source: src/main/java/negotiator/boaframework/offeringstrategy/anac2012/CUHKAgent_Offering.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: 26.2 KB
Line 
1package negotiator.boaframework.offeringstrategy.anac2012;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.List;
6import java.util.Map;
7import java.util.Random;
8
9import agents.anac.y2012.CUHKAgent.OwnBidHistory;
10import genius.core.Bid;
11import genius.core.BidIterator;
12import genius.core.bidding.BidDetails;
13import genius.core.boaframework.NegotiationSession;
14import genius.core.boaframework.NoModel;
15import genius.core.boaframework.OMStrategy;
16import genius.core.boaframework.OfferingStrategy;
17import genius.core.boaframework.OpponentModel;
18import genius.core.issue.Issue;
19import genius.core.issue.IssueDiscrete;
20import genius.core.issue.IssueInteger;
21import genius.core.issue.IssueReal;
22import genius.core.issue.Value;
23import genius.core.issue.ValueInteger;
24import genius.core.issue.ValueReal;
25import genius.core.utility.AdditiveUtilitySpace;
26import negotiator.boaframework.offeringstrategy.anac2012.CUHKAgent.OpponentBidHistory;
27import negotiator.boaframework.opponentmodel.DefaultModel;
28
29/**
30 * This is the decoupled Bidding Strategy of CUHKAgent Note that the Opponent
31 * Model was not decoupled and thus is integrated into this strategy As well due
32 * to the strong coupling with the AC there is not AC_CUHKAgent and thus it is
33 * not proven equivalent with the original This is the offering and does not
34 * simulate the stopping situation of CUHKAgent
35 *
36 * The AC and reservation value code was removed
37 *
38 * @author Alex Dirkzwager
39 */
40
41public class CUHKAgent_Offering extends OfferingStrategy {
42
43 private double totalTime;
44 private double maximumOfBid;
45 private OwnBidHistory ownBidHistory;
46 private OpponentBidHistory opponentBidHistory;
47 private double minimumUtilityThreshold;
48 private double utilitythreshold;
49 private double MaximumUtility;
50 private double timeLeftBefore;
51 private double timeLeftAfter;
52 private double maximumTimeOfOpponent;
53 private double maximumTimeOfOwn;
54 private double discountingFactor;
55 private double concedeToDiscountingFactor;
56 private double concedeToDiscountingFactor_original;
57 private double minConcedeToDiscountingFactor;
58 private ArrayList<ArrayList<Bid>> bidsBetweenUtility;
59 private boolean concedeToOpponent;
60 private boolean toughAgent; // if we propose a bid that was proposed by the
61 // opponnet, then it should be accepted.
62 private double alpha1;// the larger alpha is, the more tough the agent is.
63 private Bid bid_maximum_utility;// the bid with the maximum utility over the
64 // utility space.
65 private double reservationValue;
66 private Random random;
67
68 public CUHKAgent_Offering() {
69 }
70
71 public CUHKAgent_Offering(NegotiationSession negoSession, OpponentModel model, OMStrategy oms) throws Exception {
72 init(negoSession, model, oms, null);
73 }
74
75 /**
76 * Init required for the Decoupled Framework.
77 */
78 @Override
79 public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
80 Map<String, Double> parameters) throws Exception {
81 random = new Random();
82 if (model instanceof DefaultModel) {
83 model = new NoModel();
84 }
85 this.opponentModel = model;
86 negotiationSession = negoSession;
87 maximumOfBid = negoSession.getUtilitySpace().getDomain().getNumberOfPossibleBids();
88 ownBidHistory = new OwnBidHistory();
89 opponentBidHistory = new OpponentBidHistory(opponentModel, oms,
90 (AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
91 bidsBetweenUtility = new ArrayList<ArrayList<Bid>>();
92
93 this.bid_maximum_utility = negoSession.getUtilitySpace().getMaxUtilityBid();
94 this.utilitythreshold = negoSession.getUtilitySpace().getUtility(bid_maximum_utility); // initial
95 // utility
96 // threshold
97 this.MaximumUtility = this.utilitythreshold;
98 this.timeLeftAfter = 0;
99 this.timeLeftBefore = 0;
100 this.totalTime = negoSession.getTimeline().getTotalTime();
101 this.maximumTimeOfOpponent = 0;
102 this.maximumTimeOfOwn = 0;
103 this.minConcedeToDiscountingFactor = 0.08;// 0.1;
104 this.discountingFactor = 1;
105 if (negoSession.getUtilitySpace().getDiscountFactor() <= 1D
106 && negoSession.getUtilitySpace().getDiscountFactor() > 0D) {
107 this.discountingFactor = negoSession.getUtilitySpace().getDiscountFactor();
108 }
109 this.chooseUtilityThreshold();
110 this.calculateBidsBetweenUtility();
111 this.chooseConcedeToDiscountingDegree();
112 this.opponentBidHistory.initializeDataStructures(negoSession.getUtilitySpace().getDomain());
113 this.timeLeftAfter = negoSession.getTimeline().getCurrentTime();
114 this.concedeToOpponent = false;
115 this.toughAgent = false;
116 this.alpha1 = 2;
117 this.reservationValue = 0;
118 if (negoSession.getUtilitySpace().getReservationValue() > 0) {
119 this.reservationValue = negoSession.getUtilitySpace().getReservationValue();
120 }
121 }
122
123 @Override
124 public BidDetails determineOpeningBid() {
125 return determineNextBid();
126 }
127
128 @Override
129 public BidDetails determineNextBid() {
130 BidDetails action = null;
131 try {
132
133 this.timeLeftBefore = negotiationSession.getTimeline().getCurrentTime();
134 BidDetails bid = null;
135 // we propose first and propose the bid with maximum utility
136 if (negotiationSession.getOpponentBidHistory().isEmpty()) {
137 bid = negotiationSession.getMaxBidinDomain();
138 action = bid;
139 } else {
140 // receiveMessage opponent model first
141 this.opponentBidHistory.updateOpponentModel(negotiationSession.getOpponentBidHistory().getLastBid(),
142 negotiationSession.getUtilitySpace().getDomain(),
143 (AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
144 this.updateConcedeDegree();
145 // receiveMessage the estimation
146 if (negotiationSession.getOwnBidHistory().size() == 0) {
147 // bid = utilitySpace.getMaxUtilityBid();
148 bid = negotiationSession.getMaxBidinDomain();
149 action = bid;
150 } else {// other conditions
151 if (estimateRoundLeft(true) > 10) {// still have some rounds
152 // left to further
153 // negotiate (the major
154 // negotiation period)
155 bid = BidToOffer();
156 /** REMOVED AC */
157 // Boolean IsAccept =
158 // AcceptOpponentOffer(negotiationSession.getOpponentBidHistory().getLastBid(),
159 // bid.getBid());
160 // Boolean IsTerminate =
161 // TerminateCurrentNegotiation(bid.getBid());
162
163 // if(!IsAccept && !IsTerminate){
164 // we expect that the negotiation is over once we select
165 // a bid from the opponent's history.
166 if (this.concedeToOpponent == true) {
167 // bid =
168 // opponentBidHistory.chooseBestFromHistory(this.utilitySpace);
169 Bid possibleBid = opponentBidHistory.getBestBidInHistory();
170 action = new BidDetails(possibleBid,
171 negotiationSession.getUtilitySpace().getUtility(possibleBid));
172 this.toughAgent = true;
173 this.concedeToOpponent = false;
174 } else {
175 action = bid;
176 this.toughAgent = false;
177 }
178 // }
179 } else {// this is the last chance and we concede by
180 // providing the opponent the best offer he ever
181 // proposed to us
182 // in this case, it corresponds to an opponent whose
183 // decision time is short
184 if (negotiationSession.getTimeline().getTime() > 0.9985 && estimateRoundLeft(true) < 5) {
185 // bid =
186 // opponentBidHistory.chooseBestFromHistory(this.utilitySpace);
187 Bid bid1 = opponentBidHistory.getBestBidInHistory();
188 bid = new BidDetails(bid1, negotiationSession.getUtilitySpace().getUtility(bid1));
189
190 // this is specially designed to avoid that we got
191 // very low utility by searching between an
192 // acceptable range (when the domain is small)
193 if (negotiationSession.getUtilitySpace().getUtility(bid.getBid()) < 0.85) {
194 List<Bid> candidateBids = this.getBidsBetweenUtility(this.MaximumUtility - 0.15,
195 this.MaximumUtility - 0.02);
196 // if the candidate bids do not exsit and also
197 // the deadline is approaching in next round, we
198 // concede.
199 // if (candidateBids.size() == 1 &&
200 // timeline.getTime()>0.9998) {
201 // we have no chance to make a new proposal
202 // before the deadline
203 if (this.estimateRoundLeft(true) < 2) {
204 Bid bid2 = opponentBidHistory.getBestBidInHistory();
205 bid = new BidDetails(bid2, negotiationSession.getUtilitySpace().getUtility(bid2));
206 } else {
207 Bid possibleBid = opponentBidHistory.ChooseBid(candidateBids,
208 negotiationSession.getUtilitySpace().getDomain());
209 bid = new BidDetails(possibleBid,
210 negotiationSession.getUtilitySpace().getUtility(possibleBid));
211 }
212 }
213
214 /**
215 * REMOVED AC Boolean IsAccept =
216 * AcceptOpponentOffer(
217 * negotiationSession.getOpponentBidHistory
218 * ().getLastBid(), bid.getBid()); Boolean
219 * IsTerminate =
220 * TerminateCurrentNegotiation(bid.getBid());
221 * if(!IsAccept && !IsTerminate){ if
222 * (this.toughAgent == false) { action = bid;
223 * //this.toughAgent = true; } }
224 */
225 action = bid;
226 // in this case, it corresponds to the situation
227 // that we encounter an opponent who needs more
228 // computation to make decision each round
229 } else {// we still have some time to negotiate,
230 // and be tough by sticking with the lowest one in
231 // previous offer history.
232 // we also have to make the decisin fast to avoid
233 // reaching the deadline before the decision is made
234 // bid = ownBidHistory.GetMinBidInHistory();//reduce
235 // the computational cost
236 bid = BidToOffer();
237
238 /** REMOVED AC */
239 // Boolean IsAccept =
240 // AcceptOpponentOffer(negotiationSession.getOpponentBidHistory().getLastBid(),bid.getBid());
241 // Boolean IsTerminate =
242 // TerminateCurrentNegotiation(bid.getBid());
243 // if(!IsAccept && !IsTerminate){
244 action = bid;
245 // }
246 }
247 }
248 }
249 }
250
251 this.ownBidHistory.addBid(bid.getBid(), (AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
252 this.timeLeftAfter = negotiationSession.getTimeline().getCurrentTime();
253 this.estimateRoundLeft(false);// receiveMessage the estimation
254 } catch (Exception e) {
255 System.out.println("Exception in ChooseAction:" + e.getMessage());
256 System.out.println(estimateRoundLeft(false));
257 }
258
259 return action;
260 }
261
262 /*
263 * principle: randomization over those candidate bids to let the opponent
264 * have a better model of my utility profile return the bid to be offered in
265 * the next round
266 */
267 private BidDetails BidToOffer() {
268 Bid bidReturned = null;
269 double decreasingAmount_1 = 0.05;
270 double decreasingAmount_2 = 0.25;
271 try {
272 double maximumOfBid = this.MaximumUtility;// utilitySpace.getUtility(utilitySpace.getMaxUtilityBid());
273 double minimumOfBid;
274 // used when the domain is very large.
275 // make concession when the domin is large
276 if (this.discountingFactor == 1 && this.maximumOfBid > 3000) {
277 minimumOfBid = this.MaximumUtility - decreasingAmount_1;
278 // make further concession when the deadline is approaching and
279 // the domain is large
280 if (this.discountingFactor > 1 - decreasingAmount_2 && this.maximumOfBid > 10000
281 && negotiationSession.getTimeline().getTime() >= 0.98) {
282 minimumOfBid = this.MaximumUtility - decreasingAmount_2;
283 }
284 if (this.utilitythreshold > minimumOfBid) {
285 this.utilitythreshold = minimumOfBid;
286 }
287 } /*
288 * else if (this.discountingFactor > 1 - decreasingAmount_3 &&
289 * this.maximumOfBid >= 100000 && this.maximumOfBid < 300000) {
290 * minimumOfBid = this.MaximumUtility - decreasingAmount_3; }
291 * else if (this.discountingFactor > 1 - decreasingAmount_4 &&
292 * this.maximumOfBid >= 300000) { minimumOfBid =
293 * this.MaximumUtility - decreasingAmount_4; }
294 */else {// the general case
295 if (negotiationSession.getTimeline().getTime() <= this.concedeToDiscountingFactor) {
296 double minThreshold = (maximumOfBid * this.discountingFactor)
297 / Math.pow(this.discountingFactor, this.concedeToDiscountingFactor);
298 this.utilitythreshold = maximumOfBid - (maximumOfBid - minThreshold) * Math.pow(
299 (negotiationSession.getTimeline().getTime() / this.concedeToDiscountingFactor), alpha1);
300 } else {
301 this.utilitythreshold = (maximumOfBid * this.discountingFactor)
302 / Math.pow(this.discountingFactor, negotiationSession.getTimeline().getTime());
303 }
304 minimumOfBid = this.utilitythreshold;
305 }
306
307 /*
308 * if(minimumOfBid < 0.9 && this.guessOpponentType == false){
309 * if(this.opponentBidHistory.getSize() <= 2){ this.opponentType =
310 * 1;//tough opponent alpha1 = 2; } else{ this.opponentType = 0;
311 * alpha1 = 4; } this.guessOpponentType = true;//we only guess the
312 * opponent type once here System.out.println("we guess the opponent
313 * type is "+this.opponentType); }
314 */
315 // choose from the opponent bid history first to reduce calculation
316 // time
317 Bid bestBidOfferedByOpponent = opponentBidHistory.getBestBidInHistory();
318 if (negotiationSession.getUtilitySpace().getUtility(bestBidOfferedByOpponent) >= this.utilitythreshold
319 || negotiationSession.getUtilitySpace().getUtility(bestBidOfferedByOpponent) >= minimumOfBid) {
320 return new BidDetails(bestBidOfferedByOpponent,
321 negotiationSession.getUtilitySpace().getUtility(bestBidOfferedByOpponent));
322 }
323
324 List<Bid> candidateBids = this.getBidsBetweenUtility(minimumOfBid, maximumOfBid);
325 bidReturned = opponentBidHistory.ChooseBid(candidateBids,
326 this.negotiationSession.getUtilitySpace().getDomain());
327 if (bidReturned == null) {
328 System.out.println("no bid is searched warning");
329 bidReturned = this.negotiationSession.getUtilitySpace().getMaxUtilityBid();
330 }
331 } catch (Exception e) {
332 System.out.println(e.getMessage() + "exception in method BidToOffer");
333 }
334 try {
335 return new BidDetails(bidReturned, negotiationSession.getUtilitySpace().getUtility(bidReturned));
336 } catch (Exception e) {
337 e.printStackTrace();
338 }
339 return null;
340 }
341
342 /**
343 * REMOVED AC private boolean AcceptOpponentOffer(Bid opponentBid, Bid
344 * ownBid) { double currentUtility = 0; double nextRoundUtility = 0; double
345 * maximumUtility = 0; this.concedeToOpponent = false; try { currentUtility
346 * = this.negotiationSession.getUtilitySpace().getUtility(opponentBid);
347 * maximumUtility = this.MaximumUtility; } catch (Exception e) {
348 * System.out.println(e.getMessage() + "Exception in method
349 * AcceptOpponentOffer part 1"); } try { nextRoundUtility =
350 * this.negotiationSession.getUtilitySpace().getUtility(ownBid); } catch
351 * (Exception e) { System.out.println(e.getMessage() + "Exception in method
352 * AcceptOpponentOffer part 2"); }
353 * //System.out.println(this.utilitythreshold +"at time "+
354 * timeline.getTime()); if (currentUtility >= this.utilitythreshold ||
355 * currentUtility >= nextRoundUtility) { return true; } else { //if the
356 * current utility with discount is larger than the predicted maximum
357 * utility with discount //then accept it. double predictMaximumUtility =
358 * maximumUtility * this.discountingFactor; //double currentMaximumUtility =
359 * this.utilitySpace.getUtilityWithDiscount(opponentBidHistory.
360 * chooseBestFromHistory(utilitySpace), timeline); double
361 * currentMaximumUtility =
362 * this.negotiationSession.getUtilitySpace().getUtilityWithDiscount
363 * (opponentBidHistory.getBestBidInHistory(),
364 * negotiationSession.getTimeline()); if (currentMaximumUtility >
365 * predictMaximumUtility && negotiationSession.getTimeline().getTime() >
366 * this.concedeToDiscountingFactor) { try { //if the current offer is
367 * approximately as good as the best one in the history, then accept it. if
368 * (negotiationSession.getUtilitySpace().getUtility(opponentBid) >=
369 * negotiationSession
370 * .getUtilitySpace().getUtility(opponentBidHistory.getBestBidInHistory()) -
371 * 0.01) { System.out.println("he offered me " + currentMaximumUtility + "
372 * we predict we can get at most " + predictMaximumUtility + "we concede now
373 * to avoid lower payoff due to conflict"); return true; } else {
374 * this.concedeToOpponent = true; return false; } } catch (Exception e) {
375 * System.out.println("exception in Method AcceptOpponentOffer"); return
376 * true; } //retrieve the opponent's biding history and utilize it } else if
377 * (currentMaximumUtility > this.utilitythreshold *
378 * Math.pow(this.discountingFactor,
379 * negotiationSession.getTimeline().getTime())) { try { //if the current
380 * offer is approximately as good as the best one in the history, then
381 * accept it. if
382 * (negotiationSession.getUtilitySpace().getUtility(opponentBid) >=
383 * negotiationSession
384 * .getUtilitySpace().getUtility(opponentBidHistory.getBestBidInHistory()) -
385 * 0.01) { return true; } else { System.out.println("test" +
386 * negotiationSession.getUtilitySpace().getUtility(opponentBid) +
387 * this.utilitythreshold); this.concedeToOpponent = true; return false; } }
388 * catch (Exception e) { System.out.println("exception in Method
389 * AcceptOpponentOffer"); return true; } } else { return false; } } }
390 */
391
392 /**
393 * REMOVED AC private boolean TerminateCurrentNegotiation(Bid ownBid) {
394 * double currentUtility = 0; double nextRoundUtility = 0; double
395 * maximumUtility = 0; this.concedeToOpponent = false; try { currentUtility
396 * = this.reservationValue; nextRoundUtility =
397 * this.negotiationSession.getUtilitySpace().getUtility(ownBid);
398 * maximumUtility = this.MaximumUtility; } catch (Exception e) {
399 * System.out.println(e.getMessage() + "Exception in method
400 * TerminateCurrentNegotiation part 1"); }
401 *
402 * if (currentUtility >= this.utilitythreshold || currentUtility >=
403 * nextRoundUtility) { return true; } else { //if the current reseravation
404 * utility with discount is larger than the predicted maximum utility with
405 * discount //then terminate the negotiation. double predictMaximumUtility =
406 * maximumUtility * this.discountingFactor; double currentMaximumUtility =
407 * this
408 * .negotiationSession.getUtilitySpace().getReservationValueWithDiscount(
409 * negotiationSession.getTimeline()); // System.out.println("the current
410 * reserved value is "+ this.reservationValue+" after discounting is
411 * "+currentMaximumUtility); if (currentMaximumUtility >
412 * predictMaximumUtility && negotiationSession.getTimeline().getTime() >
413 * this.concedeToDiscountingFactor) { return true; } else { return false; }
414 * } }
415 */
416
417 /*
418 * estimate the number of rounds left before reaching the deadline @param
419 * opponent @return
420 */
421
422 private int estimateRoundLeft(boolean opponent) {
423 double round;
424 if (opponent == true) {
425 if (this.timeLeftBefore - this.timeLeftAfter > this.maximumTimeOfOpponent) {
426 this.maximumTimeOfOpponent = this.timeLeftBefore - this.timeLeftAfter;
427 }
428 } else {
429 if (this.timeLeftAfter - this.timeLeftBefore > this.maximumTimeOfOwn) {
430 this.maximumTimeOfOwn = this.timeLeftAfter - this.timeLeftBefore;
431 }
432 }
433 if (this.maximumTimeOfOpponent + this.maximumTimeOfOwn == 0) {
434 System.out.println("divided by zero exception");
435 }
436 round = (this.totalTime - negotiationSession.getTimeline().getCurrentTime())
437 / (this.maximumTimeOfOpponent + this.maximumTimeOfOwn);
438 // System.out.println("current time is " + timeline.getElapsedSeconds()
439 // + "---" + round + "----" + this.maximumTimeOfOpponent);
440 return ((int) (round));
441 }
442
443 /*
444 * pre-processing to save the computational time each round
445 */
446 private void calculateBidsBetweenUtility() {
447 BidIterator myBidIterator = new BidIterator(this.negotiationSession.getUtilitySpace().getDomain());
448
449 try {
450 // double maximumUtility =
451 // utilitySpace.getUtility(utilitySpace.getMaxUtilityBid());
452 double maximumUtility = this.MaximumUtility;
453 double minUtility = this.minimumUtilityThreshold;
454 int maximumRounds = (int) ((maximumUtility - minUtility) / 0.01);
455 // initalization for each arraylist storing the bids between each
456 // range
457 for (int i = 0; i < maximumRounds; i++) {
458 ArrayList<Bid> BidList = new ArrayList<Bid>();
459 // BidList.add(this.bid_maximum_utility);
460 this.bidsBetweenUtility.add(BidList);
461 }
462 this.bidsBetweenUtility.get(maximumRounds - 1).add(this.bid_maximum_utility);
463 // note that here we may need to use some trick to reduce the
464 // computation cost (to be checked later);
465 // add those bids in each range into the corresponding arraylist
466 int limits = 0;
467 if (this.maximumOfBid < 20000) {
468 while (myBidIterator.hasNext()) {
469 Bid b = myBidIterator.next();
470 for (int i = 0; i < maximumRounds; i++) {
471 if (negotiationSession.getUtilitySpace().getUtility(b) <= (i + 1) * 0.01 + minUtility
472 && negotiationSession.getUtilitySpace().getUtility(b) >= i * 0.01 + minUtility) {
473 this.bidsBetweenUtility.get(i).add(b);
474 break;
475 }
476 }
477 // limits++;
478 }
479 } else {
480 while (limits <= 20000) {
481 Bid b = this.RandomSearchBid();
482 for (int i = 0; i < maximumRounds; i++) {
483 if (negotiationSession.getUtilitySpace().getUtility(b) <= (i + 1) * 0.01 + minUtility
484 && negotiationSession.getUtilitySpace().getUtility(b) >= i * 0.01 + minUtility) {
485 this.bidsBetweenUtility.get(i).add(b);
486 break;
487 }
488 }
489 limits++;
490 }
491 }
492 } catch (Exception e) {
493 System.out.println("Exception in calculateBidsBetweenUtility()");
494 e.printStackTrace();
495 }
496 }
497
498 private Bid RandomSearchBid() throws Exception {
499 HashMap<Integer, Value> values = new HashMap<Integer, Value>();
500 List<Issue> issues = negotiationSession.getUtilitySpace().getDomain().getIssues();
501 Bid bid = null;
502
503 for (Issue lIssue : issues) {
504 switch (lIssue.getType()) {
505 case DISCRETE:
506 IssueDiscrete lIssueDiscrete = (IssueDiscrete) lIssue;
507 int optionIndex = random.nextInt(lIssueDiscrete.getNumberOfValues());
508 values.put(lIssue.getNumber(), lIssueDiscrete.getValue(optionIndex));
509 break;
510 case REAL:
511 IssueReal lIssueReal = (IssueReal) lIssue;
512 int optionInd = random.nextInt(lIssueReal.getNumberOfDiscretizationSteps() - 1);
513 values.put(lIssueReal.getNumber(),
514 new ValueReal(lIssueReal.getLowerBound()
515 + (lIssueReal.getUpperBound() - lIssueReal.getLowerBound()) * (double) (optionInd)
516 / (double) (lIssueReal.getNumberOfDiscretizationSteps())));
517 break;
518 case INTEGER:
519 IssueInteger lIssueInteger = (IssueInteger) lIssue;
520 int optionIndex2 = lIssueInteger.getLowerBound()
521 + random.nextInt(lIssueInteger.getUpperBound() - lIssueInteger.getLowerBound());
522 values.put(lIssueInteger.getNumber(), new ValueInteger(optionIndex2));
523 break;
524 default:
525 throw new Exception("issue type " + lIssue.getType() + " not supported");
526 }
527 }
528 bid = new Bid(negotiationSession.getUtilitySpace().getDomain(), values);
529 return bid;
530 }
531
532 /*
533 * Get all the bids within a given utility range.
534 */
535 private List<Bid> getBidsBetweenUtility(double lowerBound, double upperBound) {
536 List<Bid> bidsInRange = new ArrayList<Bid>();
537 try {
538 int range = (int) ((upperBound - this.minimumUtilityThreshold) / 0.01);
539 int initial = (int) ((lowerBound - this.minimumUtilityThreshold) / 0.01);
540 // System.out.println(range+"---"+initial);
541 for (int i = initial; i < range; i++) {
542 bidsInRange.addAll(this.bidsBetweenUtility.get(i));
543 }
544 if (bidsInRange.isEmpty()) {
545 bidsInRange.add(this.bid_maximum_utility);
546 }
547 } catch (Exception e) {
548 System.out.println("Exception in getBidsBetweenUtility");
549 e.printStackTrace();
550 }
551 return bidsInRange;
552 }
553
554 /*
555 * determine the lowest bound of our utility threshold based on the
556 * discounting factor we think that the minimum utility threshold should not
557 * be related with the discounting degree.
558 */
559 private void chooseUtilityThreshold() {
560 double discountingFactor = this.discountingFactor;
561 if (discountingFactor >= 0.9) {
562 this.minimumUtilityThreshold = 0;// this.MaximumUtility - 0.09;
563 } else {
564 // this.minimumUtilityThreshold = 0.85;
565 this.minimumUtilityThreshold = 0;// this.MaximumUtility - 0.09;
566 }
567 }
568
569 /*
570 * determine concede-to-time degree based on the discounting factor.
571 */
572
573 private void chooseConcedeToDiscountingDegree() {
574 double alpha = 0;
575 double beta = 1.5;// 1.3;//this value controls the rate at which the
576 // agent concedes to the discouting factor.
577 // the larger beta is, the more the agent makes concesions.
578 // if (utilitySpace.getDomain().getNumberOfPossibleBids() > 100) {
579 /*
580 * if (this.maximumOfBid > 100) { beta = 2;//1.3; } else { beta = 1.5; }
581 */
582 // the vaule of beta depends on the discounting factor (trade-off
583 // between concede-to-time degree and discouting factor)
584 if (this.discountingFactor > 0.75) {
585 beta = 1.8;
586 } else if (this.discountingFactor > 0.5) {
587 beta = 1.5;
588 } else {
589 beta = 1.2;
590 }
591 alpha = Math.pow(this.discountingFactor, beta);
592 this.concedeToDiscountingFactor = this.minConcedeToDiscountingFactor
593 + (1 - this.minConcedeToDiscountingFactor) * alpha;
594 this.concedeToDiscountingFactor_original = this.concedeToDiscountingFactor;
595 System.out.println("concedeToDiscountingFactor is " + this.concedeToDiscountingFactor + "current time is "
596 + negotiationSession.getTimeline().getTime());
597 }
598
599 /*
600 * receiveMessage the concede-to-time degree based on the predicted
601 * toughness degree of the opponent
602 */
603
604 private void updateConcedeDegree() {
605 double gama = 10;
606 double weight = 0.1;
607 double opponnetToughnessDegree = this.opponentBidHistory.getConcessionDegree();
608 // this.concedeToDiscountingFactor =
609 // this.concedeToDiscountingFactor_original * (1 +
610 // opponnetToughnessDegree);
611 this.concedeToDiscountingFactor = this.concedeToDiscountingFactor_original
612 + weight * (1 - this.concedeToDiscountingFactor_original) * Math.pow(opponnetToughnessDegree, gama);
613 if (this.concedeToDiscountingFactor >= 1) {
614 this.concedeToDiscountingFactor = 1;
615 }
616 // System.out.println("concedeToDiscountingFactor is " +
617 // this.concedeToDiscountingFactor + "current time is " +
618 // timeline.getTime() + "original concedetodiscoutingfactor is " +
619 // this.concedeToDiscountingFactor_original);
620 }
621
622 @Override
623 public String getName() {
624 return "2012 - CUHKAgent";
625 }
626
627}
Note: See TracBrowser for help on using the repository browser.