source: src/main/java/agents/anac/y2016/agentsmith/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: 2.4 KB
Line 
1package agents.anac.y2016.agentsmith;
2
3import java.util.ArrayList;
4
5import genius.core.Bid;
6import genius.core.utility.AbstractUtilitySpace;
7
8public class negotiationStrategy {
9 private AbstractUtilitySpace utilitySpace;
10 private negotiationInfo negotiationInfo;
11 public double rv = 0.0; // 留保価格
12 public double df = 0.0;
13
14 private boolean isPrinting = false; // デバッグ用
15
16 public negotiationStrategy(AbstractUtilitySpace utilitySpace,
17 negotiationInfo negotiationInfo, boolean isPrinting) {
18 this.utilitySpace = utilitySpace;
19 this.negotiationInfo = negotiationInfo;
20 this.isPrinting = isPrinting;
21 rv = utilitySpace.getReservationValue();
22 df = utilitySpace.getDiscountFactor();
23 }
24
25 // u:utility
26 // t:time
27 // int i =0;
28
29 // 受容判定
30 public boolean selectAccept(Bid offeredBid, double time) {
31 try {
32 // System.out.println("time:" +time);
33 //
34 // System.out.println("dislity "+i +":" +discountedUtility );
35 // i++;
36 if (utilitySpace.getUtility(offeredBid) >= getThreshold(time)) {
37 return true;
38 } else {
39 return false;
40 }
41 } catch (Exception e) {
42 System.out.println("受容判定に失敗しました");
43 e.printStackTrace();
44 return false;
45 }
46 }
47
48 // 交渉終了判定
49 public boolean selectEndNegotiation(Bid offerBid, double time) {
50 if (getThreshold(time) <= rv * Math.pow(df, time)) {
51 return true;
52 }
53 return false;
54 }
55
56 // 閾値を返す
57 public double getThreshold(double time) {
58 double threshold = 1.0;
59 // if (rv != 0.0 && df == 1.0){ //留保価格あり,割引効用なし
60 //
61 // }
62 // else if (rv !=0.0 && df != 1.0){//留保価格あり,割引効用あり
63 // }
64 // else if (rv == 0.0 && df == 1.0){//留保価格なし,割引効用なし
65 // }
66 // else if (rv == 0.0 && df != 1.0){//留保価格なし,割引効用あり
67 //
68 // }
69 /* 交渉戦略に基づきthreshold(t)を設計する */
70 /* negotiationInfoから提案履歴の統計情報を取得できるので使っても良い */
71 /* (統計情報についてはあまりデバッグできていないので,バグが見つかった場合は報告をお願いします) */
72
73 // 例:
74 ArrayList<Object> opponents = negotiationInfo.getOpponents();
75 for (Object sender : opponents) {
76 double m = negotiationInfo.getAverage(sender);
77 double v = negotiationInfo.getVariancer(sender);
78 double sd = negotiationInfo.getStandardDeviation(sender);
79 }
80
81 return threshold;
82 }
83}
Note: See TracBrowser for help on using the repository browser.