source: src/main/java/agents/anac/y2015/Atlas3/etc/strategy.java@ 1

Last change on this file since 1 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.y2015.Atlas3.etc;
2
3import agents.anac.y2015.Atlas3.Atlas3;
4import genius.core.Bid;
5import genius.core.utility.AdditiveUtilitySpace;
6
7public class strategy {
8 private AdditiveUtilitySpace utilitySpace;
9 private negotiatingInfo negotiatingInfo;
10
11 private double df = 0.0; // 割引係数
12 private double rv = 0.0; // 留保価格
13
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 public strategy(AdditiveUtilitySpace utilitySpace, negotiatingInfo negotiatingInfo) {
23 this.utilitySpace = utilitySpace;
24 this.negotiatingInfo = negotiatingInfo;
25 df = utilitySpace.getDiscountFactor();
26 rv = utilitySpace.getReservationValue();
27 }
28
29 // 受容判定
30 public boolean selectAccept(Bid offeredBid, double time) {
31 try {
32 double offeredBidUtil = utilitySpace.getUtility(offeredBid);
33 if(offeredBidUtil >= getThreshold(time)){ return true; }
34 else{ return false; }
35 } catch (Exception e) {
36 System.out.println("受容判定に失敗しました");
37 e.printStackTrace();
38 return false;
39 }
40 }
41
42 // 交渉終了判定
43 public boolean selectEndNegotiation(double time) {
44 // 閾値が留保価格を下回るとき交渉を放棄
45 if (rv * Math.pow(df, time) >= getThreshold(time)) { return true; }
46 else { return false; }
47 }
48
49 // 閾値を返す
50 public double getThreshold(double time) {
51 double threshold = 1.0;
52 updateGameMatrix(); // ゲームの表を更新する
53 double target = getExpectedUtilityinFOP() / Math.pow(df, time); // 最終提案フェーズの期待効用(割引効用によって減少する効用値を考慮して上方補正する)
54 // 最終提案フェーズの期待効用に基づき,譲歩を行う
55 if(df == 1.0){ threshold = target + (1.0 - target) * (1.0 - time); }
56 else { threshold = Math.max(1.0 - time / df, target); }
57
58 // デバッグ用
59 if(Atlas3.isPrinting){ System.out.println("threshold = " + threshold + ", opponents:"+negotiatingInfo.getOpponents()); }
60
61 return threshold;
62 }
63
64 // 最終提案フェイズの混合戦略の期待効用
65 private double getExpectedUtilityinFOP(){
66 double q = getOpponentEES();
67 return q*A21+(1-q)*A22;
68 }
69
70 // 最終提案ゲームにおける最適混合戦略の均衡点での,相手の混合戦略(p,1.0-p)=(強硬戦略を選択する確率,妥協戦略を選択する確率)を導出する
71 private double getOpponentEES(){
72 double q = 1.0;
73 if((A12 - A22 != 0) && (1.0-(A11-A21)/(A12-A22) != 0)){ q = 1.0 / (1.0 - (A11-A21)/(A12-A22)); }
74 if(q < 0.0 || q > 1.0){ q=1.0; }
75 return q;
76 }
77
78 // ゲームの表を更新する
79 private void updateGameMatrix(){
80 double C; // 妥協案の推定効用値
81 if(negotiatingInfo.getNegotiatorNum() == 2){ C = negotiatingInfo.getBOU(); }
82 else { C = negotiatingInfo.getMPBU(); }
83
84 A11 = rv * df;
85 A12 = Math.pow(df, TF);
86 if(C >= rv) { A21 = C * Math.pow(df,TF); }
87 else { A21 = rv * df; }
88 A22 = PF * A21 + (1.0-PF) * A12;
89 }
90}
Note: See TracBrowser for help on using the repository browser.