source: src/main/java/agents/anac/y2014/AgentTRP/AgentTRP.java@ 127

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

Initial import : Genius 9.0.0

File size: 25.3 KB
Line 
1package agents.anac.y2014.AgentTRP;
2
3import java.io.Serializable;
4import java.util.List;
5import java.util.Random;
6
7import genius.core.Agent;
8import genius.core.Bid;
9import genius.core.NegotiationResult;
10import genius.core.actions.Accept;
11import genius.core.actions.Action;
12import genius.core.actions.DefaultAction;
13import genius.core.actions.Offer;
14import genius.core.issue.Issue;
15import genius.core.issue.IssueInteger;
16import genius.core.issue.Value;
17import genius.core.issue.ValueInteger;
18
19/**
20 * This agent is an example of how to create an ANAC2013 agent which learns
21 * during the tournament. This agent is a variant of the random agent.
22 *
23 * @author M. Hendrikx
24 */
25public class AgentTRP extends Agent {
26
27 /** The minimum utility a bid should have to be accepted or offered. */
28 private double MINIMUM_BID_UTILITY;
29 /** The opponent's last action. */
30 private Bid opponentLastBid;
31 /** 相手�Bid */
32 private Bid opponentBid;
33 /**
34 * 自分ã�«ã�¨ã�£ã�¦ä¸€ç•ªè‰¯ã�„ç
35 * ›¸æ‰‹ã�Å
36’æ��案ã�—ã�Å
37¸Bid
38 */
39 private Bid myBestBidByOpponent;
40 /**
41 * 自分ã�«ã�¨ã�£ã�¦ä¸€ç•ªè‰¯ã�
42 * „Bid
43 */
44 private Bid myBestBid;
45 /**
46 * ã�Å
47 Ã¤Âºâ€™Ã£ï¿½â€žÃ£ï¿½Â«Ã£ï¿½Â¨Ã£ï¿½Â£Ã£ï¿½Â¦Ã¨â€°Â¯Ã£ï¿½â€¢Ã£ï¿½ï¿½
48 * ��手
49 */
50 private Bid bestBid;
51 /** 妥å�â€�ã�®å¢ƒç•Å
52’ */
53 private double[] minimumUtilities;
54
55 // 強気��弱気���戦略
56 /**
57 * 0 é�Å
58¾Ã¥Â¦Â¥Ã¥ï¿½â€� +
59 * æÅ
60½Â¢Ã§Â´Â¢Ã¦Â°â€”味 1
61 * 相手ã�Å
62’強気�判断
63 * -> 相手
64 * ã�®ãƒ™ã‚¹ãƒˆãƒ“ッドæÅ
65 â€¢Ã£ï¿½â€™Ã£â€šâ€¹
66 * 2 æ™®é€Å
67¡ -> SA
68 */
69 private int mode;
70
71 /** 1試å�ˆã�®ç·�交渉å›Å
72¾Ã¦â€¢Â° */
73 private int round;
74
75 private Random rand = new Random();
76
77 private TRPSessionData mySessionData;
78
79 public AgentTRP() {
80 }
81
82 /**
83 * Initialize the target utility to MAX(rv, max). Where rv is the
84 * reservation value of the preference profile and max is the highest
85 * utility received on the current preference profile.
86 */
87 @Override
88 public void init() {
89 // System.out.println("SessionsNr : " + sessionNr);
90 round = 0;
91 /*
92 * 戦略を設å®
93 * Å
94¡Ã£ï¿½â„¢Ã£â€šâ€¹
95 * é�¸æÅ
96 Å
97¾Ã£ï¿½Â®Ã¦â€“¹æ³â€
98 * ¢ 1.対戦å›Å
99¾Ã¦â€¢Â°
100 * 2.決裂å›Å
101¾Ã¦â€¢Â°
102 * 3.æÅ
103“€å¾Å
104’ã�®ãƒâ€
105 * œÃ£Æ’ƒãƒ‰
106 * 4.å‰�å›Å
107¾Ã£ï¿½Â®Ã§ÂµÅ
108’éï¿
109 * ½Å
110½Ã¦â„¢â€šÃ©â€““
111 */
112
113 // å�ˆæ„�çÅ
114½â€¡
115 double rate;
116
117 // System.out.print(mySessionData.breakCount);
118 // 戦績をロード
119 if (sessionNr == 0) {
120 mySessionData = null;
121 rate = 0;
122 } else {
123 mySessionData = initPrevSessionData();
124 myBestBidByOpponent = new Bid(mySessionData.opponentBestBid);
125 rate = (sessionNr - mySessionData.breakCount) / sessionNr;
126 }
127
128 // �戦
129 if (sessionNr < 2) {
130 // minimumUtilities = new
131 // double[]{0.9,0.9,0.9,0.9,0.9,0.8,0.8,0.8,0.8,0.8};
132 mode = 0; // 0
133 return;
134 } else if (rate > 0.5) {
135 // minimumUtilities = new
136 // double[]{0.9,0.9,0.9,0.9,0.9,0.8,0.8,0.8,0.75,0.75};
137 mode = 3;
138 return;
139 } else {
140 // minimumUtilities = new
141 // double[]{0.9,0.9,0.9,0.9,0.9,0.8,0.8,0.8,0.75,0.75};
142 mode = 2;
143 return;
144 }
145 }
146
147 @Override
148 public String getVersion() {
149 return "1.0";
150 }
151
152 @Override
153 public String getName() {
154 return "AgentTRP";
155 }
156
157 // å‰�å›Å
158¾Ã£ï¿½Â®Ã¤ÂºÂ¤Ã¦Â¸â€°Ã§Âµï¿½Ã¦Å
159¾Å
160“を呼�出�
161 public TRPSessionData initPrevSessionData() {
162 TRPSessionData prev = (TRPSessionData) this.loadSessionData();
163 prev.printAll();
164 myBestBidByOpponent = prev.opponentBestBid;
165 myBestBid = prev.myBestBid;
166 return prev;
167 }
168
169 /**
170 * Set the target utility for the next match on the same preference profile.
171 * If the received utility is higher than the current target, save the
172 * received utility as the new target utility.
173 */
174 // 終ã‚�ã�£ã�Å
175¸Ã£ï¿½Â¨Ã£ï¿½ï¿½Ã£ï¿½Â«Ã¥â€˜Â¼Ã£ï¿½Â°Ã£â€šÅ
176’ã‚‹
177 @Override
178 public void endSession(NegotiationResult result) {
179
180 /*
181 * --
182 * 交渉çµ�æÅ
183¾Å
184“ã‚ââ‚
185 * ¬â„¢ÃƒÂ¤Ã‚¿ï¿½Ã¥Â­Ëœ --
186 * ä¿�å­˜ã�™ã�¹ã�ï
187 * ¿½Ã¦Æ’…å ±
188 * å�ˆæ„�ビãÆ
189 * ’ƒãƒ‰ï¼Å
190’��
191 * 時間,
192 * å�ˆæ„�ã�—ã�Å
193¸Ã£Ã
194 * ¯Â¿Â½Ã¢â‚¬Â¹,
195 * 決裂å›Å
196¾Ã¦â€¢Â°Ã¯Â
197 * ¼Å
198’æ¤Å
199“ç´¢ï¼Å
200’ラã‚
201 * ¦ãƒ³ãƒ‰æ•°
202 */
203
204 Bid lastBid;
205 // æÅ
206“€å¾Å
207’�ビッド
208 if (mySessionData == null) {
209 lastBid = result.getLastBid();
210 } else {
211 // ä»Å
212 Ã£ï¿½Â¾Ã£ï¿½Â§Ã£ï¿½Â§Ã¤Â¸â‚¬Ã§â€¢ÂªÃ£ï¿½â€žÃ£ï¿½â€žÃ¥ï¿½Ë†Ã¦â€žï¿½Ã§Âµï¿½Ã¦Å
213¾Å
214“を格�
215 if (getUtility(mySessionData.lastBid) < getUtility(
216 result.getLastBid())) {
217 lastBid = result.getLastBid();
218 } else {
219 lastBid = mySessionData.lastBid;
220 }
221 }
222 // æÅ
223“€å¾Å
224’�時間
225 double lastTime = timeline.getTime();
226 // å�ˆæ„�ã�—ã�Å
227¸Ã£ï¿½â€¹Ã¥ï¿½Â¦Ã£ï¿½â€¹
228 Boolean isAgree = result.isAgreement();
229
230 boolean reset = false;
231 if (sessionNr == 0) {
232 reset = true;
233 }
234 TRPSessionData mySessionData = new TRPSessionData(lastBid, lastTime,
235 isAgree, myBestBid, myBestBidByOpponent, round, reset);
236 this.saveSessionData(mySessionData);
237 }
238
239 /**
240 * Retrieve the bid from the opponent's last action.
241 */
242 // メッセージをå�—ã�‘å�–ã�£ã�Å
243¸Ã£ï¿½Â¨Ã£ï¿½ï¿½Ã£ï¿½Â®Ã¥â€¡Â¦Ã§ï¿½â€ 
244 @Override
245 public void ReceiveMessage(Action opponentAction) {
246 opponentLastBid = DefaultAction.getBidFromAction(opponentAction);
247 opponentBid = DefaultAction.getBidFromAction(opponentAction);
248 if (myBestBidByOpponent == null || opponentBid == null) { // bestBidã�Å
249’����
250 myBestBidByOpponent = utilitySpace.getDomain().getRandomBid(null);
251 } else {
252 if (getUtility(opponentBid) >= getUtility(myBestBidByOpponent)) { // bestBid
253 // よã‚Å
254 Ã£â€šË†Ã£ï¿½â€žÃ£â€šâ€šÃ£ï¿½Â®Ã£â€šâ€™Ã¦ï¿½ï¿½Ã¦Â¡Ë†Ã£ï¿½â€”ã�Å
255¸Ã£ï¿½Â¨Ã£ï¿½ï¿½
256 myBestBidByOpponent = new Bid(opponentBid);
257 }
258 if (myBestBid == null
259 || getUtility(opponentBid) >= getUtility(myBestBid)) {
260 myBestBid = new Bid(opponentBid);
261 }
262 }
263 }
264
265 /**
266 * Accept if the utility of the opponent's is higher than the target
267 * utility; else return a random bid with a utility at least equal to the
268 * target utility.
269 */
270 @Override
271 public Action chooseAction() {
272 double time = timeline.getTime(); // ç�¾åÅ
273“¨æ™‚刻
274
275 // ã�“ã�®å€¤ã‚ˆã‚Å
276 Ã¥Â¤Â§Ã£ï¿½ï¿½Ã£ï¿½â€žBid����る
277 double minimun_utility = acceptBorder(time);
278 round += 1; // 交渉å›Å
279¾Ã¦â€¢Â°Ã£â€šâ€™Ã£â€šÂ«Ã£â€šÂ¦Ã£Æ’³ãƒˆ
280
281 /** Accept */
282 if (opponentLastBid != null
283 && getUtility(opponentLastBid) >= minimun_utility) {
284 return new Accept(getAgentID(), opponentLastBid);
285 }
286 if (mySessionData != null && getUtility(mySessionData.lastBid) < 0.6) {
287 return mode(time);
288 }
289
290 // æÅ
291“€åˆ�ã�‹æÅ
292“€å¾Å
293’�1戦以ä¸Å
294 Ã¤ÂºÂ¤Ã¦Â¸â€°Ã£ï¿½â€”ã�¦ãƒ‡ãƒ¼ã‚¿ã�Å
295’�る��
296 if ((time < 0.15 || time >= 0.85) && mySessionData != null) {
297 // 相手ã�Å
298’都å�ˆã�®ã�„ã�„ビットをæ��案ã�—ã�Å
299¸Ã¥Â Â´Ã¥ï¿½Ë†
300 // 0.85以ä¸Å
301 Ã¥ï¿½â€“ã‚Å
302’る�ら
303 if (mySessionData.isAgree
304 && getUtility(mySessionData.lastBid) > 0.85) {
305 if (mySessionData.isAgree && round < 100) {
306 return new Offer(getAgentID(), mySessionData.lastBid);
307 }
308 }
309 }
310
311 switch (mode) {
312 case 0:
313 try {
314 return mode0(time);
315 } catch (Exception e) {
316 e.printStackTrace();
317 }
318 case 1:
319 return mode1(time);
320 case 2:
321 try {
322 return mode2(time);
323 } catch (Exception e) {
324 e.printStackTrace();
325 }
326 case 3:
327 return mode3(time);
328 default:
329 return mode(time);
330 }
331 }
332
333 // å¼·æ°—
334 private double acceptBorder(double time) {
335 return 0.85;
336 }
337
338 // 妥�を�����モード
339 private Action mode0(double time) throws Exception {
340 if (time < 0.05) {
341 return getBid0();
342 } else if (time < 0.1) {
343 return getBidA();
344 } else if (time < 0.5) {
345 return getBid0();
346 } else if (time < 0.98) {
347 return getBidA();
348 } else {
349 return getBidC();
350 }
351 // if(time< 0.99){
352 // return getBidC();
353 // } else {
354 // //
355 // ã�µã�–ã�‘ã�Å
356¸Ã£Æ’“ッド
357 // return getBidD();
358 // }
359 }
360
361 // æÅ
362 ËœÃ£â€šÅ
363’るモード
364 private Action mode1(double time) {
365 if (time < 0.95) {
366 return getBid0();
367 } else {
368 return new Offer(getAgentID(), myBestBidByOpponent);
369 }
370 }
371
372 // è¿‘å‚�æÅ
373½Â¢Ã§Â´Â¢
374 private Action mode2(double time) throws Exception {
375 if (time < 0.05) {
376 return getBid0();
377 } else {
378 return getBidB();
379 }
380 }
381
382 // 強調�るモード
383 private Action mode3(double time) {
384 if (getUtility(myBestBidByOpponent) > getUtility(
385 mySessionData.lastBid)) {
386 return new Offer(getAgentID(), myBestBidByOpponent);
387 } else {
388 return new Offer(getAgentID(), mySessionData.lastBid);
389 }
390 }
391
392 // 一切妥����
393 private Action mode(double time) {
394 if (time < 0.99) {
395 return getBidA();
396 } else {
397 return getBidC();
398 }
399 }
400
401 private void beforeOffer(Bid bid) {
402 // System.out.println("offer : " + getUtility(bid));
403 }
404
405 // å¼±SA(制é™�ã�Å
406’緩�)
407 private Action getBid0() {
408 Bid bid = utilitySpace.getDomain().getRandomBid(null);
409 if (getUtility(bid) > 0.80) {
410 // ã�Å
411¸Ã£ï¿½Â¾Ã£ï¿½Â«Ã£ï¿½â€ Ã£ï¿½Â¾Ã£ï¿½ï¿½Ã£ï¿½â€žÃ£ï¿½ï¿½
412 beforeOffer(bid);
413 return new Offer(getAgentID(), bid);
414 } else {
415 return getBidA();
416 }
417 }
418
419 // å¼·SA(æ™®é€Å
420¡Ã£ï¿½Â®SA
421 // 自分ã�«ã�¨ã�£ã�¦é«˜ã�„ã‚‚ã�®ã‚’é�¸æÅ
422 Å
423¾)
424 private Action getBidA() {
425 double t0 = 10000;
426 double t1 = 0.001;
427 Bid baseBid;
428 if (myBestBid == null || rand.nextInt(10) != 0) {
429 baseBid = utilitySpace.getDomain().getRandomBid(null);
430 Bid bid = getSA(baseBid, t0, t1);
431 beforeOffer(bid);
432 return new Offer(getAgentID(), bid);
433 } else {
434 return new Offer(getAgentID(), myBestBid);
435 }
436 // ランダムBidを元�SA
437 }
438
439 // bidã‚’SAã�«ã‚ˆã‚Å
440 Ã¦â€�¹å–„ã�™ã‚‹
441 private Bid getSA(Bid bid, double t0, double t1) {
442 int step = 1;
443 double def = 0.99;
444 int issueSize = bid.getIssues().size();
445 double bid_util;
446
447 try {
448 do {
449 double current_util = utilitySpace.getUtility(bid); // ç�¾åÅ
450“¨ã�®bid�util
451 Bid newBid = new Bid(bid); // 変更ã�•ã‚Å
452’ã‚‹ç�¾åÅ
453“¨ã�®bid
454 int selectedIssueId = rand.nextInt(issueSize); // issueã�®é�¸æÅ
455 Å
456¾
457 IssueInteger issueInteger = (IssueInteger) bid.getIssues()
458 .get(selectedIssueId); //  é�¸æÅ
459 Å
460¾Ã£ï¿½â€¢Ã£â€šÅ
461’ã�Å
462¸issue
463 int issueId = issueInteger.getNumber(); // é�¸æÅ
464 Å
465¾Ã£ï¿½â€”ã�Å
466¸issue�index
467 ValueInteger issueValue = (ValueInteger) bid.getValue(issueId); // issue�index�部分�値
468 int issueValueInt = Integer.valueOf(issueValue.toString())
469 .intValue(); // intÃ¥Å
470¾â€¹Ã£ï¿½Â¸
471 int max = issueInteger.getUpperBound(); // é�¸æÅ
472 Å
473¾Ã£ï¿½â€¢Ã£â€šÅ
474’ã�Å
475¸issueã�®ãƒ‰ãƒ¡ã‚¤ãƒ³ã�®æÅ
476“€å¤§å€¤
477 int min = issueInteger.getLowerBound(); // é�¸æÅ
478 Å
479¾Ã£ï¿½â€¢Ã£â€šÅ
480’ã�Å
481¸issueã�®ãƒ‰ãƒ¡ã‚¤ãƒ³ã�®æÅ
482“€å°�値
483
484 int flag = rand.nextBoolean() ? 1 : -1;
485
486 if (issueValueInt >= min && issueValueInt <= max) {
487 if (issueValueInt + step > max) {
488 flag = -1;
489 } else if (issueValueInt - step < min) {
490 flag = 1;
491 }
492 }
493
494 Value valueInteger = new ValueInteger(
495 issueValueInt + flag * step);
496 newBid = newBid.putValue(issueId, valueInteger);
497
498 double newBid_util;
499 newBid_util = utilitySpace.getUtility(newBid);
500 double bf_cost = 1.0 - current_util;
501 double af_cost = 1.0 - newBid_util;
502
503 double p = Math.pow(Math.E, -Math.abs(af_cost - bf_cost) / t0);
504
505 if (af_cost < bf_cost || rand.nextDouble() < p) {
506 bid = new Bid(newBid); // bidã‚’æ›´æ–°
507 }
508 t0 *= def;
509 bid_util = newBid_util;
510 } while (t0 > t1);
511
512 // myBestBidã�®è¨­å®Å
513¡
514 // myBestBidã�Å
515’����
516 if (myBestBid == null) {
517 myBestBid = new Bid(bid);
518 } else {
519 renewBids(bid);
520 }
521
522 if (bid_util <= 0.9 && myBestBid != null) {
523 bid = new Bid(myBestBid); // 0.9以ä¸Å
524 Ã£ï¿½Â®Ã¥â‚¬Â¤Ã£ï¿½Å
525’å�–ã‚Å
526’ã�ªã�‹ã�£ã�Å
527¸Ã£ï¿½Â¨Ã£ï¿½ï¿½
528 }
529
530 } catch (Exception e) {
531 e.printStackTrace();
532 }
533 return bid;
534 }
535
536 // è¿‘å‚�æÅ
537½Â¢Ã§Â´Â¢(相手�出方)�よるBid��得
538 private Action getBidB() throws Exception {
539 try {
540 if (myBestBidByOpponent == null) {
541 return getBidA();
542 } else {
543 Bid bid = new Bid(myBestBidByOpponent);
544 System.out.println("before : " + getUtility(bid));
545 Bid newBid = new Bid(nearSearch(bid));
546 System.out.println("after :" + getUtility(newBid));
547 if (bestBid == null
548 || getUtility(newBid) > getUtility(bestBid)) {
549 bestBid = new Bid(newBid);
550 }
551 // newBidã�Å
552’0.8以下ã�ªã‚‰æÅ
553½Â¡Ã§â€�¨ã�—ã�ªã�„
554 if (getUtility(newBid) < 0.8) {
555 return getBidA();
556 } else {
557 return new Offer(getAgentID(), newBid);
558 }
559 }
560 } catch (Exception e) {
561 e.printStackTrace();
562 }
563 return getBidA();
564 }
565
566 // baseBidã�®è¿‘å‚�ã‚’æÅ
567½Â¢Ã§Â´Â¢Ã£ï¿½â„¢Ã£â€šâ€¹
568 private Bid nearSearch(Bid baseBid) throws Exception {
569
570 List<Issue> issues = utilitySpace.getDomain().getIssues(); // 全issue��得
571 Bid nextBid = new Bid(baseBid); // ç�¾åÅ
572“¨ã�®Bidをコãƒâ€�ー
573 int numberIndexes = utilitySpace.getDomain().getIssues().size(); // イシュー�数
574 for (int i = 0; i < numberIndexes; i++) {
575 int index = rand.nextInt(issues.size());
576 IssueInteger lIssueInteger = (IssueInteger) issues.get(index); // æÅ
577’‡å®Å
578¡Ã£ï¿½â€”ã�Å
579¸index�issueを�得
580 int issueNumber = lIssueInteger.getNumber(); // issue�index
581 // 0
582 // ã€Å
583“
584 // 9
585
586 int optionIndex = 0; // 変更�るValue値
587
588 optionIndex = selectIndex(lIssueInteger, baseBid);
589
590 nextBid = nextBid.putValue(issueNumber,
591 new ValueInteger(optionIndex)); // ç�¾åÅ
592“¨ã�®Bid�らIssueã�®å€¤ã‚’å…¥ã‚Å
593’替�る
594 }
595 return nextBid;
596 }
597
598 private int selectIndex(IssueInteger issue, Bid baseBid) {
599 int issueNumber = issue.getNumber();
600 int issueIndexMin = issue.getLowerBound(); // issue�下�値
601 int issueIndexMax = issue.getUpperBound(); // issueã�®ä¸Å
602 Ã©â„¢ï¿½Ã¥â‚¬Â¤
603 int candidate = issueIndexMin;
604 Bid sBid = new Bid(baseBid);
605 for (int i = issueIndexMin; i < issueIndexMax; i++) {
606 Bid tempBid = new Bid(baseBid);
607 tempBid = tempBid.putValue(issueNumber, new ValueInteger(i));
608 if (getUtility(sBid) <= getUtility(tempBid)) {
609 candidate = i;
610 }
611 sBid = sBid.putValue(issueNumber, new ValueInteger(candidate));
612 }
613 return candidate;
614 }
615
616 // å‰�å›Å
617¾Ã¥ï¿½Ë†Ã¦â€žï¿½Ã£ï¿½â€”ã�Å
618¸Ã£Æ’“ッドをæ��案
619 private Action getBidC() {
620 if (mySessionData != null) {
621 renewBids(mySessionData.lastBid);
622 return new Offer(getAgentID(), mySessionData.lastBid);
623 } else {
624 return getBidA();
625 }
626 }
627
628 // æ„�図çÅ
629¡â€žÃ£ï¿½Â«Ã£ï¿½Å
630¡Ã£â€šâ€°Ã£ï¿½â€”ã�Å
631¸Ã£Æ’“ッドをè¿â€��
632 private Action getBidD() throws Exception {
633 Bid baseBid = utilitySpace.getDomain().getRandomBid(null);
634 System.out.println("noisy!!");
635 do {
636 baseBid = nearSearchWithNoise(baseBid);
637 } while (getUtility(baseBid) > 0.55);
638 return new Offer(getAgentID(), nearSearchWithNoise(baseBid));
639 }
640
641 private Bid nearSearchWithNoise(Bid baseBid) throws Exception {
642
643 List<Issue> issues = utilitySpace.getDomain().getIssues(); // 全issue��得
644 Bid nextBid = new Bid(baseBid); // ç�¾åÅ
645“¨ã�®Bidをコãƒâ€�ー
646 int numberIndexes = utilitySpace.getDomain().getIssues().size(); // イシュー�数
647 for (int i = 0; i < numberIndexes; i++) {
648 int index = rand.nextInt(issues.size());
649 IssueInteger lIssueInteger = (IssueInteger) issues.get(index); // æÅ
650’‡å®Å
651¡Ã£ï¿½â€”ã�Å
652¸index�issueを�得
653 int issueNumber = lIssueInteger.getNumber(); // issue�index
654 // 0
655 // ã€Å
656“
657 // 9
658
659 int optionIndex = 0; // 変更�るValue値
660
661 optionIndex = selectIndexWithNoise(lIssueInteger, baseBid);
662
663 nextBid = nextBid.putValue(issueNumber,
664 new ValueInteger(optionIndex)); // ç�¾åÅ
665“¨ã�®Bid�らIssueã�®å€¤ã‚’å…¥ã‚Å
666’替�る
667 }
668 return nextBid;
669 }
670
671 private int selectIndexWithNoise(IssueInteger issue, Bid baseBid) {
672 int issueNumber = issue.getNumber();
673 int issueIndexMin = issue.getLowerBound(); // issue�下�値
674 int issueIndexMax = issue.getUpperBound(); // issueã�®ä¸Å
675 Ã©â„¢ï¿½Ã¥â‚¬Â¤
676 int candidate = issueIndexMin;
677 Bid sBid = new Bid(baseBid);
678 for (int i = issueIndexMin; i < issueIndexMax; i++) {
679 Bid tempBid = new Bid(baseBid);
680 tempBid = tempBid.putValue(issueNumber, new ValueInteger(i));
681 // å¤Å
682¡Ã¥Â°â€˜Ã¨â€¡ÂªÃ¥Ë†â€ Ã£ï¿½Â«Ã£ï¿½Â¨Ã£ï¿½Â£Ã£ï¿½Â¦Ã¦Å
683“‰åˆ©ã�«ã�™ã‚‹
684 if (getUtility(sBid) <= getUtility(tempBid)
685 && rand.nextInt(10) == 0) {
686 candidate = i;
687 }
688 sBid = sBid.putValue(issueNumber, new ValueInteger(candidate));
689 }
690 return candidate;
691 }
692
693 private void renewBids(Bid bid) {
694 if (myBestBid == null) {
695 myBestBid = new Bid(bid);
696 } else if (getUtility(myBestBid) < getUtility(bid)) {
697 // System.out.printf("modified %f to %f\n",
698 // getUtility(myBestBid), getUtility(bid));
699 myBestBid = new Bid(bid);
700 }
701 }
702
703 @Override
704 public String getDescription() {
705 return "ANAC2014 compatible with non-linear utility spaces";
706 }
707}
708
709class TRPSessionData implements Serializable {
710 Bid lastBid; // ç›´å‰�ã�®å�ˆæ„�ã�—ã�Å
711¸Ã£Æ’“ット
712 double lastTime; // 直��時間
713 boolean isAgree; // ̴威
714¸Ã©Å
715¡â€ºÃ¥ï¿½Ë†Ã¦â€žï¿½Ã£ï¿½â€”ã�Å
716¸Ã£ï¿½â€¹
717 static int breakCount = 0; // 決裂å›Å
718¾Ã¦â€¢Â°
719 Bid myBestBid; // æÅ
720“€ã‚‚åÅ
721 Â¹Ã§â€�¨ã�®é«˜ã�„ビット
722 Bid opponentBestBid; // 相手ã�Å
723’æ��案ã�—ã�Å
724¸Ã¤Â¸â‚¬Ã§â€¢ÂªÃ¨â€°Â¯Ã£ï¿½â€žÃ£Æ’“ット
725 int round;
726
727 public TRPSessionData(Bid lastBid, double lastTime, boolean isAgree,
728 Bid myBestBid, Bid myBestBidByOpponent, int round, boolean reset) {
729 this.lastBid = lastBid;
730 this.lastTime = lastTime;
731 this.isAgree = isAgree;
732
733 if (reset) {
734 this.breakCount = 0;
735 }
736 if (!isAgree) {
737 this.breakCount++;
738 }
739 this.myBestBid = myBestBid;
740 this.opponentBestBid = myBestBidByOpponent;
741 this.round = round;
742 }
743
744 public void printAll() {
745 // System.out.println("----------------------------------");
746 // System.out.println("lastBid :" + lastBid);
747 // System.out.println("time :" + lastTime);
748 // System.out.println("isAgree :" + isAgree);
749 // System.out.println("breakCo :" + breakCount);
750 // System.out.println("round :" + round);
751 }
752
753}
Note: See TracBrowser for help on using the repository browser.