source: src/main/java/agents/qoagent/Issue.java@ 127

Last change on this file since 127 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 8.6 KB
RevLine 
[127]1package agents.qoagent;
2
3import java.util.StringTokenizer;
4
5//file name: Issue.java
6
7/*****************************************************************
8 * Class name: Issue
9 * Goal: Saving an attribute of the negotiation along with its value,
10 * weight, utility, effect of time (all strings) and whether the attribute was
11 * agreed upon (a boolen). We also save a 2 more strings: a list of
12 * all possible values (seperated by spaces) and a list of all
13 * possible utilities (seperated by spaces). Both those lists are read
14 * from the utility file.
15 * When the server gets an accept message from the client, it checks
16 * all the agreed attributes and their values. Then, we find the
17 * position of the agreed value in the values list, and find the
18 * corresponding utility value in the same position in the utilities
19 * list. We save the corresponding utility in the issue's utility field.
20 ****************************************************************/
21class Issue
22{
23 private String m_sAttribute; //the attribute's name
24 private String m_sWeight; //weight of the attribute
25 private String m_sValue; //the chosen value
26 private String m_sUtility; //the corresponding utility
27 private String m_sTimeEffect; //the time effect
28 private boolean m_bAgreed; //agreed or not
29 private int m_nTurn; //the turn in which the issue was agreed upon
30
31 private String m_sValues; //list of possible values seperated by spaces
32 private String m_sUtilities; //list of possible utilities seperated by spaces
33
34 /*****************************************************************
35 * Method name: Issue()
36 * Goal: Constructor.
37 * Description: Initialize the class variables.
38 * Input: None.
39 * Output: None.
40 ****************************************************************/
41 public Issue()
42 {
43 m_bAgreed=false;
44 m_nTurn=0;
45 m_sAttribute = "";
46 m_sValue = "";
47 m_sUtility = "";
48 m_sTimeEffect = "";
49 m_sValues = "";
50 m_sUtilities = "";
51 }
52
53 /*****************************************************************
54 * Method name: getAgreed()
55 * Goal: Return a boolean value which specifies whether the attribute
56 * was agreed or not.
57 * Input: None.
58 * Output: A boolean value.
59 ***************************************************************/
60 public boolean getAgreed()
61 {
62 return m_bAgreed;
63 }
64
65 /*****************************************************************
66 * Method name: setAgreed()
67 * Goal: Setting the boolean value which specifies whether the attribute was
68 * agreed or not.
69 * Input: A boolean value.
70 * Output: None.
71 ****************************************************************/
72 public void setAgreed(boolean bAgreed)
73 {
74 m_bAgreed = bAgreed;
75 }
76
77 /*****************************************************************
78 * Method name: getTurn()
79 * Goal: Return the turn in which the issue was agreed upon.
80 * Input: None.
81 * Output: An integer.
82 ***************************************************************/
83 public int getTurn()
84 {
85 return m_nTurn;
86 }
87
88 /*****************************************************************
89 * Method name: setTurn()
90 * Goal: Setting the turn in which the issue was agreed upon.
91 * Input: An integer.
92 * Output: None.
93 ****************************************************************/
94 public void setTurn(int nTurn)
95 {
96 m_nTurn = nTurn;
97 }
98
99 /*****************************************************************
100 * Method name: getAttribute()
101 * Goal: Return the attribute's name.
102 * Input: None.
103 * Output: A string.
104 ****************************************************************/
105 public String getAttribute()
106 {
107 return m_sAttribute;
108 }
109
110 /*****************************************************************
111 * Method name: setAttribute()
112 * Goal: Setting the attribute's name.
113 * Input: A string.
114 * Output: None.
115 ****************************************************************/
116 public void setAttribute(String sAttribute)
117 {
118 m_sAttribute = sAttribute;
119 }
120
121 /*****************************************************************
122 * Method name: setWeight()
123 * Goal: Setting the attribute's weight.
124 * Input: A string.
125 * Output: None.
126 ****************************************************************/
127 public void setWeight(String sWeight)
128 {
129 m_sWeight = sWeight;
130 }
131
132 /*****************************************************************
133 * Method name: getWeight()
134 * Goal: Return the attribute's weight.
135 * Input: None.
136 * Output: A string.
137 ****************************************************************/
138 public String getWeight()
139 {
140 return m_sWeight;
141 }
142
143 /*****************************************************************
144 * Method name: getValue()
145 * Goal: Return the attribute's value.
146 * Input: None.
147 * Output: A string.
148 ****************************************************************/
149 public String getValue()
150 {
151 return m_sValue;
152 }
153
154 /*****************************************************************
155 * Method name: getValues()
156 * Goal: Return the list of values.
157 * Input: None.
158 * Output: A string.
159 ****************************************************************/
160 public String getValues()
161 {
162 return m_sValues;
163 }
164
165 /*****************************************************************
166 * Method name: getUtility()
167 * Goal: Return the attribute's utility value.
168 * Input: None.
169 * Output: A string.
170 ****************************************************************/
171 public String getUtility()
172 {
173 return m_sUtility;
174 }
175
176 /*****************************************************************
177 * Method name: getUtilities()
178 * Goal: Return the list of utility values.
179 * Input: None.
180 * Output: A string.
181 ****************************************************************/
182 public String getUtilities()
183 {
184 return m_sUtilities;
185 }
186
187 /*****************************************************************
188 * Method name: getTimeEffect()
189 * Goal: Return the attribute's time effect value.
190 * Input: None.
191 * Output: A string.
192 ****************************************************************/
193 public String getTimeEffect()
194 {
195 return m_sTimeEffect;
196 }
197
198 /*****************************************************************
199 * Method name: setValue()
200 * Goal: Setting the attribute's value.
201 * Input: A string.
202 * Output: None.
203 ****************************************************************/
204 public void setValue(String sValue)
205 {
206 m_sValue = sValue;
207 }
208
209 /*****************************************************************
210 * Method name: setValues()
211 * Goal: Setting the list of values.
212 * Input: A string.
213 * Output: None.
214 ****************************************************************/
215 public void setValues(String sValues)
216 {
217 m_sValues = sValues;
218 }
219
220 /*****************************************************************
221 * Method name: setUtility()
222 * Goal: Setting the attribute's utility.
223 * Input: A string.
224 * Output: None.
225 ****************************************************************/
226 public void setUtility(String sUtility)
227 {
228 m_sUtility = sUtility;
229 }
230
231 /*****************************************************************
232 * Method name: setUtilities()
233 * Goal: Setting the list of utilities.
234 * Input: A string.
235 * Output: None.
236 ****************************************************************/
237 public void setUtilities(String sUtilities)
238 {
239 m_sUtilities = sUtilities;
240 }
241
242 /*****************************************************************
243 * Method name: setTimeEffect()
244 * Goal: Setting the attribute's effect of time.
245 * Input: A string.
246 * Output: None.
247 ****************************************************************/
248 public void setTimeEffect(String sTimeEffect)
249 {
250 m_sTimeEffect = sTimeEffect;
251 }
252
253 public void setNoAgreementValue()
254 {
255 //finds the value's position in the values line
256 //in order to find corresponding utility and effect of time
257 int position=1; //this variable will hold the value's position
258 String values = getValues();
259 StringTokenizer stValues=new StringTokenizer(values, "~");
260 while(stValues.hasMoreTokens())
261 {
262 String value=stValues.nextToken();
263 if(value.equals(AutomatedAgentType.NOT_APPLICABLE_STR1))
264 {
265 break;
266 }
267 position++;
268 }
269 setValue(AutomatedAgentType.NOT_APPLICABLE_STR1); //set the value of the issue at the agent
270
271 //finds and sets corresponding utility value
272 String utilities = getUtilities();
273 StringTokenizer stUtilities=new StringTokenizer(utilities);
274 String utility="";
275 for(int i=1; (i<=position)&&(stUtilities.hasMoreTokens()); i++)
276 {
277 utility=stUtilities.nextToken();
278 }
279 setUtility(utility); //set the utility value of the issue at the agent
280 }
281}
Note: See TracBrowser for help on using the repository browser.