source: src/main/java/negotiator/boaframework/acceptanceconditions/anac2011/AC_HardHeaded.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: 2.7 KB
Line 
1package negotiator.boaframework.acceptanceconditions.anac2011;
2
3import java.util.Map;
4
5import genius.core.bidding.BidDetails;
6import genius.core.boaframework.AcceptanceStrategy;
7import genius.core.boaframework.Actions;
8import genius.core.boaframework.NegotiationSession;
9import genius.core.boaframework.OfferingStrategy;
10import genius.core.boaframework.OpponentModel;
11import negotiator.boaframework.sharedagentstate.anac2011.HardHeadedSAS;
12
13/**
14 * This is the decoupled Acceptance Conditions for HardHeaded (ANAC2011). The
15 * code was taken from the ANAC2011 HardHeaded and adapted to work within the
16 * BOA framework.
17 *
18 * Decoupling Negotiating Agents to Explore the Space of Negotiation Strategies
19 * T. Baarslag, K. Hindriks, M. Hendrikx, A. Dirkzwager, C.M. Jonker
20 *
21 * @author Alex Dirkzwager, Mark Hendrikx
22 */
23public class AC_HardHeaded extends AcceptanceStrategy {
24
25 private boolean activeHelper = false;
26 private double prevUtil = 1.0;
27 private double lowestOfferBidUtil = 1.0;
28
29 /**
30 * Empty constructor for the BOA framework.
31 */
32 public AC_HardHeaded() {
33 }
34
35 public AC_HardHeaded(NegotiationSession negoSession, OfferingStrategy strat) throws Exception {
36 init(negoSession, strat, null, null);
37
38 }
39
40 @Override
41 public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
42 Map<String, Double> parameters) throws Exception {
43 this.negotiationSession = negoSession;
44 this.offeringStrategy = strat;
45
46 if (offeringStrategy.getHelper() == null || (!offeringStrategy.getHelper().getName().equals("HardHeaded"))) {
47 helper = new HardHeadedSAS(negoSession);
48 activeHelper = true;
49 } else {
50 helper = (HardHeadedSAS) offeringStrategy.getHelper();
51 }
52 }
53
54 @Override
55 public Actions determineAcceptability() {
56 BidDetails opponentsLastBid = negotiationSession.getOpponentBidHistory().getLastBidDetails();
57 // if opponent's suggested bid is better than the one we just selected,
58 // then accept it
59
60 if (activeHelper) {
61 prevUtil = ((HardHeadedSAS) helper).getLowestUtilityYet();
62 } else {
63 if (lowestOfferBidUtil != prevUtil) {
64 prevUtil = lowestOfferBidUtil;
65 }
66 lowestOfferBidUtil = ((HardHeadedSAS) helper).getLowestYetUtility();
67 }
68
69 double util = 0;
70 try {
71 util = offeringStrategy.getNextBid().getMyUndiscountedUtil();
72 } catch (Exception e) {
73 e.printStackTrace();
74 }
75
76 if (opponentsLastBid != null && (opponentsLastBid.getMyUndiscountedUtil() > prevUtil
77 || util <= opponentsLastBid.getMyUndiscountedUtil())) {
78 return Actions.Accept;
79 }
80 return Actions.Reject;
81 }
82
83 @Override
84 public String getName() {
85 return "2011 - HardHeaded";
86 }
87}
Note: See TracBrowser for help on using the repository browser.