source: src/main/java/agents/anac/y2018/seto/etc/NegoStrategy.java@ 346

Last change on this file since 346 was 343, checked in by Tim Baarslag, 4 years ago

Fixed all errors in all 2018 agents

File size: 4.1 KB
Line 
1package agents.anac.y2018.seto.etc;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.parties.NegotiationInfo;
7
8
9public class NegoStrategy {
10 private NegotiationInfo info;
11 private boolean isPrinting = false; // デバッグ用
12 private boolean isPrinting_Strategy = false;
13
14 private NegoStats negoStats; // 交渉情報
15 private NegoHistory negoHistory;
16 private double rv = 0.0; // 留保価格
17 private double df = 0.0; // 割引効用
18
19 public double alpha = 3.0; // 自分の戦略の強さ
20
21
22 public NegoStrategy(NegotiationInfo info, boolean isPrinting, NegoStats negoStats, NegoHistory negoHistory){
23 this.info = info;
24 this.isPrinting = isPrinting;
25
26 this.negoStats = negoStats;
27 this.negoHistory = negoHistory;
28 rv = info.getUtilitySpace().getReservationValueUndiscounted();
29 df = info.getUtilitySpace().getDiscountFactor();
30
31 if(this.isPrinting){
32 System.out.println("[isPrinting] NegoStrategy: success");
33 }
34 if(isPrinting_Strategy){
35 System.out.println("[isPrint_Strategy] rv = " + rv);
36 System.out.println("[isPrint_Strategy] df = " + df);
37 }
38 }
39
40 // 受容判定
41 public boolean selectAccept(Bid offeredBid, double time) {
42 try {
43 if(info.getUtilitySpace().getUtility(offeredBid) >= getThreshold(time)){
44 return true;
45 } else {
46 return false;
47 }
48 } catch (Exception e) {
49 System.out.println("[Exception_Strategy] 受容判定に失敗しました");
50 e.printStackTrace();
51 return false;
52 }
53 }
54
55 // 交渉終了判定
56 public boolean selectEndNegotiation(double time) {
57 // 割引効用が設定されているかどうか (ANAC 2017では設定されない方針)
58 if(1.0 - df < 1e-7){
59 return false;
60 } else {
61 if (rv > getThreshold(time)){
62 return true;
63 } else {
64 return false;
65 }
66 }
67
68 }
69
70 /**
71 * 統計情報を元に相手の変位幅を推定 (二分割一様分布を利用)
72 * @param m 平均効用値
73 * @param sd 標準偏差
74 * @return
75 */
76 public double calWidth(double m, double sd){
77 if(m > 0.1 && m < 0.9){
78 return Math.sqrt(3.0 / (m - m*m)) * sd;
79 } else {
80 return Math.sqrt(12) * sd;
81 }
82 }
83
84 // 閾値を返す
85 public double getThreshold(double time) {
86 double threshold = 1.0;
87
88 // 交渉相手全員に対してemaxを計算し,最小となるものを探す
89 ArrayList<Object> rivals = negoStats.getRivals();
90 double emax = 1.0;
91 for(Object sender: rivals){
92 double m = negoStats.getRivalMean(sender);
93 double sd = negoStats.getRivalSD(sender);
94
95 // emax = Math.min(emax, m + (1 - m)*calWidth(m, sd));
96 // negoStats.getRivalMax(sender) より今sessionにおける最大効用値を採用
97 emax = Math.min(emax, Math.max(negoStats.getRivalMax(sender), m + (1 - m)*calWidth(m, sd)));
98 emax = Math.max(emax, rv); // 留保価格より小さい場合は,rvを採用する.
99 }
100
101 // 割引効用が設定されているかどうか (ANAC 2017では設定されない方針)
102 if(1.0 - df < 1e-7){
103 threshold = Math.min(threshold, 1 - (1 - emax) * Math.pow(time, alpha));
104 } else {
105 threshold = Math.max(threshold - time, emax);
106 }
107
108 // 交渉決裂寸前では、過去の提案で最大のものまで譲歩する
109 if(time > 0.99){
110 for(Object sender: rivals) {
111 threshold = Math.min(threshold, negoStats.getRivalMax(sender));
112 }
113 threshold = Math.max(threshold, rv);
114 }
115
116 if(isPrinting_Strategy){
117 System.out.println("[isPrint_Strategy] threshold = " + threshold
118 + " | time: " + time
119 + ", emax: " + emax);
120 }
121
122 return threshold;
123 }
124}
Note: See TracBrowser for help on using the repository browser.