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 | * 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 | */
|
---|
24 | public 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 | } |
---|