source: src/test/java/boaexample/TimeDependent_Offering.java@ 127

Last change on this file since 127 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: 5.0 KB
Line 
1package boaexample;
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 * This is an abstract class used to implement a TimeDependentAgent Strategy
18 * adapted from [1] [1] S. Shaheen Fatima Michael Wooldridge Nicholas R.
19 * Jennings Optimal Negotiation Strategies for Agents with Incomplete
20 * Information http://eprints.ecs.soton.ac.uk/6151/1/atal01.pdf
21 *
22 * The default strategy was extended to enable the usage of opponent models.
23 *
24 * Note that this agent is not fully equivalent to the theoretical model,
25 * loading the domain may take some time, which may lead to the agent skipping
26 * the first bid. A better implementation is GeniusTimeDependent_Offering.
27 */
28public class TimeDependent_Offering extends OfferingStrategy {
29
30 /**
31 * k in [0, 1]. For k = 0 the agent starts with a bid of maximum utility
32 */
33 private double k;
34 /** Maximum target utility */
35 private double Pmax;
36 /** Minimum target utility */
37 private double Pmin;
38 /** Concession factor */
39 private double e;
40 /** Outcome space */
41 private SortedOutcomeSpace outcomespace;
42
43 /**
44 * Method which initializes the agent by setting all parameters. The
45 * parameter "e" is the only parameter which is required.
46 */
47 @Override
48 public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
49 Map<String, Double> parameters) throws Exception {
50 super.init(negoSession, parameters);
51 if (parameters.get("e") != null) {
52 this.negotiationSession = negoSession;
53
54 outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
55 negotiationSession.setOutcomeSpace(outcomespace);
56
57 this.e = parameters.get("e");
58
59 if (parameters.get("k") != null)
60 this.k = parameters.get("k");
61 else
62 this.k = 0;
63
64 if (parameters.get("min") != null)
65 this.Pmin = parameters.get("min");
66 else
67 this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
68
69 if (parameters.get("max") != null) {
70 Pmax = parameters.get("max");
71 } else {
72 BidDetails maxBid = negoSession.getMaxBidinDomain();
73 Pmax = maxBid.getMyUndiscountedUtil();
74 }
75
76 this.opponentModel = model;
77 this.omStrategy = oms;
78 } else {
79 throw new Exception("Constant \"e\" for the concession speed was not set.");
80 }
81 }
82
83 @Override
84 public BidDetails determineOpeningBid() {
85 return determineNextBid();
86 }
87
88 /**
89 * Simple offering strategy which retrieves the target utility and looks for
90 * the nearest bid if no opponent model is specified. If an opponent model
91 * is specified, then the agent return a bid according to the opponent model
92 * strategy.
93 */
94 @Override
95 public BidDetails determineNextBid() {
96 double time = negotiationSession.getTime();
97 double utilityGoal;
98 utilityGoal = p(time);
99
100 // System.out.println("[e=" + e + ", Pmin = " +
101 // BilateralAgent.round2(Pmin) + "] t = " + BilateralAgent.round2(time)
102 // + ". Aiming for " + utilityGoal);
103
104 // if there is no opponent model available
105 if (opponentModel instanceof NoModel) {
106 nextBid = negotiationSession.getOutcomeSpace().getBidNearUtility(utilityGoal);
107 } else {
108 nextBid = omStrategy.getBid(outcomespace, utilityGoal);
109 }
110 return nextBid;
111 }
112
113 /**
114 * From [1]:
115 *
116 * A wide range of time dependent functions can be defined by varying the
117 * way in which f(t) is computed. However, functions must ensure that 0 <=
118 * f(t) <= 1, f(0) = k, and f(1) = 1.
119 *
120 * That is, the offer will always be between the value range, at the
121 * beginning it will give the initial constant and when the deadline is
122 * reached, it will offer the reservation value.
123 *
124 * For e = 0 (special case), it will behave as a Hardliner.
125 */
126 public double f(double t) {
127 if (e == 0)
128 return k;
129 double ft = k + (1 - k) * Math.pow(t, 1.0 / e);
130 return ft;
131 }
132
133 /**
134 * Makes sure the target utility with in the acceptable range according to
135 * the domain Goes from Pmax to Pmin!
136 *
137 * @param t
138 * @return double
139 */
140 public double p(double t) {
141 return Pmin + (Pmax - Pmin) * (1 - f(t));
142 }
143
144 public NegotiationSession getNegotiationSession() {
145 return negotiationSession;
146 }
147
148 @Override
149 public Set<BOAparameter> getParameterSpec() {
150 Set<BOAparameter> set = new HashSet<BOAparameter>();
151 set.add(new BOAparameter("e", 1.0, "Concession rate"));
152 set.add(new BOAparameter("k", 0.0, "Offset"));
153 set.add(new BOAparameter("min", 0.0, "Minimum utility"));
154 set.add(new BOAparameter("max", 0.99, "Maximum utility"));
155
156 return set;
157 }
158
159 @Override
160 public String getName() {
161 return "TimeDependent Offering example";
162 }
163}
Note: See TracBrowser for help on using the repository browser.