source: src/main/java/agents/anac/y2014/BraveCat/OfferingStrategies/TimeDependent_Offering.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 3.5 KB
Line 
1 package agents.anac.y2014.BraveCat.OfferingStrategies;
2
3 import agents.anac.y2014.BraveCat.OpponentModelStrategies.OMStrategy;
4 import agents.anac.y2014.BraveCat.OpponentModels.NoModel;
5 import agents.anac.y2014.BraveCat.OpponentModels.OpponentModel;
6 import java.util.HashMap;
7 import agents.anac.y2014.BraveCat.necessaryClasses.NegotiationSession;
8 import agents.anac.y2014.BraveCat.necessaryClasses.SortedOutcomeSpace;
9import genius.core.bidding.BidDetails;
10
11 public class TimeDependent_Offering extends OfferingStrategy
12 {
13 private double k;
14 private double Pmax;
15 private double Pmin;
16 private double e;
17 SortedOutcomeSpace outcomespace;
18
19 public TimeDependent_Offering()
20 {
21 }
22
23 public TimeDependent_Offering(NegotiationSession negoSession, OpponentModel model, OMStrategy oms, double e, double k, double max, double min)
24 {
25 this.e = e;
26 this.k = k;
27 this.Pmax = max;
28 this.Pmin = min;
29 this.negotiationSession = negoSession;
30 this.outcomespace = new SortedOutcomeSpace(this.negotiationSession.getUtilitySpace());
31 this.negotiationSession.setOutcomeSpace(this.outcomespace);
32 this.opponentModel = model;
33 this.omStrategy = oms;
34 }
35
36 @Override
37 public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms, HashMap<String, Double> parameters)
38 throws Exception
39 {
40 if (parameters.get("e") != null) {
41 this.negotiationSession = negoSession;
42
43 this.outcomespace = new SortedOutcomeSpace(this.negotiationSession.getUtilitySpace());
44 this.negotiationSession.setOutcomeSpace(this.outcomespace);
45
46 this.e = ((Double)parameters.get("e")).doubleValue();
47
48 if (parameters.get("k") != null)
49 this.k = ((Double)parameters.get("k")).doubleValue();
50 else {
51 this.k = 0.0D;
52 }
53 if (parameters.get("min") != null)
54 this.Pmin = ((Double)parameters.get("min")).doubleValue();
55 else {
56 this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
57 }
58 if (parameters.get("max") != null) {
59 this.Pmax = ((Double)parameters.get("max")).doubleValue();
60 } else {
61 BidDetails maxBid = negoSession.getMaxBidinDomain();
62 this.Pmax = maxBid.getMyUndiscountedUtil();
63 }
64
65 this.opponentModel = model;
66 this.omStrategy = oms;
67 } else {
68 throw new Exception("Constant \"e\" for the concession speed was not set.");
69 }
70 }
71
72 @Override
73 public BidDetails determineOpeningBid()
74 {
75 return determineNextBid();
76 }
77
78 @Override
79 public BidDetails determineNextBid()
80 {
81 double time = this.negotiationSession.getTime();
82
83 double utilityGoal = p(time);
84
85 if ((this.opponentModel instanceof NoModel))
86 this.nextBid = this.negotiationSession.getOutcomeSpace().getBidNearUtility(utilityGoal);
87 else {
88 this.nextBid = this.omStrategy.getBid(this.outcomespace, utilityGoal);
89 }
90 return this.nextBid;
91 }
92
93 public double f(double t)
94 {
95 if (this.e == 0.0D)
96 return this.k;
97 double ft = this.k + (1.0D - this.k) * Math.pow(t, 1.0D / this.e);
98 return ft;
99 }
100
101 public double p(double t)
102 {
103 return this.Pmin + (this.Pmax - this.Pmin) * (1.0D - f(t));
104 }
105
106 public NegotiationSession getNegotiationSession()
107 {
108 return this.negotiationSession;
109 }
110 @Override
111 public String GetName()
112 {
113 return "TimeDependent Offering!";
114 }
115 }
Note: See TracBrowser for help on using the repository browser.