source: src/main/java/agents/anac/y2014/DoNA/ClearDefaultStrategy.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: 22.6 KB
RevLine 
[127]1package agents.anac.y2014.DoNA;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import genius.core.AgentID;
7import genius.core.Bid;
8import genius.core.actions.Accept;
9import genius.core.actions.Action;
10import genius.core.actions.EndNegotiation;
11import genius.core.actions.Offer;
12import genius.core.bidding.BidDetails;
13import genius.core.boaframework.SortedOutcomeSpace;
14import genius.core.misc.Range;
15import genius.core.timeline.TimeLineInfo;
16import genius.core.utility.AbstractUtilitySpace;
17
18//1. Check Utility is not 1. Multiple with MaxUtility
19//2. CHECK DISTANCE BETWEEN AVERAGE RESPONSE AND MINIMUM RESPONSE
20
21// a. How many are opponent sequence steps made?
22// b. How many rounds, which the opponent stay, are made?
23// c. When did the opponent go?
24// d how many bids, from the opponent space-bids are made?
25
26/**
27 * An agent that waits for the last moment and then offers something.
28 *
29 * @author Eden Erez, Erel Segal haLevi
30 * @since 2013-01-13
31 */
32public class ClearDefaultStrategy {
33 public static AbstractUtilitySpace utilitySpace;
34 public static TimeLineInfo timeline;
35
36 private Bid firstBidOfOpponent, lastBidOfOpponent;
37 private Bid maxUtilityBid;
38 private Bid minUtilityBid;
39 private double maxUtility;
40 private double minUtility;
41 private double UtilityRange;
42 private OpponentBidHistory opponentBidHistory;
43 private double averageResponseTime;
44 private SortedOutcomeSpace outcomeSpace;
45 int numOfRounds;
46 boolean NotFirstTime;
47 List<BidDetails> SortedBid;
48
49 private double theTimeIAmReadyToInvestInNegotiation;
50 private double theFastUtilityInvestInNegotiation;
51
52 private int countBid;
53 private double MyOfferedUtility;
54 boolean IConcedeLast;
55 boolean IsPrintForDebug;
56 int numberOfStepsDoneByOpponent;
57 private AgentID agentID;
58
59 public void init(AgentID id) {
60 this.agentID = id;
61 try {
62 if (utilitySpace.getReservationValue() > 0 && utilitySpace.getReservationValue() < 1
63 && utilitySpace.getDiscountFactor() < 1)
64 theTimeIAmReadyToInvestInNegotiation = Math.sqrt(Math.sqrt(1 - utilitySpace.getReservationValue())
65 * Math.sqrt(utilitySpace.getDiscountFactor()));
66 /*
67 * (1-utilitySpace.getReservationValue())
68 *
69 * Math.pow(utilitySpace.getDiscountFactor(),2)
70 *
71 * 2;
72 */
73 else
74 theTimeIAmReadyToInvestInNegotiation = 1.0;
75 theFastUtilityInvestInNegotiation = (1 - Math.sqrt(
76 Math.sqrt(1 - utilitySpace.getDiscountFactor()) * Math.sqrt(utilitySpace.getReservationValue())))
77 * 0.33 + 0.62;
78
79 System.out.println("theTimeIAmReadyToInvestInRiskyNegotiation=" + theTimeIAmReadyToInvestInNegotiation);
80
81 numOfRounds = 0;
82 maxUtilityBid = utilitySpace.getMaxUtilityBid();
83 minUtilityBid = utilitySpace.getMinUtilityBid();
84 maxUtility = utilitySpace.getUtility(maxUtilityBid);
85 minUtility = utilitySpace.getUtility(minUtilityBid);
86 UtilityRange = maxUtility - minUtility;
87 firstBidOfOpponent = lastBidOfOpponent = null;
88 opponentBidHistory = new OpponentBidHistory();
89 opponentBidHistory.initializeDataStructures(utilitySpace.getDomain());
90 outcomeSpace = new SortedOutcomeSpace(utilitySpace);
91 NotFirstTime = false;
92 SortedBid = outcomeSpace.getAllOutcomes();
93 /*
94 * for (int i = 0; i < SortedBid.size(); i++) { BidDetails
95 * bidDetails= SortedBid.get(i);
96 * System.out.println("getMyUndiscountedUtil:" +
97 * bidDetails.getMyUndiscountedUtil()); }
98 */
99 countBid = 0;
100 MyOfferedUtility = 2;
101 IConcedeLast = false;
102 IsPrintForDebug = false;
103
104 } catch (Exception e) {
105 System.out.println("initialization error" + e.getMessage());
106 }
107 }
108
109 public void ReceiveMessage(Action opponentAction) {
110 if (opponentAction instanceof Offer) {
111 lastBidOfOpponent = ((Offer) opponentAction).getBid();
112 if (firstBidOfOpponent == null)
113 firstBidOfOpponent = lastBidOfOpponent;
114
115 double remainingTime = theTimeIAmReadyToInvestInNegotiation - timeline.getTime();
116 double weight = remainingTime * 100;
117 opponentBidHistory.updateOpponentModel(lastBidOfOpponent, weight, utilitySpace);
118
119 numOfRounds++;
120 averageResponseTime = timeline.getTime() / numOfRounds;
121 numberOfStepsDoneByOpponent = opponentBidHistory.getNumberOfDistinctBids();
122
123 // System.out.println("BIU: time="+timeline.getTime()+"
124 // #bids="+numOfRounds+" averageResponseTime="+averageResponseTime);
125 }
126 }
127
128 /**
129 * @param RoundLeft
130 * - estimation of the number of rounds left until the time we
131 * decided to quit. Logarithmic scale (1/2, 1/4, 1/8..).
132 * @param MinUtil
133 * the minimum utility we want to get from this nego
134 * @return
135 */
136 public Bid middleBid(int RoundLeft, double MinUtil) throws Exception {
137 final double MAX_ROUNDS = 12.0; // log scale
138 /*
139 * double explorationSurface = SortedBid.size()*(RoundLeft/10);
140 * System.out
141 * .println(Integer.parseInt(Double.toString(explorationSurface)));
142 * return
143 * SortedBid.get(Integer.parseInt(Double.toString(explorationSurface
144 * ))).getBid();
145 */
146 // System.out.println(utilitySpace.getDiscountFactor() + ", " +
147 // utilitySpace.getReservationValue());
148 double utilOfMyBestBid = maxUtility;
149 double utilOfBestOpponentBid = utilitySpace.getUtility(this.opponentBidHistory.getBestBidInHistory());
150 // double constFactor =
151 // ((1-0.6+utilitySpace.getDiscountFactor())*RoundLeft)/10 +
152 // 0.6*(utilitySpace.getDiscountFactor());
153
154 double weightOfOurBestBid = UtilityRange * (RoundLeft / MAX_ROUNDS) + MinUtil; // larger
155 // constFactor
156 // -
157 // larger
158 // weight
159 // to
160 // our
161 // best
162 // bid.
163 // When RoundLeft=10, the weight is 1 - we take ONLY our best bid.
164 // When RoundLeft=0, the weight is MinUtil
165 // When RoundLeft=5, it is the average between 1 and MinUtil.
166 // double averageUtility = 0.8*utilOfMyBid + 0.2*utilOfOpponentBid;
167 double averageUtility = weightOfOurBestBid * utilOfMyBestBid + (1 - weightOfOurBestBid) * utilOfBestOpponentBid;
168
169 /*
170 * Range r = new Range(averageUtility,1); List<BidDetails> RangeBid =
171 * outcomeSpace.getBidsinRange(r);
172 *
173 * int RndInx =
174 * Integer.parseInt(Double.toString((Math.random()*RangeBid.size())));
175 * return RangeBid.get(RndInx).getBid();
176 */
177
178 List<BidDetails> bidDetailsWeAreWillingToAccept = outcomeSpace.getBidsinRange(new Range(averageUtility, 1.0));
179 List<Bid> bidsWeAreWillingToAccept = new ArrayList<Bid>();
180 for (BidDetails bd : bidDetailsWeAreWillingToAccept)
181 bidsWeAreWillingToAccept.add(bd.getBid());
182 Bid bid = opponentBidHistory.ChooseBid(bidsWeAreWillingToAccept, utilitySpace.getDomain());
183 if (bid == null) {
184
185 try {
186 Bid tmp = outcomeSpace.getBidNearUtility(averageUtility).getBid();
187 return tmp;
188 } catch (Exception e) {
189 System.out.println("***********************Exception");
190 return SortedBid.get(0).getBid();
191 }
192 } else {
193 return bid;
194 }
195 }
196
197 /**
198 * This will be returned when there is exception in other strategies
199 */
200 public Action ExceptionStrategy() {
201 return this.FastLastMomentStrategyWithoutEndNegotiation(1, 0, timeline.getTime());
202 }
203
204 /**
205 * If the utility of the given bid is better than the reservation value -
206 * offer it. Otherwise - return EndNegotiation.
207 *
208 * @throws Exception
209 */
210 private Action EndNegotiationOrAcceptOrNewOfferr(Bid myOfferedBid) throws Exception {
211 double lastBidOfOpponentUtility = (lastBidOfOpponent == null ? 0 : utilitySpace.getUtility(lastBidOfOpponent));
212
213 double MyOfferedUtility = utilitySpace.getUtility(myOfferedBid);
214
215 Bid bestOpponentBid = this.opponentBidHistory.getBestBidInHistory();
216
217 double bestOpponentBidUtility = (bestOpponentBid == null) ? utilitySpace.getUtility(this.minUtilityBid)
218 : utilitySpace.getUtility(bestOpponentBid);
219
220 double endNegotiationUtility = utilitySpace.getReservationValue();
221
222 // 1st priority - EndNegotiation is the best choice
223 if (endNegotiationUtility >= MyOfferedUtility && endNegotiationUtility >= bestOpponentBidUtility
224 && endNegotiationUtility >= lastBidOfOpponentUtility) {
225 return new EndNegotiation(agentID);
226 }
227
228 // 2nd priority - Accept (lastBidOfOpponentUtil) is the best choice
229 else if (lastBidOfOpponentUtility >= bestOpponentBidUtility && lastBidOfOpponentUtility >= MyOfferedUtility
230 && lastBidOfOpponentUtility >= endNegotiationUtility) {
231 return new Accept(agentID, lastBidOfOpponent);
232 }
233
234 // 3rd priority - bestOpponentBidUtility is the best choice
235 else if (bestOpponentBidUtility >= lastBidOfOpponentUtility && bestOpponentBidUtility >= MyOfferedUtility
236 && bestOpponentBidUtility >= endNegotiationUtility) {
237 return new Offer(agentID, this.opponentBidHistory.getBestBidInHistory());
238 }
239
240 // 4th priority - myOfferedBid
241 else
242 return new Offer(agentID, myOfferedBid);
243 }
244
245 /**
246 * This strategy counts the number of steps the opponent has done towards us
247 * (= distinct bids), and does the same number of steps towards him.
248 */
249 public Action OneStepStrategy() {
250 try {
251 Bid bid = SortedBid.get(numberOfStepsDoneByOpponent).getBid();
252 return EndNegotiationOrAcceptOrNewOfferr(bid);
253 } catch (Exception e) {
254 System.out.println("OneStepStrategy: Exception in ChooseAction:" + e.getMessage());
255 return ExceptionStrategy(); // terminate if anything goes wrong.
256 }
257 }
258
259 public Action RandomStepStrategy() {
260 try {
261 Bid bid = SortedBid.get(numberOfStepsDoneByOpponent).getBid();
262 double MyOfferedUtility = utilitySpace.getUtility(bid);
263 List<BidDetails> bidDetailsWeAreWillingToAccept = outcomeSpace
264 .getBidsinRange(new Range(MyOfferedUtility, 1.0));
265 List<Bid> bidsWeAreWillingToAccept = new ArrayList<Bid>();
266 for (BidDetails bd : bidDetailsWeAreWillingToAccept)
267 bidsWeAreWillingToAccept.add(bd.getBid());
268 Bid bid2 = opponentBidHistory.ChooseBid(bidsWeAreWillingToAccept, utilitySpace.getDomain());
269 if (bid2 == null) {
270
271 try {
272 Bid tmp = outcomeSpace.getBidNearUtility(MyOfferedUtility).getBid();
273 return EndNegotiationOrAcceptOrNewOfferr(tmp);
274 } catch (Exception e) {
275 System.out.println("***********************Exception");
276 return EndNegotiationOrAcceptOrNewOfferr(SortedBid.get(0).getBid());
277 }
278 } else {
279 return EndNegotiationOrAcceptOrNewOfferr(bid2);
280 }
281
282 } catch (Exception e) {
283 System.out.println("OneStepStrategy: Exception in ChooseAction:" + e.getMessage());
284 return ExceptionStrategy(); // terminate if anything goes wrong.
285 }
286 }
287
288 public Action OneStepStrategy(double ratio) {
289 try {
290 int bidNumber = (int) (ratio * numberOfStepsDoneByOpponent);
291 Bid bid = SortedBid.get(bidNumber + 1).getBid();
292 // System.out.println("bid: " + bid.toString());
293 return EndNegotiationOrAcceptOrNewOfferr(bid);
294 } catch (Exception e) {
295 System.out.println("OneStepStrategy: Exception in ChooseAction:" + e.getMessage());
296 return ExceptionStrategy(); // terminate if anything goes wrong.
297 }
298 }
299
300 /**
301 * This strategy tries to achieve an agreement as fast as possible.
302 */
303 public Action FastStrategy() {
304 try {
305 return EndNegotiationOrAcceptOrNewOfferr(SortedBid.get(countBid++).getBid());
306 } catch (Exception e) {
307 System.out.println("Exception in ChooseAction:" + e.getMessage());
308 return new EndNegotiation(agentID);
309 }
310 }
311
312 public Action FastStrategyWithoutEndNegotiation(double VirtulReservation) {
313 try {
314 double lastBidOfOpponentUtil = lastBidOfOpponent == null ? 0 : utilitySpace.getUtility(lastBidOfOpponent);
315 MyOfferedUtility = utilitySpace.getUtility(SortedBid.get(countBid).getBid());
316 double bestOpponentBidUtility = utilitySpace.getUtility(this.opponentBidHistory.getBestBidInHistory());
317 // lastBidOfOpponentUtil is the best choice
318 if (lastBidOfOpponentUtil >= bestOpponentBidUtility && lastBidOfOpponentUtil >= MyOfferedUtility
319 && lastBidOfOpponentUtil >= VirtulReservation) {
320 return new Accept(agentID, lastBidOfOpponent);
321 }
322 // bestOpponentBidUtility is the best choice
323 else if (bestOpponentBidUtility >= lastBidOfOpponentUtil && bestOpponentBidUtility >= MyOfferedUtility
324 && bestOpponentBidUtility >= VirtulReservation) {
325 return new Offer(agentID, this.opponentBidHistory.getBestBidInHistory());
326 }
327 // Reservation is the best choice
328 else if (VirtulReservation >= MyOfferedUtility && VirtulReservation >= bestOpponentBidUtility
329 && VirtulReservation >= lastBidOfOpponentUtil) {
330 Bid bid = SortedBid.get(countBid).getBid();
331 double MyOfferedUtility = utilitySpace.getUtility(bid);
332 List<BidDetails> bidDetailsWeAreWillingToAccept = outcomeSpace
333 .getBidsinRange(new Range(MyOfferedUtility, 1.0));
334 List<Bid> bidsWeAreWillingToAccept = new ArrayList<Bid>();
335 for (BidDetails bd : bidDetailsWeAreWillingToAccept)
336 bidsWeAreWillingToAccept.add(bd.getBid());
337 Bid bid2 = opponentBidHistory.ChooseBid(bidsWeAreWillingToAccept, utilitySpace.getDomain());
338 if (bid2 == null) {
339
340 try {
341 return EndNegotiationOrAcceptOrNewOfferr(bid);
342 } catch (Exception e) {
343 System.out.println("***********************Exception");
344 return EndNegotiationOrAcceptOrNewOfferr(SortedBid.get(0).getBid());
345 }
346 } else {
347 return new Offer(agentID, bid2);
348 }
349 // return new Offer(SortedBid.get(countBid).getBid());
350 // return new EndNegotiation();
351 } else
352 return new Offer(agentID, SortedBid.get(countBid++).getBid());
353
354 } catch (Exception e) {
355 System.out.println("Exception in ChooseAction:" + e.getMessage());
356 return FastStrategy();
357 }
358 }
359
360 public Action FastLastMomentStrategyWithoutEndNegotiation(double StartMinUtil, double MinUtil,
361 double dblMyRoundTime) {
362 double Delta = (StartMinUtil - MinUtil) / 11;
363 // double MinUtil = 0.75;
364 // double dblMyRoundTime =
365 // timeline.getTime()/(1.1*(1-utilitySpace.getReservationValue()));
366 // double dblMyRoundTime = timeline.getTime();
367 int FactorOfAverageResponseTime = 1;
368 if (dblMyRoundTime >= 1 - Math.pow(2, 2) * FactorOfAverageResponseTime * averageResponseTime) { // Other
369 // before-last
370 // moments
371 // -
372 // logarithmic
373 // scale
374 return FastStrategyWithoutEndNegotiation(MinUtil);
375 } else if (dblMyRoundTime >= 1 - Math.pow(2, 3) * FactorOfAverageResponseTime * averageResponseTime) {
376 return FastStrategyWithoutEndNegotiation(MinUtil + Delta);
377 } else if (dblMyRoundTime >= 1 - Math.pow(2, 4) * FactorOfAverageResponseTime * averageResponseTime) {
378 return FastStrategyWithoutEndNegotiation(MinUtil + 2 * Delta);
379 } else if (dblMyRoundTime >= 1 - Math.pow(2, 5) * FactorOfAverageResponseTime * averageResponseTime) {
380 return FastStrategyWithoutEndNegotiation(MinUtil + 3 * Delta);
381 } else if (dblMyRoundTime >= 1 - Math.pow(2, 6) * FactorOfAverageResponseTime * averageResponseTime) {
382 return FastStrategyWithoutEndNegotiation(MinUtil + 4 * Delta);
383 } else if (dblMyRoundTime >= 1 - Math.pow(2, 7) * FactorOfAverageResponseTime * averageResponseTime) {
384 return FastStrategyWithoutEndNegotiation(MinUtil + 5 * Delta);
385 } else if (dblMyRoundTime >= 1 - Math.pow(2, 8) * FactorOfAverageResponseTime * averageResponseTime) {
386 return FastStrategyWithoutEndNegotiation(MinUtil + 6 * Delta);
387 } else if (dblMyRoundTime >= 1 - Math.pow(2, 9) * FactorOfAverageResponseTime * averageResponseTime) {
388 return FastStrategyWithoutEndNegotiation(MinUtil + 7 * Delta);
389 } else if (dblMyRoundTime >= 1 - Math.pow(2, 10) * FactorOfAverageResponseTime * averageResponseTime) {
390 return FastStrategyWithoutEndNegotiation(MinUtil + 8 * Delta);
391 } else if (dblMyRoundTime >= 1 - Math.pow(2, 11) * FactorOfAverageResponseTime * averageResponseTime) {
392 return FastStrategyWithoutEndNegotiation(MinUtil + 9 * Delta);
393 } else if (dblMyRoundTime >= 1 - Math.pow(2, 12) * FactorOfAverageResponseTime * averageResponseTime) {
394 return FastStrategyWithoutEndNegotiation(MinUtil + 10 * Delta);
395 } else {
396 return FastStrategyWithoutEndNegotiation(StartMinUtil);
397 }
398 }
399
400 public Action LastMomentStrategy(double MinUtil, double dblMyRoundTime) {
401 try {
402 int FactorOfAverageResponseTime = 2;
403 Bid bid;
404 if (dblMyRoundTime >= 1 - FactorOfAverageResponseTime * averageResponseTime) { // last
405 // last
406 // moment
407 double utilOfBid = utilitySpace.getUtility(lastBidOfOpponent);
408 if (utilitySpace.getReservationValue() > utilOfBid) {
409 if (IsPrintForDebug)
410 System.out.println("***********EndNegotiation");
411 return new EndNegotiation(agentID);
412 } else
413 return new Accept(agentID, lastBidOfOpponent);
414
415 } else if (dblMyRoundTime >= 1 - Math.pow(2, 1) * FactorOfAverageResponseTime * averageResponseTime) { // one
416 // before
417 // last
418 // moment
419 double utilOflastBidOfOpponent = utilitySpace.getUtility(lastBidOfOpponent);
420 double utilOfBestBidOfOppenent = utilitySpace.getUtility(this.opponentBidHistory.getBestBidInHistory());
421 if (utilitySpace.getReservationValue() > utilOfBestBidOfOppenent
422 && utilitySpace.getReservationValue() > utilOflastBidOfOpponent) {
423 if (IsPrintForDebug)
424 System.out.println("***********EndNegotiation1");
425 return new EndNegotiation(agentID);
426 } else if (utilOflastBidOfOpponent >= utilOfBestBidOfOppenent)
427 return new Accept(agentID, lastBidOfOpponent);
428 else
429 return new Offer(agentID, this.opponentBidHistory.getBestBidInHistory());
430 } else if (dblMyRoundTime >= 1 - Math.pow(2, 2) * FactorOfAverageResponseTime * averageResponseTime) { // Other
431 // before-last
432 // moments
433 // -
434 // logarithmic
435 // scale
436 return FastStrategy();
437 } else if (dblMyRoundTime >= 1 - Math.pow(2, 3) * FactorOfAverageResponseTime * averageResponseTime) {
438 return FastStrategy();
439 } else if (dblMyRoundTime >= 1 - Math.pow(2, 4) * FactorOfAverageResponseTime * averageResponseTime) {
440 bid = middleBid(3, MinUtil);
441 } else if (dblMyRoundTime >= 1 - Math.pow(2, 5) * FactorOfAverageResponseTime * averageResponseTime) {
442 bid = middleBid(4, MinUtil);
443 } else if (dblMyRoundTime >= 1 - Math.pow(2, 6) * FactorOfAverageResponseTime * averageResponseTime) {
444 bid = middleBid(5, MinUtil);
445 } else if (dblMyRoundTime >= 1 - Math.pow(2, 7) * FactorOfAverageResponseTime * averageResponseTime) {
446 bid = middleBid(6, MinUtil);
447 } else if (dblMyRoundTime >= 1 - Math.pow(2, 8) * FactorOfAverageResponseTime * averageResponseTime) {
448 bid = middleBid(7, MinUtil);
449 } else if (dblMyRoundTime >= 1 - Math.pow(2, 9) * FactorOfAverageResponseTime * averageResponseTime) {
450 bid = middleBid(8, MinUtil);
451 } else if (dblMyRoundTime >= 1 - Math.pow(2, 10) * FactorOfAverageResponseTime * averageResponseTime) {
452 bid = middleBid(9, MinUtil);
453 } else if (dblMyRoundTime >= 1 - Math.pow(2, 11) * FactorOfAverageResponseTime * averageResponseTime) {
454 bid = middleBid(10, MinUtil);
455 } else if (dblMyRoundTime >= 1 - Math.pow(2, 12) * FactorOfAverageResponseTime * averageResponseTime) {
456 bid = middleBid(11, MinUtil);
457 } else {
458 double utilOfOurBestBid = maxUtility;
459 if (utilitySpace.getReservationValue() > utilOfOurBestBid) {
460 if (IsPrintForDebug)
461 System.out.println("***********EndNegotiation2");
462 return new EndNegotiation(agentID);
463 } else {
464 return new Offer(agentID, this.maxUtilityBid);
465 }
466 }
467 double utilOflastBidOfOpponent = utilitySpace.getUtility(lastBidOfOpponent);
468 double utilOfBid = utilitySpace.getUtility(bid);
469 if (utilitySpace.getReservationValue() > utilOfBid
470 && utilitySpace.getReservationValue() > utilOflastBidOfOpponent) {
471 if (IsPrintForDebug)
472 System.out.println("***********EndNegotiation3");
473 return new EndNegotiation(agentID);
474 } else if (utilOflastBidOfOpponent > utilOfBid) {
475 return new Accept(agentID, lastBidOfOpponent);
476 } else {
477 return new Offer(agentID, bid);
478 }
479 } catch (Exception e) {
480 System.out.println("LastMomentStrategy: Exception in ChooseAction:" + e.getMessage());
481 e.printStackTrace();
482 return ExceptionStrategy();
483 }
484 }
485
486 public Action chooseAction() {
487 try {
488
489 System.out.println("Domain size: " + utilitySpace.getDomain().getNumberOfPossibleBids());
490 boolean highReservation = (utilitySpace.getReservationValue() >= 0.75);// (minUtility+0.75*UtilityRange));
491 boolean midReservation = (utilitySpace.getReservationValue() < 0.75
492 && utilitySpace.getReservationValue() > 0.25);// (minUtility+0.75*UtilityRange)
493 // &&
494 // utilitySpace.getReservationValue()
495 // >=
496 // (minUtility+0.375*UtilityRange));
497 boolean lowReservation = (utilitySpace.getReservationValue() <= 0.25);// (minUtility+0.375*UtilityRange));
498
499 boolean highDiscount = (utilitySpace.getDiscountFactor() >= 0.75);
500 boolean midDiscount = (utilitySpace.getDiscountFactor() < 0.75 && utilitySpace.getDiscountFactor() > 0.25);
501 boolean lowDiscount = (utilitySpace.getDiscountFactor() <= 0.25);
502 try {
503 double currentTime = timeline.getTime() / (theTimeIAmReadyToInvestInNegotiation / 1.2);
504 // System.out.println("currentTime: " + currentTime);
505 double MyNextOfferedUtility = utilitySpace.getUtility(SortedBid.get(countBid).getBid());
506
507 if (highDiscount) {
508 return LastMomentStrategy(0.75, timeline.getTime());
509 } else if (highReservation) {
510 return new EndNegotiation(agentID);
511 } else if (lowReservation) {
512 return FastStrategy();
513 } else if (midDiscount && lowReservation) {
514 return OneStepStrategy();
515 } else {
516 if (currentTime <= 0.25 && MyNextOfferedUtility >= 0.95) {
517 return FastStrategyWithoutEndNegotiation(0.95);
518 } else if (currentTime <= 0.5 && MyNextOfferedUtility >= 0.85) {
519 return FastLastMomentStrategyWithoutEndNegotiation(1, 0.85, currentTime * 2);
520 } else if (currentTime > 0.75) {
521 return LastMomentStrategy(0.65, currentTime);
522 } else {
523 return OneStepStrategy();
524 }
525 }
526
527 } catch (Exception e) {
528 System.out.println("Exception in ChooseAction:" + e.getMessage());
529 return ExceptionStrategy(); // terminate if anything goes wrong.
530 }
531 } catch (Exception e) {
532 // TODO Auto-generated catch block
533 e.printStackTrace();
534 return ExceptionStrategy();
535 }
536 }
537
538 public String getName() {
539 return getClass().getSimpleName();
540 }
541}
Note: See TracBrowser for help on using the repository browser.