source: src/main/java/agents/anac/y2018/fullagent/OfferingStrategy_lgsmi.java@ 341

Last change on this file since 341 was 341, checked in by Katsuhide Fujita, 5 years ago

Katsuhide Fujita added ANAC2018 agents.

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