source: src/main/java/agents/anac/y2016/myagent/etc/negotiationStrategy.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: 3.4 KB
Line 
1package agents.anac.y2016.myagent.etc;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.utility.UtilitySpace;
7
8public class negotiationStrategy {
9 private UtilitySpace utilitySpace;
10 private negotiationInfo negotiationInfo;
11 private double df = -1.0; // 割引率
12 private double rv = 0.0; // 留保価格
13
14 private boolean isPrinting = false; // デバッグ用
15
16 public negotiationStrategy(UtilitySpace utilitySpace,
17 negotiationInfo negotiationInfo, boolean isPrinting) {
18 this.utilitySpace = utilitySpace;
19 this.negotiationInfo = negotiationInfo;
20 this.isPrinting = isPrinting;
21 rv = utilitySpace.getReservationValue();
22 }
23
24 // 受容判定
25 public boolean selectAccept(Bid offeredBid, double time) {
26
27 // 割引率を求める(discountFactorが使えないため)
28 if (df == -1.0) {
29 double util = utilitySpace.getUtility(offeredBid);
30 double discounted = utilitySpace.discount(util, time);
31 df = Math.pow(discounted / util, 1 / time);
32 // System.out.println("util:" + util + "\tdiscounted:" + discounted
33 // + "\tdf:" + df);
34 }
35
36 try {
37 if (utilitySpace.getUtility(offeredBid) >= getThreshold(time)) {
38 return true;
39 } else {
40 return false;
41 }
42 } catch (Exception e) {
43 System.out.println("受容判定に失敗しました");
44 e.printStackTrace();
45 return false;
46 }
47 }
48
49 // 交渉終了判定
50 public boolean selectEndNegotiation(double time) {
51 if (getThreshold(time) < rv) {
52 return true;
53 }
54 return false;
55 }
56
57 // 閾値を返す
58 public double getThreshold(double time) {
59
60 /* 交渉戦略に基づきthreshold(t)を設計する */
61 /* negotiationInfoから提案履歴の統計情報を取得できるので使っても良い */
62 /* (統計情報についてはあまりデバッグできていないので,バグが見つかった場合は報告をお願いします) */
63
64 double threshold = 0.95;
65 double e = 0.01;
66
67 threshold = 1.0 - Math.pow(time, 1 / e);
68
69 ArrayList<Object> arrogants = negotiationInfo.getArrogants();
70
71 if (arrogants.size() == 1) {
72 Object arrogant = arrogants.get(0);
73
74 double slant = negotiationInfo.getSlant(arrogant);
75 // System.out.println("---------------\nSlant: " + slant);
76
77 double rushValue = threshold * df * slant; // 強気*強気(0.5は勝利確率)
78 double concedeValue = negotiationInfo.getAverage(arrogant)
79 * Math.pow(df, time); // 弱気*強気
80 // System.out.println("rushValue:" + rushValue);
81 // System.out.println("concedeValue:" + concedeValue);
82
83 if (concedeValue > rushValue) {
84 if (negotiationInfo.getOpponentBidNum(arrogant) < 70) {
85 e = 0.5;
86 } else if (slant < 0.15) {
87 if (df == 1.0) {
88 e = 0.3;
89 } else {
90 e = 1.65;
91 }
92 } else {
93 e = 0.1;
94 }
95 }
96 }
97
98 threshold = 1.0 - Math.pow(time, 1 / e);
99
100 // 例:
101 ArrayList<Object> opponents = negotiationInfo.getOpponents();
102
103 for (Object sender : opponents) {
104 // System.out.println("sender:" + sender);
105 // System.out.println("time:" + time);
106 // double m = negotiationInfo.getAverage(sender);
107 // double v = negotiationInfo.getVariancer(sender);
108 // double sd = negotiationInfo.getStandardDeviation(sender);
109 // System.out.println("ave:" + m + "\nvar:" + v + "\nsta:" + sd);
110 // System.out.println("AcceptedNum:" +
111 // negotiationInfo.getAcceptedNum(sender));
112 // System.out.println("ArrogantsNum:" + arrogants.size());
113 }
114
115 return threshold;
116 }
117
118}
Note: See TracBrowser for help on using the repository browser.