1 | package agents.anac.y2015.SENGOKU.etc;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.HashMap;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import genius.core.Bid;
|
---|
8 | import genius.core.issue.Issue;
|
---|
9 | import genius.core.issue.IssueDiscrete;
|
---|
10 | import genius.core.issue.IssueInteger;
|
---|
11 | import genius.core.issue.Value;
|
---|
12 | import genius.core.issue.ValueDiscrete;
|
---|
13 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
14 |
|
---|
15 | public class negotiatingInfo {
|
---|
16 | private AdditiveUtilitySpace utilitySpace; // 効用空間
|
---|
17 | private List<Issue> issues; // 論点
|
---|
18 | private ArrayList<Object> opponents; // 自身以外の交渉参加者のsender
|
---|
19 | private ArrayList<Bid> MyBidHistory = null; // 提案履歴 自分!
|
---|
20 | private HashMap<Object, ArrayList<Bid>> opponentsBidHistory = null; // 提案履歴 相手! ハッシュマップで保存!
|
---|
21 | private HashMap<Object, ArrayList<Boolean>> opponentsCooperateHistory = null; // 相手の協力履歴
|
---|
22 | private HashMap<Object, Double> opponentsAverage; // 平均
|
---|
23 | private double allAverage = 0.0; // すべての平均
|
---|
24 | private HashMap<Object, Double> opponentsVariance; // 分散
|
---|
25 | private double allVariance = 0.0; // すべての分散
|
---|
26 | private HashMap<Object, Double> opponentsSum; // 和
|
---|
27 | private HashMap<Object, Double> opponentsPowSum; // 二乗和
|
---|
28 | private HashMap<Object, Double> opponentsStandardDeviation; // 標準偏差
|
---|
29 | private HashMap<Issue, HashMap<Value, Double>> valueRelativeUtility = null; // 自身の効用空間における各論点値の相対効用値行列(線形効用空間用)
|
---|
30 | private HashMap<Issue, HashMap<Value, Double>> valueNumUtility = null; // 自身の効用空間における各論点値の相対効用値行列(線形効用空間用
|
---|
31 | private int round = 0; // 自分の手番数
|
---|
32 | private int negotiatorNum = 3; // 交渉者数
|
---|
33 |
|
---|
34 | private int acceptNum = 0; // アクセプト数
|
---|
35 | private double acceptRate = 0.0; // アクセプト率1ラウンドあたり
|
---|
36 |
|
---|
37 | private boolean isLinerUtilitySpace = true; // 線形効用空間であるかどうか
|
---|
38 |
|
---|
39 | // オリジナルプロパティー
|
---|
40 | private int ActionFlag = 0; // 戦術番号
|
---|
41 | private HashMap<Object, ArrayList<Bid>> newBidHistory = null; // 提案履歴 相手! ハッシュマップで保存!近い履歴
|
---|
42 | private HashMap<Object, Double> newAverage; // 平均
|
---|
43 | private HashMap<Object, Double> newVariance; // 分散
|
---|
44 | private HashMap<Object, Double> newStandardDeviation; // 標準偏差
|
---|
45 | private HashMap<Object, Double> newSumNum; // 重複回数
|
---|
46 | private HashMap<Object, Double> newAccept; // アクセプトフラグ
|
---|
47 | private ArrayList<Double> allMaxShreshold; // 最大の閾値をたえず保存
|
---|
48 | private HashMap<Object, ArrayList<Double>> BidValue; // 提案したビットの自分の効用値
|
---|
49 | private Object OfferPlayer = null;
|
---|
50 | private HashMap<Object, Double> maxUtil; // 相手の提案の最大値
|
---|
51 | private ArrayList<Bid> LastOfferBidHistory = null; // 最後の提案に使う用のビッドリスト
|
---|
52 | private ArrayList<Double> aveTime = new ArrayList<Double>(); // 自分のターンが回ってくるまでの時間
|
---|
53 | public Boolean lastFlag = false; // 最後の妥協にしようするフラグ
|
---|
54 |
|
---|
55 | public negotiatingInfo(AdditiveUtilitySpace utilitySpace) {
|
---|
56 | // 初期化
|
---|
57 | this.utilitySpace = utilitySpace;
|
---|
58 | issues = utilitySpace.getDomain().getIssues();
|
---|
59 | opponents = new ArrayList<Object>();
|
---|
60 | MyBidHistory = new ArrayList<Bid>();
|
---|
61 | opponentsBidHistory = new HashMap<Object, ArrayList<Bid>>();
|
---|
62 | opponentsCooperateHistory = new HashMap<Object, ArrayList<Boolean>>();
|
---|
63 | opponentsAverage = new HashMap<Object, Double>();
|
---|
64 | opponentsVariance = new HashMap<Object, Double>();
|
---|
65 | opponentsSum = new HashMap<Object, Double>();
|
---|
66 | opponentsPowSum = new HashMap<Object, Double>();
|
---|
67 | opponentsStandardDeviation = new HashMap<Object, Double>();
|
---|
68 | valueRelativeUtility = new HashMap<Issue, HashMap<Value, Double>>();
|
---|
69 | valueNumUtility = new HashMap<Issue, HashMap<Value, Double>>();
|
---|
70 |
|
---|
71 | // 新しいのの初期化
|
---|
72 | newBidHistory = new HashMap<Object, ArrayList<Bid>>();
|
---|
73 | newAverage = new HashMap<Object, Double>();
|
---|
74 | newVariance = new HashMap<Object, Double>();
|
---|
75 | newStandardDeviation = new HashMap<Object, Double>();
|
---|
76 | newSumNum = new HashMap<Object, Double>();
|
---|
77 | newAccept = new HashMap<Object, Double>();
|
---|
78 | BidValue = new HashMap<Object, ArrayList<Double>>();
|
---|
79 | allMaxShreshold = new ArrayList<Double>();
|
---|
80 | maxUtil = new HashMap<Object, Double>();
|
---|
81 | LastOfferBidHistory = new ArrayList<Bid>();
|
---|
82 |
|
---|
83 | try {
|
---|
84 | initValueRelativeUtility();
|
---|
85 | } catch (Exception e) {
|
---|
86 | System.out.println("相対効用行列の初期化に失敗しました");
|
---|
87 | e.printStackTrace();
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void initOpponent(Object sender) {
|
---|
92 | initNegotiatingInfo(sender); // 交渉情報を初期化
|
---|
93 | opponents.add(sender); // 交渉参加者にsenderを追加
|
---|
94 | }
|
---|
95 |
|
---|
96 | public void updateInfo(Object sender, Bid offeredBid) {
|
---|
97 | try {
|
---|
98 | updateNegotiatingInfo(sender, offeredBid);
|
---|
99 | } // 交渉情報の更新
|
---|
100 | catch (Exception e1) {
|
---|
101 | System.out.println("交渉情報の更新に失敗しました");
|
---|
102 | e1.printStackTrace();
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | private void initNegotiatingInfo(Object sender) {
|
---|
107 | opponentsBidHistory.put(sender, new ArrayList<Bid>());
|
---|
108 | opponentsCooperateHistory.put(sender, new ArrayList<Boolean>());
|
---|
109 | opponentsAverage.put(sender, 0.0);
|
---|
110 | opponentsVariance.put(sender, 0.0);
|
---|
111 | opponentsSum.put(sender, 0.0);
|
---|
112 | opponentsPowSum.put(sender, 0.0);
|
---|
113 | opponentsStandardDeviation.put(sender, 0.0);
|
---|
114 | newBidHistory.put(sender, new ArrayList<Bid>());
|
---|
115 | newAverage.put(sender, 0.0);
|
---|
116 | newVariance.put(sender, 0.0);
|
---|
117 | newStandardDeviation.put(sender, 0.0);
|
---|
118 | newSumNum.put(sender, 0.0);
|
---|
119 | newAccept.put(sender, 0.0);
|
---|
120 | BidValue.put(sender, new ArrayList<Double>());
|
---|
121 | maxUtil.put(sender, 0.0);
|
---|
122 | }
|
---|
123 |
|
---|
124 | // 相対効用行列の初期化
|
---|
125 | private void initValueRelativeUtility() throws Exception {
|
---|
126 | ArrayList<Value> values = null;
|
---|
127 | for (Issue issue : issues) {
|
---|
128 | valueRelativeUtility.put(issue, new HashMap<Value, Double>()); // 論点行の初期化
|
---|
129 | valueNumUtility.put(issue, new HashMap<Value, Double>()); // 論点行の初期化
|
---|
130 | values = getValues(issue);
|
---|
131 | for (Value value : values) { // 論点行の要素の初期化
|
---|
132 | valueRelativeUtility.get(issue).put(value, 0.0);
|
---|
133 | valueNumUtility.get(issue).put(value, 0.0);
|
---|
134 | }
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | // 相対効用行列の導出
|
---|
139 | public void setValueRelativeUtility(Bid maxBid) throws Exception {
|
---|
140 | ArrayList<Value> values = null;
|
---|
141 | Bid currentBid = null;
|
---|
142 | for (Issue issue : issues) {
|
---|
143 | currentBid = new Bid(maxBid);
|
---|
144 | values = getValues(issue);
|
---|
145 | for (Value value : values) {
|
---|
146 | currentBid = currentBid.putValue(issue.getNumber(), value);
|
---|
147 | valueRelativeUtility.get(issue).put(
|
---|
148 | value,
|
---|
149 | utilitySpace.getUtility(currentBid)
|
---|
150 | - utilitySpace.getUtility(maxBid));
|
---|
151 | }
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | // 相手の提案している値の数を数えていく 相手すべての頻度行列
|
---|
156 | public void setValueNumUtility(Bid maxBid) throws Exception {
|
---|
157 | ArrayList<Value> values = null;
|
---|
158 | Bid currentBid = null;
|
---|
159 | for (Issue issue : issues) {
|
---|
160 | currentBid = new Bid(maxBid);
|
---|
161 | Value onValue = currentBid.getValue(issue.getNumber());
|
---|
162 | values = getValues(issue);
|
---|
163 | for (Value value : values) {
|
---|
164 | if (onValue.equals(value)) {
|
---|
165 | Double i = valueRelativeUtility.get(issue).get(value);
|
---|
166 | valueRelativeUtility.get(issue).put(value, i + 1.0);
|
---|
167 | }
|
---|
168 | }
|
---|
169 | }
|
---|
170 | }
|
---|
171 |
|
---|
172 | public void updateNegotiatingInfo(Object sender, Bid offeredBid)
|
---|
173 | throws Exception {
|
---|
174 | OfferPlayer = sender;
|
---|
175 | opponentsBidHistory.get(sender).add(offeredBid); // 提案履歴
|
---|
176 |
|
---|
177 | // utilは相手の提案に対するそのあたい効用値である! 自分の提案は自分でわかる!
|
---|
178 | // utilitySpace.getUtility 引数ビットにたいする公用地を返す自分のみ!
|
---|
179 | double util = utilitySpace.getUtility(offeredBid);
|
---|
180 | updateBidValue(sender, util);
|
---|
181 | if (maxUtil.get(sender) < util) {
|
---|
182 | maxUtil.put(sender, util);
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (!lastFlag) {
|
---|
186 | if (LastOfferBidHistory.size() == 0) {
|
---|
187 | LastOfferBidHistory.add(offeredBid);
|
---|
188 | } else if (utilitySpace.getUtility(LastOfferBidHistory
|
---|
189 | .get(LastOfferBidHistory.size() - 1)) < util) {
|
---|
190 | LastOfferBidHistory.add(offeredBid);
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | // 新しいものを更新していくクラス!
|
---|
195 | test(sender);
|
---|
196 |
|
---|
197 | round++;
|
---|
198 | opponentsSum.put(sender, opponentsSum.get(sender) + util); // 和
|
---|
199 | opponentsPowSum.put(sender,
|
---|
200 | opponentsPowSum.get(sender) + Math.pow(util, 2)); // 二乗和
|
---|
201 |
|
---|
202 | int round_num = opponentsBidHistory.get(sender).size();
|
---|
203 | opponentsAverage.put(sender, opponentsSum.get(sender) / round_num); // 平均
|
---|
204 | opponentsVariance.put(sender, (opponentsPowSum.get(sender) / round_num)
|
---|
205 | - Math.pow(opponentsAverage.get(sender), 2)); // 分散
|
---|
206 |
|
---|
207 | if (opponentsVariance.get(sender) < 0) {
|
---|
208 | opponentsVariance.put(sender, 0.0);
|
---|
209 | }
|
---|
210 | opponentsStandardDeviation.put(sender,
|
---|
211 | Math.sqrt(opponentsVariance.get(sender))); // 標準偏差
|
---|
212 |
|
---|
213 | }
|
---|
214 |
|
---|
215 | // 提案履歴から最新x個を取り出して平均とかを求める!
|
---|
216 | public void test(Object sender) throws Exception {
|
---|
217 | // System.out.println(opponentsBidHistory.get(sender));
|
---|
218 | ArrayList<Bid> bidlist = opponentsBidHistory.get(sender);
|
---|
219 | int x = 6; // どれだけの最新でーたを採用するか
|
---|
220 | double sumNum = 0; // どれだけ重複しているか
|
---|
221 | int bitSize = bidlist.size(); // どれだけ履歴があるか
|
---|
222 | int count = x; // 実際の入れる配列数
|
---|
223 | if (bitSize < x) {
|
---|
224 | count = bitSize;
|
---|
225 | }
|
---|
226 |
|
---|
227 | double sum = 0;
|
---|
228 | double ave = 0;
|
---|
229 | double v = 0;
|
---|
230 | double sd = 0;
|
---|
231 |
|
---|
232 | ArrayList<Bid> newlist = new ArrayList<Bid>();
|
---|
233 |
|
---|
234 | for (int i = 0; count > i; i++) {
|
---|
235 | Bid inBit = bidlist.get(bitSize - i - 1); // 入れるビット
|
---|
236 | // 何回同じ提案があるか計算
|
---|
237 | if (newlist.contains(inBit)) {
|
---|
238 | sumNum = sumNum + 1.0;
|
---|
239 | }
|
---|
240 |
|
---|
241 | newlist.add(inBit);
|
---|
242 | double util = utilitySpace.getUtility(inBit);
|
---|
243 | sum = sum + util;
|
---|
244 | }
|
---|
245 |
|
---|
246 | ave = sum / count; // 平均を出す
|
---|
247 | for (int i = 0; count > i; i++) {
|
---|
248 | newlist.add(bidlist.get(bitSize - i - 1));
|
---|
249 | double util = utilitySpace.getUtility(bidlist.get(bitSize - i - 1));
|
---|
250 | v = v + Math.pow((ave - util), 2);
|
---|
251 | }
|
---|
252 |
|
---|
253 | sd = Math.sqrt(v);
|
---|
254 | newBidHistory.put(sender, newlist);
|
---|
255 | newAverage.put(sender, ave);
|
---|
256 | newVariance.put(sender, v);
|
---|
257 | newStandardDeviation.put(sender, sd);
|
---|
258 | newSumNum.put(sender, sumNum);
|
---|
259 | if (newAccept.get(sender) > 0.0) {
|
---|
260 | newAccept.put(sender, newAccept.get(sender) - 1.0 / x);
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 | // 他人がアクセプトしたときのデータ更新
|
---|
265 | public void updateAccept(Object sender) {
|
---|
266 | // すべてのアクセプトの数
|
---|
267 | acceptNum++;
|
---|
268 | // 1巡のアクセプト率
|
---|
269 | double rate = 1.0 / opponents.size();
|
---|
270 | acceptRate = acceptRate + rate;
|
---|
271 | // ある人の最近アクセプト
|
---|
272 | newAccept.put(sender, 1.0);
|
---|
273 | }
|
---|
274 |
|
---|
275 | // 得られる最大をすべて保存
|
---|
276 | public void updateMaxThreshold(double threshold) {
|
---|
277 | allMaxShreshold.add(threshold);
|
---|
278 | }
|
---|
279 |
|
---|
280 | // //得られる最大を返す
|
---|
281 | public ArrayList<Double> getMaxThreshold() {
|
---|
282 | return allMaxShreshold;
|
---|
283 | }
|
---|
284 |
|
---|
285 | // アクセプト率をリセット
|
---|
286 | public void resetAcceptRate() {
|
---|
287 | acceptRate = 0.0;
|
---|
288 | }
|
---|
289 |
|
---|
290 | // 自分が何をするか オファーのとき
|
---|
291 | public void myActionOffer() {
|
---|
292 | ActionFlag = 0;
|
---|
293 | }
|
---|
294 |
|
---|
295 | // 自分が何をするか アクセプトの時
|
---|
296 | public void myActionAccept() {
|
---|
297 | ActionFlag = 1;
|
---|
298 | }
|
---|
299 |
|
---|
300 | // 交渉者数を返す
|
---|
301 | public void updateOpponentsNum(int num) {
|
---|
302 | negotiatorNum = num;
|
---|
303 | }
|
---|
304 |
|
---|
305 | // 線形効用空間でない場合
|
---|
306 | public void utilitySpaceTypeisNonLiner() {
|
---|
307 | isLinerUtilitySpace = false;
|
---|
308 | }
|
---|
309 |
|
---|
310 | // 自身の提案情報の更新
|
---|
311 | public void updateMyBidHistory(Bid offerBid) {
|
---|
312 | MyBidHistory.add(offerBid);
|
---|
313 | }
|
---|
314 |
|
---|
315 | // 平均
|
---|
316 | public double getAverage(Object sender) {
|
---|
317 | return opponentsAverage.get(sender);
|
---|
318 | }
|
---|
319 |
|
---|
320 | // 分散
|
---|
321 | public double getVariancer(Object sender) {
|
---|
322 | return opponentsVariance.get(sender);
|
---|
323 | }
|
---|
324 |
|
---|
325 | // 最新の平均
|
---|
326 | public double getNewAverage(Object sender) {
|
---|
327 | return newAverage.get(sender);
|
---|
328 | }
|
---|
329 |
|
---|
330 | // 最新の分散
|
---|
331 | public double getNewVariancer(Object sender) {
|
---|
332 | return newVariance.get(sender);
|
---|
333 | }
|
---|
334 |
|
---|
335 | // 平均
|
---|
336 | public double getAllAverage(double m) {
|
---|
337 | return allAverage;
|
---|
338 | }
|
---|
339 |
|
---|
340 | // 分散
|
---|
341 | public double getAllVariancer(double v) {
|
---|
342 | return allVariance;
|
---|
343 | }
|
---|
344 |
|
---|
345 | // 標準偏差
|
---|
346 | public double getStandardDeviation(Object sender) {
|
---|
347 | return opponentsStandardDeviation.get(sender);
|
---|
348 | }
|
---|
349 |
|
---|
350 | // 新しい標準偏差
|
---|
351 | public double getNewStandardDeviation(Object sender) {
|
---|
352 | return newStandardDeviation.get(sender);
|
---|
353 | }
|
---|
354 |
|
---|
355 | // 相手の協力状態を返す
|
---|
356 | public ArrayList<Double> getBidValue(Object sender) {
|
---|
357 | return BidValue.get(sender);
|
---|
358 | }
|
---|
359 |
|
---|
360 | // 相手の協力状態を更新
|
---|
361 | public void updateBidValue(Object sender, double util) {
|
---|
362 | BidValue.get(sender).add(util);
|
---|
363 | }
|
---|
364 |
|
---|
365 | // 相手の提案履歴の要素数を返す
|
---|
366 | public int getPartnerBidNum(Object sender) {
|
---|
367 | return opponentsBidHistory.get(sender).size();
|
---|
368 | }
|
---|
369 |
|
---|
370 | // 相手の提案履歴を返す
|
---|
371 | public ArrayList<Bid> getPartnerBid(Object sender) {
|
---|
372 | return opponentsBidHistory.get(sender);
|
---|
373 | }
|
---|
374 |
|
---|
375 | // 相手の協力情報を更新する 協力ならtrue
|
---|
376 | public void updateopponentsCooperateHistory(Object sender, boolean state) {
|
---|
377 | opponentsCooperateHistory.get(sender).add(state);
|
---|
378 | }
|
---|
379 |
|
---|
380 | // 相手の協力情報をリストで返す
|
---|
381 | public ArrayList<Boolean> getopponentsCooperateHistory(Object sender) {
|
---|
382 | return opponentsCooperateHistory.get(sender);
|
---|
383 | }
|
---|
384 |
|
---|
385 | // 最後のリストを返す
|
---|
386 | public Bid getLastOfferBidHistry() {
|
---|
387 | int size = LastOfferBidHistory.size();
|
---|
388 | return LastOfferBidHistory.get(size - 1);
|
---|
389 | }
|
---|
390 |
|
---|
391 | // 最後のビットのリストのサイズを返す
|
---|
392 | public int getLastOfferBidNum() {
|
---|
393 | return LastOfferBidHistory.size();
|
---|
394 | }
|
---|
395 |
|
---|
396 | public void removeLastOfferBidHistry() {
|
---|
397 | int size = LastOfferBidHistory.size();
|
---|
398 | LastOfferBidHistory.remove(size - 1);
|
---|
399 | }
|
---|
400 |
|
---|
401 | // 自分の提案履歴を返す
|
---|
402 | public ArrayList<Bid> getMyBidHistory() {
|
---|
403 | return MyBidHistory;
|
---|
404 | }
|
---|
405 |
|
---|
406 | // オファーしている相手を返す
|
---|
407 | public Object getOfferPlayer() {
|
---|
408 | return OfferPlayer;
|
---|
409 | }
|
---|
410 |
|
---|
411 | // 新しい提案の重複数
|
---|
412 | public double getNewSumNum(Object sender) {
|
---|
413 | return newSumNum.get(sender);
|
---|
414 | }
|
---|
415 |
|
---|
416 | // 新しいアクセプト数
|
---|
417 | public double getNewAccept(Object sender) {
|
---|
418 | return newAccept.get(sender);
|
---|
419 | }
|
---|
420 |
|
---|
421 | // 自身のラウンド数を返す
|
---|
422 | public int getRound() {
|
---|
423 | return round;
|
---|
424 | }
|
---|
425 |
|
---|
426 | // 自身の行動フラグを返す
|
---|
427 | public int getActionFlag() {
|
---|
428 | return ActionFlag;
|
---|
429 | }
|
---|
430 |
|
---|
431 | // アクセプト数を返す
|
---|
432 | public int getAccept() {
|
---|
433 | return acceptNum;
|
---|
434 | }
|
---|
435 |
|
---|
436 | // アクセプト数を返す
|
---|
437 | public double getAcceptRate() {
|
---|
438 | return acceptRate;
|
---|
439 | }
|
---|
440 |
|
---|
441 | // 相手の提案の有効値の最大を返す
|
---|
442 | public double getmaxUtil(Object sender) {
|
---|
443 | return maxUtil.get(sender);
|
---|
444 | }
|
---|
445 |
|
---|
446 | // 交渉者数を返す
|
---|
447 | public int getNegotiatorNum() {
|
---|
448 | return negotiatorNum;
|
---|
449 | }
|
---|
450 |
|
---|
451 | // 相対効用行列を返す
|
---|
452 | public HashMap<Issue, HashMap<Value, Double>> getValueRelativeUtility() {
|
---|
453 | return valueRelativeUtility;
|
---|
454 | }
|
---|
455 |
|
---|
456 | // 線形効用空間であるかどうかを返す
|
---|
457 | public boolean isLinerUtilitySpace() {
|
---|
458 | return isLinerUtilitySpace;
|
---|
459 | }
|
---|
460 |
|
---|
461 | // 論点一覧を返す
|
---|
462 | public List<Issue> getIssues() {
|
---|
463 | return issues;
|
---|
464 | }
|
---|
465 |
|
---|
466 | // 論点における取り得る値の一覧を返す それほど大したものではない
|
---|
467 | public ArrayList<Value> getValues(Issue issue) {
|
---|
468 | ArrayList<Value> values = new ArrayList<Value>();
|
---|
469 | switch (issue.getType()) {
|
---|
470 | case DISCRETE:
|
---|
471 | List<ValueDiscrete> valuesDis = ((IssueDiscrete) issue).getValues();
|
---|
472 | for (Value value : valuesDis) {
|
---|
473 | values.add(value);
|
---|
474 | }
|
---|
475 | break;
|
---|
476 | case INTEGER:
|
---|
477 | int min_value = ((IssueInteger) issue).getUpperBound();
|
---|
478 | int max_value = ((IssueInteger) issue).getUpperBound();
|
---|
479 | for (int j = min_value; j <= max_value; j++) {
|
---|
480 | Object valueObject = new Integer(j);
|
---|
481 | values.add((Value) valueObject);
|
---|
482 | }
|
---|
483 | break;
|
---|
484 | default:
|
---|
485 | try {
|
---|
486 | throw new Exception("issue type " + issue.getType()
|
---|
487 | + " not supported by Atlas3");
|
---|
488 | } catch (Exception e) {
|
---|
489 | System.out.println("論点の取り得る値の取得に失敗しました");
|
---|
490 | e.printStackTrace();
|
---|
491 | }
|
---|
492 | }
|
---|
493 | return values;
|
---|
494 | }
|
---|
495 |
|
---|
496 | // すべての論点の内容を返す 勝手に出力
|
---|
497 | public void getValueAll() {
|
---|
498 | for (int i = 0; getIssues().size() > i; i++) {
|
---|
499 | System.out.println(getValues(getIssues().get(i)));
|
---|
500 | }
|
---|
501 | }
|
---|
502 |
|
---|
503 | public void updateTime(double time) {
|
---|
504 |
|
---|
505 | if (aveTime.size() == 0) {
|
---|
506 | aveTime.add(time);
|
---|
507 | } else {
|
---|
508 | double allTime = 0.0;
|
---|
509 | for (int i = 0; i < aveTime.size(); i++) {
|
---|
510 | allTime = allTime + aveTime.get(i);
|
---|
511 | }
|
---|
512 | aveTime.add(time - allTime);
|
---|
513 | }
|
---|
514 | }
|
---|
515 |
|
---|
516 | public double getAveTime() {
|
---|
517 | double allTime = 0.0;
|
---|
518 | int count = aveTime.size();
|
---|
519 | for (int i = 0; i < count; i++) {
|
---|
520 | allTime = allTime + aveTime.get(i);
|
---|
521 | }
|
---|
522 | return allTime / (double) count;
|
---|
523 | }
|
---|
524 |
|
---|
525 | public void laststrategy(double time) {
|
---|
526 | updateTime(time);
|
---|
527 | double lastTime = 1 - time;
|
---|
528 | int bidNum = LastOfferBidHistory.size() + 2;
|
---|
529 | // System.out.println(LastOfferBidHistory.size() +
|
---|
530 | // "-----list"+LastOfferBidHistory);
|
---|
531 | double yosokuTime = (double) bidNum * getAveTime();
|
---|
532 | if (lastTime < yosokuTime) {
|
---|
533 | lastFlag = true;
|
---|
534 | }
|
---|
535 | }
|
---|
536 |
|
---|
537 | // 交渉相手の一覧を返す
|
---|
538 | public ArrayList<Object> getOpponents() {
|
---|
539 | return opponents;
|
---|
540 | }
|
---|
541 | }
|
---|