1 | package negotiator.boaframework.offeringstrategy.other;
|
---|
2 |
|
---|
3 | import java.util.HashSet;
|
---|
4 | import java.util.Map;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | import genius.core.bidding.BidDetails;
|
---|
8 | import genius.core.boaframework.BOAparameter;
|
---|
9 | import genius.core.boaframework.NegotiationSession;
|
---|
10 | import genius.core.boaframework.NoModel;
|
---|
11 | import genius.core.boaframework.OMStrategy;
|
---|
12 | import genius.core.boaframework.OfferingStrategy;
|
---|
13 | import genius.core.boaframework.OpponentModel;
|
---|
14 | import 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 | *
|
---|
28 | * @author Alex Dirkzwager, Mark Hendrikx
|
---|
29 | */
|
---|
30 | public class TimeDependent_Offering extends OfferingStrategy {
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * k \in [0, 1]. For k = 0 the agent starts with a bid of maximum utility
|
---|
34 | */
|
---|
35 | private double k;
|
---|
36 | /** Maximum target utility */
|
---|
37 | private double Pmax;
|
---|
38 | /** Minimum target utility */
|
---|
39 | private double Pmin;
|
---|
40 | /** Concession factor */
|
---|
41 | private double e;
|
---|
42 | /** Outcome space */
|
---|
43 | SortedOutcomeSpace outcomespace;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Empty constructor used for reflection. Note this constructor assumes that
|
---|
47 | * init is called next.
|
---|
48 | */
|
---|
49 | public TimeDependent_Offering() {
|
---|
50 | }
|
---|
51 |
|
---|
52 | public TimeDependent_Offering(NegotiationSession negoSession, OpponentModel model, OMStrategy oms, double e,
|
---|
53 | double k, double max, double min) {
|
---|
54 | this.e = e;
|
---|
55 | this.k = k;
|
---|
56 | this.Pmax = max;
|
---|
57 | this.Pmin = min;
|
---|
58 | this.negotiationSession = negoSession;
|
---|
59 | outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
60 | negotiationSession.setOutcomeSpace(outcomespace);
|
---|
61 | this.opponentModel = model;
|
---|
62 | this.omStrategy = oms;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Method which initializes the agent by setting all parameters. The
|
---|
67 | * parameter "e" is the only parameter which is required.
|
---|
68 | */
|
---|
69 | @Override
|
---|
70 | public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
|
---|
71 | Map<String, Double> parameters) throws Exception {
|
---|
72 | if (parameters.get("e") != null) {
|
---|
73 | this.negotiationSession = negoSession;
|
---|
74 |
|
---|
75 | outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
76 | negotiationSession.setOutcomeSpace(outcomespace);
|
---|
77 |
|
---|
78 | this.e = parameters.get("e");
|
---|
79 |
|
---|
80 | if (parameters.get("k") != null)
|
---|
81 | this.k = parameters.get("k");
|
---|
82 | else
|
---|
83 | this.k = 0;
|
---|
84 |
|
---|
85 | if (parameters.get("min") != null)
|
---|
86 | this.Pmin = parameters.get("min");
|
---|
87 | else
|
---|
88 | this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
|
---|
89 |
|
---|
90 | if (parameters.get("max") != null) {
|
---|
91 | Pmax = parameters.get("max");
|
---|
92 | } else {
|
---|
93 | BidDetails maxBid = negoSession.getMaxBidinDomain();
|
---|
94 | Pmax = maxBid.getMyUndiscountedUtil();
|
---|
95 | }
|
---|
96 |
|
---|
97 | this.opponentModel = model;
|
---|
98 | this.omStrategy = oms;
|
---|
99 | } else {
|
---|
100 | throw new Exception("Constant \"e\" for the concession speed was not set.");
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | @Override
|
---|
105 | public BidDetails determineOpeningBid() {
|
---|
106 | return determineNextBid();
|
---|
107 | }
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Simple offering strategy which retrieves the target utility and looks for
|
---|
111 | * the nearest bid if no opponent model is specified. If an opponent model
|
---|
112 | * is specified, then the agent return a bid according to the opponent model
|
---|
113 | * strategy.
|
---|
114 | */
|
---|
115 | @Override
|
---|
116 | public BidDetails determineNextBid() {
|
---|
117 | double time = negotiationSession.getTime();
|
---|
118 | double utilityGoal;
|
---|
119 | utilityGoal = p(time);
|
---|
120 |
|
---|
121 | // System.out.println("[e=" + e + ", Pmin = " +
|
---|
122 | // BilateralAgent.round2(Pmin) + "] t = " + BilateralAgent.round2(time)
|
---|
123 | // + ". Aiming for " + utilityGoal);
|
---|
124 |
|
---|
125 | // if there is no opponent model available
|
---|
126 | if (opponentModel instanceof NoModel) {
|
---|
127 | nextBid = negotiationSession.getOutcomeSpace().getBidNearUtility(utilityGoal);
|
---|
128 | } else {
|
---|
129 | nextBid = omStrategy.getBid(outcomespace, utilityGoal);
|
---|
130 | }
|
---|
131 | return nextBid;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * From [1]:
|
---|
136 | *
|
---|
137 | * A wide range of time dependent functions can be defined by varying the
|
---|
138 | * way in which f(t) is computed. However, functions must ensure that 0 <=
|
---|
139 | * f(t) <= 1, f(0) = k, and f(1) = 1.
|
---|
140 | *
|
---|
141 | * That is, the offer will always be between the value range, at the
|
---|
142 | * beginning it will give the initial constant and when the deadline is
|
---|
143 | * reached, it will offer the reservation value.
|
---|
144 | *
|
---|
145 | * For e = 0 (special case), it will behave as a Hardliner.
|
---|
146 | */
|
---|
147 | public double f(double t) {
|
---|
148 | if (e == 0)
|
---|
149 | return k;
|
---|
150 | double ft = k + (1 - k) * Math.pow(t, 1.0 / e);
|
---|
151 | return ft;
|
---|
152 | }
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Makes sure the target utility with in the acceptable range according to
|
---|
156 | * the domain Goes from Pmax to Pmin!
|
---|
157 | *
|
---|
158 | * @param t
|
---|
159 | * @return double
|
---|
160 | */
|
---|
161 | public double p(double t) {
|
---|
162 | return Pmin + (Pmax - Pmin) * (1 - f(t));
|
---|
163 | }
|
---|
164 |
|
---|
165 | public NegotiationSession getNegotiationSession() {
|
---|
166 | return negotiationSession;
|
---|
167 | }
|
---|
168 |
|
---|
169 | @Override
|
---|
170 | public Set<BOAparameter> getParameterSpec() {
|
---|
171 | Set<BOAparameter> set = new HashSet<BOAparameter>();
|
---|
172 | set.add(new BOAparameter("e", 1.0, "Concession rate"));
|
---|
173 | set.add(new BOAparameter("k", 0.0, "Offset"));
|
---|
174 | set.add(new BOAparameter("min", 0.0, "Minimum utility"));
|
---|
175 | set.add(new BOAparameter("max", 0.99, "Maximum utility"));
|
---|
176 |
|
---|
177 | return set;
|
---|
178 | }
|
---|
179 |
|
---|
180 | @Override
|
---|
181 | public String getName() {
|
---|
182 | return "Other - TimeDependent Offering";
|
---|
183 | }
|
---|
184 | } |
---|