source: src/main/java/negotiator/boaframework/acceptanceconditions/anac2012/AC_CUHKAgent.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: 24.4 KB
Line 
1package negotiator.boaframework.acceptanceconditions.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.OpponentBidHistory;
10import genius.core.Bid;
11import genius.core.BidIterator;
12import genius.core.bidding.BidDetails;
13import genius.core.boaframework.AcceptanceStrategy;
14import genius.core.boaframework.Actions;
15import genius.core.boaframework.NegotiationSession;
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.sharedagentstate.anac2012.CUHKAgentSAS;
27
28/**
29 * This is the decoupled Acceptance Condition from CUHKAgent (ANAC2012). The
30 * code was taken from the ANAC2012 CUHKAgent and adapted to work within the BOA
31 * framework.
32 *
33 * Decoupling Negotiating Agents to Explore the Space of Negotiation Strategies
34 * T. Baarslag, K. Hindriks, M. Hendrikx, A. Dirkzwager, C.M. Jonker
35 *
36 * @author Alex Dirkzwager
37 * @version 31/10/12
38 */
39public class AC_CUHKAgent extends AcceptanceStrategy {
40
41 private boolean activeHelper = false;
42 private double reservationValue;
43 private AdditiveUtilitySpace utilitySpace;
44 private double discountingFactor;
45 private double previousTime;
46 private Actions nextAction;
47 private BidDetails opponentBid = null;
48 private double maximumOfBid;
49 private OpponentBidHistory opponentBidHistory;
50 private double minimumUtilityThreshold;
51 private double concedeToDiscountingFactor_original;
52 private double minConcedeToDiscountingFactor;
53 private ArrayList<ArrayList<Bid>> bidsBetweenUtility;
54 private Bid bid_maximum_utility;// the bid with the maximum utility over the
55 // utility space.
56
57 private Random random;
58 private final boolean TEST_EQUIVALENCE = true;
59
60 public AC_CUHKAgent() {
61 }
62
63 public AC_CUHKAgent(NegotiationSession negoSession, OfferingStrategy strat) throws Exception {
64 initializeAgent(negoSession, strat);
65 }
66
67 @Override
68 public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
69 Map<String, Double> parameters) throws Exception {
70 initializeAgent(negoSession, strat);
71 }
72
73 public void initializeAgent(NegotiationSession negotiationSession, OfferingStrategy os) throws Exception {
74 this.negotiationSession = negotiationSession;
75 this.offeringStrategy = os;
76
77 previousTime = 0;
78
79 // checking if offeringStrategy SAS is a BRAMAgentSAS
80 if (offeringStrategy.getHelper() == null || (!offeringStrategy.getHelper().getName().equals("CUHKAgent"))) {
81 helper = new CUHKAgentSAS(negotiationSession);
82 activeHelper = true;
83 } else {
84 helper = (CUHKAgentSAS) offeringStrategy.getHelper();
85 }
86 utilitySpace = (AdditiveUtilitySpace) negotiationSession.getUtilitySpace();
87 this.reservationValue = 0;
88
89 if (utilitySpace.getReservationValue() > 0) {
90 this.reservationValue = utilitySpace.getReservationValue();
91 }
92
93 this.discountingFactor = 1;
94 if (utilitySpace.getDiscountFactor() <= 1D && utilitySpace.getDiscountFactor() > 0D) {
95 this.discountingFactor = utilitySpace.getDiscountFactor();
96 }
97
98 if (activeHelper) {
99 try {
100 maximumOfBid = this.utilitySpace.getDomain().getNumberOfPossibleBids();
101 opponentBidHistory = new OpponentBidHistory();
102 bidsBetweenUtility = new ArrayList<ArrayList<Bid>>();
103 this.bid_maximum_utility = utilitySpace.getMaxUtilityBid();
104 this.minConcedeToDiscountingFactor = 0.08;// 0.1;
105 this.chooseUtilityThreshold();
106 this.calculateBidsBetweenUtility();
107 this.chooseConcedeToDiscountingDegree();
108
109 this.opponentBidHistory.initializeDataStructures(utilitySpace.getDomain());
110 ((CUHKAgentSAS) helper).setTimeLeftAfter(negotiationSession.getTimeline().getCurrentTime());
111
112 if (TEST_EQUIVALENCE) {
113 random = new Random(100);
114 } else {
115 random = new Random();
116 }
117
118 } catch (Exception e) {
119 System.out.println("initialization error" + e.getMessage());
120 }
121 }
122 }
123
124 @Override
125 public Actions determineAcceptability() {
126 if (activeHelper)
127 nextAction = activeDetermineAcceptability();
128 else
129 nextAction = regularDetermineAcceptability();
130 return nextAction;
131 }
132
133 private Actions activeDetermineAcceptability() {
134 nextAction = Actions.Reject;
135 try {
136 double currentTime = negotiationSession.getTime();
137 ((CUHKAgentSAS) helper).addTimeInterval(currentTime - previousTime);
138 previousTime = currentTime;
139
140 // System.out.println("i propose " + debug + " bid at time " +
141 // timeline.getTime());
142 ((CUHKAgentSAS) helper).setTimeLeftBefore(negotiationSession.getTimeline().getCurrentTime());
143 if (negotiationSession.getOpponentBidHistory().size() >= 1) {// the
144 // opponent
145 // propose
146 // first
147 // and
148 // we
149 // response
150 // secondly
151 opponentBid = negotiationSession.getOpponentBidHistory().getLastBidDetails();
152 // receiveMessage opponent model first
153 this.opponentBidHistory.updateOpponentModel(opponentBid.getBid(), utilitySpace.getDomain(),
154 this.utilitySpace);
155 this.updateConcedeDegree();
156 // receiveMessage the estimation
157 if (negotiationSession.getOwnBidHistory().isEmpty()) {
158 // bid = utilitySpace.getMaxUtilityBid();
159 } else {// other conditions
160 if (((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, true) > 10) {// still
161 // have
162 // some
163 // rounds
164 // left
165 // to
166 // further
167 // negotiate
168 // (the
169 // major
170 // negotiation
171 // period)
172
173 // System.out.println("Decoupled bid1: " + bid);
174 // we expect that the negotiation is over once we select
175 // a bid from the opponent's history.
176 System.out.println("test2: " + ((CUHKAgentSAS) helper).isConcedeToOpponent());
177
178 if (((CUHKAgentSAS) helper).isConcedeToOpponent() == true) {
179
180 // System.out.println("we offer the best bid in the
181 // history and the opponent should accept it");
182 ((CUHKAgentSAS) helper).setToughAgent(true);
183 ((CUHKAgentSAS) helper).setConcedeToOpponent(false);
184 } else {
185 ((CUHKAgentSAS) helper).setToughAgent(false);
186 // System.out.println("i propose " + debug +
187 // " bid at time " + timeline.getTime());
188 }
189
190 } else {// this is the last chance and we concede by
191 // providing the opponent the best offer he ever
192 // proposed to us
193 // in this case, it corresponds to an opponent whose
194 // decision time is short
195 if (negotiationSession.getTimeline().getTime() > 0.9985
196 && ((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, true) < 5) {
197 // bid =
198 // opponentBidHistory.chooseBestFromHistory(this.utilitySpace);
199 // this is specially designed to avoid that we got
200 // very low utility by searching between an
201 // acceptable range (when the domain is small)
202
203 if (offeringStrategy.getNextBid().getMyUndiscountedUtil() < 0.85) {
204
205 // if the candidate bids do not exsit and also
206 // the deadline is approaching in next round, we
207 // concede.
208 // if (candidateBids.size() == 1 &&
209 // timeline.getTime()>0.9998) {
210 // we have no chance to make a new proposal
211 // before the deadline
212 if (((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, true) < 2) {
213 // bid =
214 // opponentBidHistory.getBestBidInHistory();
215 // System.out.printlned bid3: " + bid);
216
217 // System.out.println("test I " +
218 // utilitySpace.getUtility(bid));
219 }
220
221 }
222
223 if (((CUHKAgentSAS) helper).isToughAgent() == true) {
224 nextAction = Actions.Accept;
225 System.out.println(
226 "the opponent is tough and the deadline is approching thus we accept the offer");
227 }
228
229 }
230 }
231 }
232 }
233 // System.out.println("i propose " + debug + " bid at time " +
234 // timeline.getTime());
235 ((CUHKAgentSAS) helper).setTimeLeftAfter(negotiationSession.getTimeline().getCurrentTime());
236 ((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, false);// receiveMessage
237 // the
238 // estimation
239 // System.out.println(this.utilitythreshold + "-***-----" +
240 // this.timeline.getElapsedSeconds());
241 } catch (Exception e) {
242 System.out.println("Exception in ChooseAction:" + e.getMessage());
243 System.out.println(((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, false));
244 // action = new Accept(getAgentID()); // accept if anything goes
245 // wrong.
246 // bidToOffer = new EndNegotiation(getAgentID()); //terminate if
247 // anything goes wrong.
248 }
249 return nextAction;
250 }
251
252 private Actions regularDetermineAcceptability() {
253 if (activeHelper) {
254 double currentTime = negotiationSession.getTime();
255 ((CUHKAgentSAS) helper).addTimeInterval(currentTime - previousTime);
256 previousTime = currentTime;
257
258 if (((CUHKAgentSAS) helper).estimateTheRoundsLeft(true, true) > 10) {// still
259 // have
260 // some
261 // rounds
262 // left
263 // to
264 // further
265 // negotiate
266 // (the
267 // major
268 // negotiation
269 // period)
270
271 if (((CUHKAgentSAS) helper).isConcedeToOpponent() == true) {
272 ((CUHKAgentSAS) helper).setToughAgent(true);
273 ((CUHKAgentSAS) helper).setConcedeToOpponent(false);
274 } else {
275 ((CUHKAgentSAS) helper).setToughAgent(false);
276 }
277 }
278 }
279
280 Bid opponentBid = negotiationSession.getOpponentBidHistory().getLastBid();
281 // Double check this corresponds with the original every time
282 Bid bid = offeringStrategy.getNextBid().getBid();
283 int roundsLeft;
284 if (activeHelper) {
285 roundsLeft = ((CUHKAgentSAS) helper).estimateTheRoundsLeft(true, true);
286 } else {
287 roundsLeft = ((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, true);
288 }
289 if (roundsLeft > 10) {// still have some rounds left to further
290 // negotiate (the major negotiation period)
291 Boolean IsAccept = AcceptOpponentOffer(opponentBid, bid);
292 Boolean IsTerminate = TerminateCurrentNegotiation(bid);
293
294 if (IsAccept && !IsTerminate) {
295 System.out.println("accept the offer");
296 return Actions.Accept;
297 } else if (IsTerminate && !IsAccept) {
298 System.out.println("we determine to terminate the negotiation");
299 return Actions.Break;
300 } else if (IsAccept && IsTerminate) {
301 try {
302 if (this.utilitySpace.getUtility(opponentBid) > this.reservationValue) {
303 System.out.println("we accept the offer RANDOMLY");
304 return Actions.Accept;
305 } else {
306 System.out.println("we determine to terminate the negotiation RANDOMLY");
307 return Actions.Break;
308 }
309 } catch (Exception e) {
310 e.printStackTrace();
311 }
312 }
313
314 } else {
315
316 if (activeHelper) {
317 roundsLeft = ((CUHKAgentSAS) helper).estimateTheRoundsLeft(true, true);
318 } else {
319 roundsLeft = ((CUHKAgentSAS) helper).estimateTheRoundsLeft(false, true);
320 }
321
322 if (negotiationSession.getTime() > 0.9985 && roundsLeft < 5) {
323 Boolean IsAccept = AcceptOpponentOffer(opponentBid, bid);
324 Boolean IsTerminate = TerminateCurrentNegotiation(bid);
325 if (IsAccept && !IsTerminate) {
326 System.out.println("accept the offer");
327 return Actions.Accept;
328 } else if (IsTerminate && !IsAccept) {
329 System.out.println("we determine to terminate the negotiation");
330 return Actions.Break;
331 } else if (IsTerminate && IsAccept) {
332 try {
333 if (utilitySpace.getUtility(opponentBid) > this.reservationValue) {
334 System.out.println("we accept the offer RANDOMLY");
335 return Actions.Accept;
336 } else {
337 System.out.println("we determine to terminate the negotiation RANDOMLY");
338 return Actions.Break;
339 }
340 } catch (Exception e) {
341 e.printStackTrace();
342 }
343 } else {
344 if (((CUHKAgentSAS) helper).isToughAgent() == true) {
345 System.out.println(
346 "the opponent is tough and the deadline is approching thus we accept the offer");
347 return Actions.Accept;
348 }
349 }
350 } else {
351 Boolean IsAccept = AcceptOpponentOffer(opponentBid, bid);
352 Boolean IsTerminate = TerminateCurrentNegotiation(bid);
353 if (IsAccept && !IsTerminate) {
354 System.out.println("accept the offer");
355 return Actions.Accept;
356 } else if (IsTerminate && !IsAccept) {
357 System.out.println("we determine to terminate the negotiation");
358 return Actions.Break;
359 } else if (IsAccept && IsTerminate) {
360 try {
361 if (utilitySpace.getUtility(opponentBid) > this.reservationValue) {
362 System.out.println("we accept the offer RANDOMLY");
363 return Actions.Accept;
364 } else {
365 System.out.println("we determine to terminate the negotiation RANDOMLY");
366 return Actions.Break;
367 }
368 } catch (Exception e) {
369 e.printStackTrace();
370 }
371 }
372 }
373
374 }
375
376 return Actions.Reject;
377 }
378
379 /*
380 * decide whether to accept the current offer or not
381 */
382 private boolean AcceptOpponentOffer(Bid opponentBid, Bid ownBid) {
383 double currentUtility = 0;
384 double nextRoundUtility = 0;
385 double maximumUtility = 0;
386 ((CUHKAgentSAS) helper).setConcedeToOpponent(false);
387 try {
388 currentUtility = this.utilitySpace.getUtility(opponentBid);
389 if (activeHelper) {
390 maximumUtility = utilitySpace.getUtility(utilitySpace.getMaxUtilityBid());
391 } else {
392 maximumUtility = ((CUHKAgentSAS) helper).getMaximumUtility();// utilitySpace.getUtility(utilitySpace.getMaxUtilityBid());
393 }
394 } catch (Exception e) {
395 System.out.println(e.getMessage() + "Exception in method AcceptOpponentOffer part 1");
396 }
397 try {
398 nextRoundUtility = this.utilitySpace.getUtility(ownBid);
399 } catch (Exception e) {
400 System.out.println(e.getMessage() + "Exception in method AcceptOpponentOffer part 2");
401 }
402 // System.out.println(this.utilitythreshold +"at time "+
403 // timeline.getTime());
404 if (currentUtility >= ((CUHKAgentSAS) helper).getUtilitythreshold() || currentUtility >= nextRoundUtility) {
405 return true;
406 } else {
407 // if the current utility with discount is larger than the predicted
408 // maximum utility with discount
409 // then accept it.
410 double predictMaximumUtility = maximumUtility * this.discountingFactor;
411 // double currentMaximumUtility =
412 // this.utilitySpace.getUtilityWithDiscount(opponentBidHistory.chooseBestFromHistory(utilitySpace),
413 // timeline);
414 double currentMaximumUtility = this.utilitySpace.getUtilityWithDiscount(
415 negotiationSession.getOpponentBidHistory().getBestBidDetails().getBid(),
416 negotiationSession.getTimeline());
417 if (currentMaximumUtility > predictMaximumUtility
418 && negotiationSession.getTime() > ((CUHKAgentSAS) helper).getConcedeToDiscountingFactor()) {
419 try {
420 // if the current offer is approximately as good as the best
421 // one in the history, then accept it.
422 if (utilitySpace.getUtility(opponentBid) >= utilitySpace.getUtility(
423 negotiationSession.getOpponentBidHistory().getBestBidDetails().getBid()) - 0.01) {
424 System.out.println("he offered me " + currentMaximumUtility + " we predict we can get at most "
425 + predictMaximumUtility + "we concede now to avoid lower payoff due to conflict");
426 return true;
427 } else {
428 ((CUHKAgentSAS) helper).setConcedeToOpponent(true);
429 return false;
430 }
431 } catch (Exception e) {
432 System.out.println("exception in Method AcceptOpponentOffer");
433 return true;
434 }
435 // retrieve the opponent's biding history and utilize it
436 } else if (currentMaximumUtility > ((CUHKAgentSAS) helper).getUtilitythreshold()
437 * Math.pow(this.discountingFactor, negotiationSession.getTime())) {
438 try {
439 // if the current offer is approximately as good as the best
440 // one in the history, then accept it.
441 if (utilitySpace.getUtility(opponentBid) >= utilitySpace.getUtility(
442 negotiationSession.getOpponentBidHistory().getBestBidDetails().getBid()) - 0.01) {
443 return true;
444 } else {
445 System.out.println("test" + utilitySpace.getUtility(opponentBid)
446 + ((CUHKAgentSAS) helper).getUtilitythreshold());
447 ((CUHKAgentSAS) helper).setConcedeToOpponent(true);
448 return false;
449 }
450 } catch (Exception e) {
451 System.out.println("exception in Method AcceptOpponentOffer");
452 return true;
453 }
454 } else {
455 return false;
456 }
457 }
458 }
459
460 /*
461 * decide whether or not to terminate now
462 */
463 private boolean TerminateCurrentNegotiation(Bid ownBid) {
464 double currentUtility = 0;
465 double nextRoundUtility = 0;
466 double maximumUtility = 0;
467 ((CUHKAgentSAS) helper).setConcedeToOpponent(false);
468 try {
469 currentUtility = this.reservationValue;
470 nextRoundUtility = this.utilitySpace.getUtility(ownBid);
471 maximumUtility = ((CUHKAgentSAS) helper).getMaximumUtility();
472 } catch (Exception e) {
473 System.out.println(e.getMessage() + "Exception in method TerminateCurrentNegotiation part 1");
474 }
475
476 if (currentUtility >= ((CUHKAgentSAS) helper).getUtilitythreshold() || currentUtility >= nextRoundUtility) {
477 return true;
478 } else {
479 // if the current reseravation utility with discount is larger than
480 // the predicted maximum utility with discount
481 // then terminate the negotiation.
482 double predictMaximumUtility = maximumUtility * this.discountingFactor;
483 double currentMaximumUtility = this.utilitySpace
484 .getReservationValueWithDiscount(negotiationSession.getTimeline());
485 // System.out.println("the current reserved value is "+
486 // this.reservationValue+" after discounting is
487 // "+currentMaximumUtility);
488 if (currentMaximumUtility > predictMaximumUtility
489 && negotiationSession.getTime() > ((CUHKAgentSAS) helper).getConcedeToDiscountingFactor()) {
490 return true;
491 } else {
492 return false;
493 }
494 }
495 }
496
497 /*
498 * determine the lowest bound of our utility threshold based on the
499 * discounting factor we think that the minimum utility threshold should not
500 * be related with the discounting degree.
501 */
502 private void chooseUtilityThreshold() {
503 double discountingFactor = this.discountingFactor;
504 if (discountingFactor >= 0.9) {
505 this.minimumUtilityThreshold = 0;// this.MaximumUtility - 0.09;
506 } else {
507 // this.minimumUtilityThreshold = 0.85;
508 this.minimumUtilityThreshold = 0;// this.MaximumUtility - 0.09;
509 }
510 }
511
512 /*
513 * determine concede-to-time degree based on the discounting factor.
514 */
515
516 private void chooseConcedeToDiscountingDegree() {
517 double alpha = 0;
518 double beta = 1.5;// 1.3;//this value controls the rate at which the
519 // agent concedes to the discouting factor.
520 // the larger beta is, the more the agent makes concesions.
521 // if (utilitySpace.getDomain().getNumberOfPossibleBids() > 100) {
522 /*
523 * if (this.maximumOfBid > 100) { beta = 2;//1.3; } else { beta = 1.5; }
524 */
525 // the vaule of beta depends on the discounting factor (trade-off
526 // between concede-to-time degree and discouting factor)
527
528 if (this.discountingFactor > 0.75) {
529 beta = 1.8;
530 } else if (this.discountingFactor > 0.5) {
531 beta = 1.5;
532 } else {
533 beta = 1.2;
534 }
535 alpha = Math.pow(this.discountingFactor, beta);
536 ((CUHKAgentSAS) helper).setConcedeToDiscountingFactor(
537 this.minConcedeToDiscountingFactor + (1 - this.minConcedeToDiscountingFactor) * alpha);
538 this.concedeToDiscountingFactor_original = ((CUHKAgentSAS) helper).getConcedeToDiscountingFactor();
539 System.out.println("concedeToDiscountingFactor is " + ((CUHKAgentSAS) helper).getConcedeToDiscountingFactor()
540 + "current time is " + negotiationSession.getTimeline().getTime());
541 }
542
543 /*
544 * pre-processing to save the computational time each round
545 */
546 private void calculateBidsBetweenUtility() {
547 BidIterator myBidIterator = new BidIterator(this.utilitySpace.getDomain());
548
549 try {
550 // double maximumUtility =
551 // utilitySpace.getUtility(utilitySpace.getMaxUtilityBid());
552 double maximumUtility = (((CUHKAgentSAS) helper).getMaximumUtility());
553 double minUtility = this.minimumUtilityThreshold;
554 int maximumRounds = (int) ((maximumUtility - minUtility) / 0.01);
555 // initalization for each arraylist storing the bids between each
556 // range
557 for (int i = 0; i < maximumRounds; i++) {
558 ArrayList<Bid> BidList = new ArrayList<Bid>();
559 // BidList.add(this.bid_maximum_utility);
560 this.bidsBetweenUtility.add(BidList);
561 }
562 this.bidsBetweenUtility.get(maximumRounds - 1).add(this.bid_maximum_utility);
563 // note that here we may need to use some trick to reduce the
564 // computation cost (to be checked later);
565 // add those bids in each range into the corresponding arraylist
566 int limits = 0;
567 if (this.maximumOfBid < 20000) {
568 while (myBidIterator.hasNext()) {
569 Bid b = myBidIterator.next();
570 for (int i = 0; i < maximumRounds; i++) {
571 if (utilitySpace.getUtility(b) <= (i + 1) * 0.01 + minUtility
572 && utilitySpace.getUtility(b) >= i * 0.01 + minUtility) {
573 this.bidsBetweenUtility.get(i).add(b);
574 break;
575 }
576 }
577 // limits++;
578 }
579 } else {
580 while (limits <= 20000) {
581 Bid b = this.RandomSearchBid();
582 for (int i = 0; i < maximumRounds; i++) {
583 if (utilitySpace.getUtility(b) <= (i + 1) * 0.01 + minUtility
584 && utilitySpace.getUtility(b) >= i * 0.01 + minUtility) {
585 this.bidsBetweenUtility.get(i).add(b);
586 break;
587 }
588 }
589 limits++;
590 }
591 }
592 } catch (Exception e) {
593 System.out.println("Exception in calculateBidsBetweenUtility()");
594 e.printStackTrace();
595 }
596 }
597
598 private Bid RandomSearchBid() throws Exception {
599 HashMap<Integer, Value> values = new HashMap<Integer, Value>();
600 List<Issue> issues = utilitySpace.getDomain().getIssues();
601 Bid bid = null;
602
603 for (Issue lIssue : issues) {
604 switch (lIssue.getType()) {
605 case DISCRETE:
606 IssueDiscrete lIssueDiscrete = (IssueDiscrete) lIssue;
607 int optionIndex = random.nextInt(lIssueDiscrete.getNumberOfValues());
608 values.put(lIssue.getNumber(), lIssueDiscrete.getValue(optionIndex));
609 break;
610 case REAL:
611 IssueReal lIssueReal = (IssueReal) lIssue;
612 int optionInd = random.nextInt(lIssueReal.getNumberOfDiscretizationSteps() - 1);
613 values.put(lIssueReal.getNumber(),
614 new ValueReal(lIssueReal.getLowerBound()
615 + (lIssueReal.getUpperBound() - lIssueReal.getLowerBound()) * (double) (optionInd)
616 / (double) (lIssueReal.getNumberOfDiscretizationSteps())));
617 break;
618 case INTEGER:
619 IssueInteger lIssueInteger = (IssueInteger) lIssue;
620 int optionIndex2 = lIssueInteger.getLowerBound()
621 + random.nextInt(lIssueInteger.getUpperBound() - lIssueInteger.getLowerBound());
622 values.put(lIssueInteger.getNumber(), new ValueInteger(optionIndex2));
623 break;
624 default:
625 throw new Exception("issue type " + lIssue.getType() + " not supported");
626 }
627 }
628 bid = new Bid(utilitySpace.getDomain(), values);
629 return bid;
630 }
631
632 private void updateConcedeDegree() {
633 double gama = 10;
634 double weight = 0.1;
635 double opponnetToughnessDegree = this.opponentBidHistory.getConcessionDegree();
636 // this.concedeToDiscountingFactor =
637 // this.concedeToDiscountingFactor_original * (1 +
638 // opponnetToughnessDegree);
639 ((CUHKAgentSAS) helper).setConcedeToDiscountingFactor(this.concedeToDiscountingFactor_original
640 + weight * (1 - this.concedeToDiscountingFactor_original) * Math.pow(opponnetToughnessDegree, gama));
641 if (((CUHKAgentSAS) helper).getConcedeToDiscountingFactor() >= 1) {
642 ((CUHKAgentSAS) helper).setConcedeToDiscountingFactor(1);
643 }
644 // System.out.println("concedeToDiscountingFactor is " +
645 // this.concedeToDiscountingFactor + "current time is " +
646 // timeline.getTime() + "original concedetodiscoutingfactor is " +
647 // this.concedeToDiscountingFactor_original);
648 }
649
650 @Override
651 public String getName() {
652 return "2012 - CUHKAgent";
653 }
654}
Note: See TracBrowser for help on using the repository browser.