-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw3.java
90 lines (63 loc) · 2.02 KB
/
hw3.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* d_i denotes a distance
s_i denotes a star, which is represented as (x,y,z), corresponding to the x, y, and z coordinates of the star.
d1 // minimal pairwise distance
s1 s2
...
d2 // maximal pairwise distance
s1 s2
s3 s2
...
d3 // minimum maximal distance
s3 s1
...
d4 // maximum minimal distance
s4
s5
...
d5 // minimal average distance
s1
...
*/
String closestNeighbors(){ /* Compute the pair of stars that minimize pairwise distance. */
return "d1";
}
closestNeighbors() @ standardOutput <- println(token);
farthestNeighbors /*Compute the pair of stars that maximize pairwise distance.*/
idealHubStar /*Compute the star which minimizes the maximal distance to any other star.*/
idealJailStar /*Compute the star which maximizes the minimal distance to any other star.*/
idealCapitalStar /*Compute the star which minimizes the average distance to all other stars.*/
/* Write an actor-based solution to the space colonization problem. */
Searcher[] actors = {searcher0, searcher1, searcher 2}; /* pg 195 */
join{
for( int i=0. i < actors.length; i++ ){
actors[i] <-find( phrase );
}
} @ customer <- output( token );
behavior Star {
Object contents;
Star( Object initialContents){
contents = initialContents;
}
Object get(){
return contents;
}
void set( Object newContents){
contents = newContents;
}
void act( String[] arguments){
}
}
myRef = new Star();
module examples;
behavior HelloWorld{
void act( String[] arguments){
standardOutput <- print("Hello")@
standardOutput <- print( "World!");
}
}
HelloWorld helloWorld = new HelloWorld() at (new UAN*"uan://nameserver/id")), new UAL("rmsp://host1:4040/id"));
/* to get its own UAN or UAL: */
UAL selfUAL = this.getUAL();
UAN selfUAN = this.getUAN();
/* Write a distributed space colonization solution. Note that in this case, the actors must communicate over a network although you do not necessarily have to run each actor on a separate machine.
If you are using SALSA, your solution will be distributed if you make use of universal actors. */