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