1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package zeus.actors.rtn.util;
25
26 import java.util.*;
27 import zeus.util.*;
28 import zeus.concepts.Goal;
29
30 /***
31 * This is the primary coordination structure. One is created for each goal
32 * at the start of a coordination process, and maintained until the end of
33 * the planning/contracting process.
34 */
35 public class GraphStruct implements Cloneable {
36 /***
37 * A vector containing the root goal
38 */
39 public Vector goal = null;
40 /***
41 *A vector containing subgoals of the root goal that the agent can
42 * perform on its own.
43 */
44 public Vector internal = null;
45 /***
46 * A vector of subgoals of the root that need to be delegated/contracted
47 * out.
48 */
49 public Vector external = null;
50
51 /***
52 * A vector containing the results of a delegation round
53 */
54 public Vector d_results = null;
55
56 /***
57 * A vector of {@link DelegationStruct}s of from agents whose proposals
58 * will be accepted.
59 */
60 public Vector selection = new Vector();
61
62 /***
63 * If agentA contracts a task out to another agentB, then
64 * gs.confirmed for agentB indicates whether agentA has confirmed the
65 * contract or not.
66 */
67 public boolean confirmed = false;
68
69 /***
70 * If agentA contracts a task out to another agentB, then
71 * gs.agent for agentB will point to agentA.
72 */
73 public String agent = null;
74
75 /***
76 * The contract reference.
77 */
78 public String key = null;
79
80 /***
81 * A temporary structure for holding miscellaneous information.
82 */
83 public Object any = null;
84
85 /***
86 * The amount of time availabe for the contracting process.
87 */
88 public double timeout = 0;
89
90 /***
91 * The list of agents to ignore, i.e. not to attempt contracting the goal
92 * out to.
93 */
94 public Vector ignore_agents = new Vector();
95
96 /***
97 * If agentA contracts a task out to another agentB, then
98 * gs.confirmed_goal for agentB will contain the final goal agreed to by
99 * agentB and confirmed by agentA. This goal might contain additional
100 * information such references to agents that will be provide resources to
101 * agentB so that it can achieve the goal.
102 */
103 public Vector confirmed_goal = null;
104
105 /***
106 * A structure containing summary task decomposition information that is
107 * utilised during planning.
108 */
109 public Hashtable decompositions;
110
111 /***
112 * A list of all {@link StrategyEvaluator}s participating in the
113 * contracting process for the goal. <p>
114 * For example, assume a goal g0 decomposes into two external
115 * subgoals g1 and g2. Now an attempt is made to contract out g1 to agents
116 * B and C, and g2 to agent D, E, F. In this case, we will have 5 strategy
117 * evaluators, one for each subgoal/agent combination. The shared strategy
118 * evaluator list allows one evaluator to consider the status of other
119 * evaluators when making bidding decisions. (Note: No implemented example
120 * to date has utilised the cross-evaluator dialogue feature).
121 */
122 public StrategyEvaluatorList evaluators = new StrategyEvaluatorList();
123
124 public GraphStruct() {
125 }
126 public GraphStruct(String agent, Goal g) {
127 goal = new Vector();
128 goal.addElement(g);
129 this.agent = agent;
130 this.key = g.getId();
131 }
132 public GraphStruct(String agent, Goal g, String key) {
133 goal = new Vector();
134 goal.addElement(g);
135 this.agent = agent;
136 this.key = key;
137 }
138 public GraphStruct(String agent, Goal g, String key,
139 Vector internal, Vector external) {
140 goal = new Vector();
141 goal.addElement(g);
142 this.agent = agent;
143 this.key = key;
144 this.internal = internal;
145 this.external = external;
146 }
147 public GraphStruct(String agent, Vector goal) {
148 this.goal = goal;
149 this.agent = agent;
150 this.key = ((Goal)goal.elementAt(0)).getId();
151 }
152 public GraphStruct(String agent, String key, Vector goals) {
153 this.goal = goals;
154 this.key = key;
155 this.agent = agent;
156 }
157
158 public String toString() {
159 String output = "(goal " + goal + "\n" +
160 " internal " + internal + "\n" +
161 " external " + external + "\n" +
162 " d_results " + d_results + "\n" +
163 " selection " + selection + "\n" +
164 " confirmed " + confirmed + "\n" +
165 " agent " + agent + "\n" +
166 " key " + key + "\n" +
167 " any " + any + "\n" +
168 " timeout " + timeout + "\n" +
169 " ignore_agents " + ignore_agents + "\n" +
170 " confirmed_goal " + confirmed_goal + "\n" +
171 " evaluators " + evaluators + "\n" +
172 " decompositions " + decompositions + "\n" + ")";
173
174 return output;
175 }
176 public GraphStruct duplicate() {
177 GraphStruct gs = new GraphStruct();
178 gs.goal = Misc.copyVector(goal);
179 gs.internal = Misc.copyVector(internal);
180 gs.external = Misc.copyVector(external);
181 gs.d_results = Misc.copyVector(d_results);
182 gs.selection = Misc.copyVector(selection);
183 gs.confirmed_goal = Misc.copyVector(confirmed_goal);
184 gs.confirmed = confirmed;
185 gs.agent = agent;
186 gs.key = key;
187 gs.any = any;
188 gs.timeout = timeout;
189 gs.ignore_agents = Misc.copyVector(ignore_agents);
190 gs.evaluators = evaluators;
191 return gs;
192 }
193 }