source: src/main/java/agents/anac/y2017/agentf/etc/negotiationStrategy.java

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

Initial import : Genius 9.0.0

File size: 3.9 KB
Line 
1package agents.anac.y2017.agentf.etc;
2
3import genius.core.Bid;
4import genius.core.utility.AbstractUtilitySpace;
5
6public class negotiationStrategy {
7 private AbstractUtilitySpace utilitySpace;
8 private negotiationInfo negotiationInfo;
9
10 private double df = 1.0; // 割引係数
11 private double rv = 0.0; // 留保価格
12
13 // Aが自分,Bが相手 各種計算などはパワーポイントの説明を参照
14 private double A11 = 0.0; // 効用値・・・A:強硬戦略,B:強硬戦略
15 private double A12 = 0.0; // 効用値・・・A:強硬戦略,B:妥協戦略
16 private double A21 = 0.0; // 効用値・・・A:妥協戦略,B:強硬戦略
17 private double A22 = 0.0; // 効用値・・・A:妥協戦略,B:妥協戦略
18
19 static private double TF = 1.0; // 最終提案フェーズの時刻
20 static private double PF = 0.5; // 最終提案フェーズにおいて互いが妥協戦略を選択した場合に,自身が相手よりも先に譲歩する確率
21
22 private boolean isPrinting = false;
23
24 public negotiationStrategy(AbstractUtilitySpace utilitySpace, negotiationInfo negotiationInfo, boolean isPrinting) {
25 this.utilitySpace = utilitySpace;
26 this.negotiationInfo = negotiationInfo;
27 this.isPrinting = isPrinting;
28 df = utilitySpace.getDiscountFactor();
29 rv = utilitySpace.getReservationValue();
30
31 if (this.isPrinting) {
32 System.out.println("negotiationStrategy:success");
33 }
34 }
35
36 public void setRV(double newRV) {
37 rv = newRV;
38 }
39
40 // 受容判定
41 public boolean selectAccept(Bid offeredBid, double time) {
42 try {
43 double offeredBidUtil = utilitySpace.getUtility(offeredBid);
44 if (offeredBidUtil >= getThreshold(time)) {
45 return true;
46 } else {
47 return false;
48 }
49 } catch (Exception e) {
50 System.out.println("受容判定に失敗しました");
51 e.printStackTrace();
52 return false;
53 }
54 }
55
56 // 交渉終了判定
57 public boolean selectEndNegotiation(double time) {
58 // 閾値が留保価格を下回るとき交渉を放棄
59 if (utilitySpace.discount(rv, time) >= getThreshold(time)) {
60 return true;
61 } else {
62 return false;
63 }
64 }
65
66 // 割引後の効用値から割引前の効用値を導出する
67 public double pureUtility(double discounted_util, double time) {
68 return discounted_util / Math.pow(df, time);
69 }
70
71 // 閾値を返す
72 public double getThreshold(double time) {
73 double threshold = 1.0;
74 updateGameMatrix(); // ゲームの表を更新する
75
76 double target = pureUtility(getExpectedUtilityinFOP(), time);
77
78 // 最終提案フェーズの期待効用に基づき,譲歩を行う
79 if (utilitySpace.discount(1.0, time) == 1.0) {
80 threshold = target + (1.0 - target) * (1.0 - time);
81 } else {
82 threshold = Math.max(1.0 - time / utilitySpace.discount(1.0, time), target);
83 }
84
85 // デバッグ用
86 if (isPrinting) {
87 System.out.println("threshold = " + threshold + ", opponents:" + negotiationInfo.getOpponents());
88 }
89
90 return threshold;
91 }
92
93 // 最終提案フェイズの混合戦略の期待効用
94 private double getExpectedUtilityinFOP() {
95 double q = getOpponentEES();
96 return q * A21 + (1 - q) * A22;
97 }
98
99 // 最終提案ゲームにおける最適混合戦略の均衡点での,相手の混合戦略(p,1.0-p)=(強硬戦略を選択する確率,妥協戦略を選択する確率)を導出する
100 private double getOpponentEES() {
101 double q = 1.0;
102 if ((A12 - A22 != 0) && (1.0 - (A11 - A21) / (A12 - A22) != 0)) {
103 q = 1.0 / (1.0 - (A11 - A21) / (A12 - A22));
104 }
105 if (q < 0.0 || q > 1.0) {
106 q = 1.0;
107 }
108 return q;
109 }
110
111 // ゲームの表を更新する
112 private void updateGameMatrix() {
113 double C; // 妥協案の推定効用値
114 if (negotiationInfo.getNegotiatorNum() == 2) {
115 C = negotiationInfo.getBOU();
116 } else {
117 C = negotiationInfo.getMPBU();
118 }
119
120 A11 = utilitySpace.discount(rv, 1.0);
121 A12 = utilitySpace.discount(1.0, TF);
122 if (C >= rv) {
123 A21 = utilitySpace.discount(C, TF);
124 } else {
125 A21 = utilitySpace.discount(rv, 1.0);
126 }
127 A22 = PF * A21 + (1.0 - PF) * A12;
128 }
129}
Note: See TracBrowser for help on using the repository browser.