source: src/main/java/agents/anac/y2015/AgentW/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.6 KB
Line 
1package agents.anac.y2015.AgentW;
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
43 int negonum = negotiatingInfo.getNegotiatorNum();
44
45 double ou[] = new double[negonum];
46 double avarage = 0;
47
48 //System.out.println("nego :"+ou.length);
49
50 if(negotiatingInfo.getOpponents().size()!=0){
51 for(int i=0;i<negotiatingInfo.getOpponents().size();i++){
52
53 //System.out.println(negotiatingInfo.getOpponents().get(i));
54 //System.out.println("差:"+negotiatingInfo.getgap(negotiatingInfo.getOpponents().get(i)));
55
56 ou[i] = 4*negotiatingInfo.getgap(negotiatingInfo.getOpponents().get(i));
57 ou[i] = ou[i] + 3*negotiatingInfo.getgapn(negotiatingInfo.getOpponents().get(i),1);
58 ou[i] = ou[i] + 2*negotiatingInfo.getgapn(negotiatingInfo.getOpponents().get(i),2);
59 ou[i] = ou[i] + negotiatingInfo.getgapn(negotiatingInfo.getOpponents().get(i),3);
60
61 ou[i] = ou[i]/10;
62 avarage = avarage + ou[i];
63 }
64
65 avarage = avarage / (negonum-1);
66 }
67
68 double e = 0.3;
69
70 //double threshold = 1.0 - time;
71 double threshold = 1.0 - Math.pow(time,1/e);
72
73 if ((threshold - avarage > 0)&&(threshold - avarage < 1)){
74 threshold = threshold - avarage;
75 }
76
77 /* 交渉戦略に基づきthreshold(t)を設計する */
78 /* negotiatingInfoから提案履歴の統計情報を取得できるので使っても良い */
79 /* 例:
80 ArrayList<Object> opponents = negotiatingInfo.getOpponents();
81 for(Object sender:opponents){
82 double m = negotiatingInfo.getAverage(sender);
83 double v = negotiatingInfo.getVariancer(sender);
84 double sd = negotiatingInfo.getStandardDeviation(sender);
85 }
86 */
87
88 return threshold;
89 }
90
91}
Note: See TracBrowser for help on using the repository browser.