1 | package agents.anac.y2017.agentkn.etc;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.Iterator;
|
---|
5 |
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.utility.AbstractUtilitySpace;
|
---|
8 |
|
---|
9 | public class negotiationStrategy {
|
---|
10 | private AbstractUtilitySpace utilitySpace;
|
---|
11 | private negotiationInfo negotiationInfo;
|
---|
12 | private double rv = 0.0; // 留保価格
|
---|
13 |
|
---|
14 | private boolean isPrinting = false; // デバッグ用
|
---|
15 |
|
---|
16 | public negotiationStrategy(AbstractUtilitySpace utilitySpace, negotiationInfo negotiationInfo, boolean isPrinting) {
|
---|
17 | this.utilitySpace = utilitySpace;
|
---|
18 | this.negotiationInfo = negotiationInfo;
|
---|
19 | this.isPrinting = isPrinting;
|
---|
20 | rv = utilitySpace.getReservationValue();
|
---|
21 | }
|
---|
22 |
|
---|
23 | // 受容判定
|
---|
24 | public boolean selectAccept(Bid offeredBid, double time) {
|
---|
25 | try {
|
---|
26 | if (utilitySpace.getUtility(offeredBid) >= getThreshold(time)) {
|
---|
27 | return true;
|
---|
28 | } else {
|
---|
29 | return false;
|
---|
30 | }
|
---|
31 | } catch (Exception e) {
|
---|
32 | System.out.println("受容判定に失敗しました");
|
---|
33 | e.printStackTrace();
|
---|
34 | return false;
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | // 交渉終了判定
|
---|
39 | public boolean selectEndNegotiation(double time) {
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 |
|
---|
43 | // 閾値を返す
|
---|
44 | public double getThreshold(double time) {
|
---|
45 | System.out.println("time : " + time);
|
---|
46 | double threshold = 1.0D;
|
---|
47 | double mi = 0.0D;
|
---|
48 | double ave = 0.0D;
|
---|
49 | double extra = 0.0D;
|
---|
50 | ArrayList opponents = negotiationInfo.getOpponents();
|
---|
51 |
|
---|
52 | double sd;
|
---|
53 | for (Iterator i = opponents.iterator(); i.hasNext(); extra = sd) {
|
---|
54 | Object sender = i.next();
|
---|
55 | if (negotiationInfo.getPartnerBidNum(sender) % 10 == 0) {
|
---|
56 | ave = 0.0D;
|
---|
57 | extra = 0.0D;
|
---|
58 | }
|
---|
59 |
|
---|
60 | double m = negotiationInfo.getAverage(sender);
|
---|
61 | sd = negotiationInfo.getStandardDeviation(sender);
|
---|
62 | ave = m;
|
---|
63 | }
|
---|
64 |
|
---|
65 | double c = 1.0D - Math.pow(time, 5D);
|
---|
66 | double emax = emax();
|
---|
67 | threshold = 1 - (1 - emax) * Math.pow(time, 5D);
|
---|
68 |
|
---|
69 | return threshold;
|
---|
70 | }
|
---|
71 |
|
---|
72 | private double emax() {
|
---|
73 | double ave = 0.0D;
|
---|
74 | double extra = 0.0D;
|
---|
75 | ArrayList opponents = negotiationInfo.getOpponents();
|
---|
76 |
|
---|
77 | double sd = 0.0D;
|
---|
78 | for (Iterator i = opponents.iterator(); i.hasNext(); extra = sd) {
|
---|
79 | Object sender = i.next();
|
---|
80 | if (negotiationInfo.getPartnerBidNum(sender) % 10 == 0) {
|
---|
81 | ave = 0.0D;
|
---|
82 | extra = 0.0D;
|
---|
83 | }
|
---|
84 |
|
---|
85 | double m = negotiationInfo.getAverage(sender);
|
---|
86 | sd = negotiationInfo.getStandardDeviation(sender);
|
---|
87 | ave = m;
|
---|
88 | }
|
---|
89 |
|
---|
90 | double d = Math.sqrt(3) * sd / Math.sqrt(ave * (1 - ave));
|
---|
91 |
|
---|
92 | return 0.7D * ave + (1 - ave) * d * 0.7D;
|
---|
93 | }
|
---|
94 | }
|
---|