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