source: src/main/java/negotiator/boaframework/offeringstrategy/other/GeniusTimeDependent_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: 4.7 KB
Line 
1package negotiator.boaframework.offeringstrategy.other;
2
3import java.util.HashSet;
4import java.util.Map;
5import java.util.Set;
6
7import genius.core.bidding.BidDetails;
8import genius.core.boaframework.BOAparameter;
9import genius.core.boaframework.NegotiationSession;
10import genius.core.boaframework.NoModel;
11import genius.core.boaframework.OMStrategy;
12import genius.core.boaframework.OfferingStrategy;
13import genius.core.boaframework.OpponentModel;
14import genius.core.boaframework.SortedOutcomeSpace;
15
16/**
17 * The problem with the default TDT, is that when the negotiation starts, some
18 * time has already passed. For small domains this amount is negligible.
19 * However, for big domains this often results in the first offer not being the
20 * best possible offer.
21 *
22 * @author Mark Hendrikx
23 */
24public class GeniusTimeDependent_Offering extends OfferingStrategy {
25
26 private double startTime;
27 /**
28 * k \in [0, 1]. For k = 0 the agent starts with a bid of maximum utility
29 */
30 private double k;
31 /** Maximum target utility */
32 private double Pmax;
33 /** Minimum target utility */
34 private double Pmin;
35 /** Concession factor */
36 private double e;
37 /** Outcome space */
38 SortedOutcomeSpace outcomespace;
39
40 /**
41 * Empty constructor used for reflexion. Note this constructor assumes that
42 * init is called next.
43 */
44 public GeniusTimeDependent_Offering() {
45 }
46
47 public GeniusTimeDependent_Offering(NegotiationSession negoSession, OpponentModel model, OMStrategy oms, double e,
48 double k, double max, double min) {
49 this.e = e;
50 this.k = k;
51 this.Pmax = max;
52 this.Pmin = min;
53 this.negotiationSession = negoSession;
54 outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
55 negotiationSession.setOutcomeSpace(outcomespace);
56 this.opponentModel = model;
57 this.omStrategy = oms;
58 }
59
60 @Override
61 public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
62 Map<String, Double> parameters) throws Exception {
63 if (parameters.get("e") != null) {
64 this.negotiationSession = negoSession;
65
66 outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
67 negotiationSession.setOutcomeSpace(outcomespace);
68
69 this.e = parameters.get("e");
70
71 if (parameters.get("k") != null)
72 this.k = parameters.get("k");
73 else
74 this.k = 0;
75
76 if (parameters.get("min") != null)
77 this.Pmin = parameters.get("min");
78 else
79 this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
80
81 if (parameters.get("max") != null) {
82 Pmax = parameters.get("max");
83 } else {
84 BidDetails maxBid = negoSession.getMaxBidinDomain();
85 Pmax = maxBid.getMyUndiscountedUtil();
86 }
87
88 this.opponentModel = model;
89 this.omStrategy = oms;
90 } else {
91 throw new Exception("Constant \"e\" for the concession speed was not set.");
92 }
93 }
94
95 @Override
96 public BidDetails determineOpeningBid() {
97 startTime = negotiationSession.getTime();
98 return determineNextBid();
99 }
100
101 /**
102 * Simple offering strategy which retrieves the target utility and finds
103 */
104 @Override
105 public BidDetails determineNextBid() {
106 double time = negotiationSession.getTime();
107 double utilityGoal;
108 utilityGoal = p(time);
109
110 // if there is no opponent model available
111 if (opponentModel instanceof NoModel) {
112 nextBid = negotiationSession.getOutcomeSpace().getBidNearUtility(utilityGoal);
113 } else {
114 nextBid = omStrategy.getBid(outcomespace, utilityGoal);
115 }
116 return nextBid;
117 }
118
119 /**
120 * From [1]:
121 *
122 * A wide range of time dependent functions can be defined by varying the
123 * way in which f(t) is computed. However, functions must ensure that 0 <=
124 * f(t) <= 1, f(0) = k, and f(1) = 1.
125 *
126 * That is, the offer will always be between the value range, at the
127 * beginning it will give the initial constant and when the deadline is
128 * reached, it will offer the reservation value.
129 */
130 public double f(double t) {
131 double ft = k + (1.0 - k) * Math.pow((t - startTime) / (1.0 - startTime), 1.0 / e);
132 return ft;
133 }
134
135 /**
136 * Makes sure the target utility with in the acceptable range according to
137 * the domain
138 *
139 * @param t
140 * @return double
141 */
142 public double p(double t) {
143 return Pmin + (Pmax - Pmin) * (1.0 - f(t));
144 }
145
146 @Override
147 public Set<BOAparameter> getParameterSpec() {
148 Set<BOAparameter> set = new HashSet<BOAparameter>();
149 set.add(new BOAparameter("e", 1.0, "Concession rate"));
150 set.add(new BOAparameter("k", 0.0, "Offset"));
151 set.add(new BOAparameter("min", 0.0, "Minimum utility"));
152 set.add(new BOAparameter("max", 0.99, "Maximum utility"));
153
154 return set;
155 }
156
157 @Override
158 public String getName() {
159 return "Other - Genius TimeDependent Offering";
160 }
161}
Note: See TracBrowser for help on using the repository browser.