source: src/main/java/negotiator/boaframework/acceptanceconditions/anac2011/AC_BRAMAgent.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: 3.2 KB
Line 
1package negotiator.boaframework.acceptanceconditions.anac2011;
2
3import java.util.Map;
4
5import genius.core.Bid;
6import genius.core.bidding.BidDetails;
7import genius.core.boaframework.AcceptanceStrategy;
8import genius.core.boaframework.Actions;
9import genius.core.boaframework.NegotiationSession;
10import genius.core.boaframework.OfferingStrategy;
11import genius.core.boaframework.OpponentModel;
12import negotiator.boaframework.sharedagentstate.anac2011.BRAMAgentSAS;
13
14/**
15 * This is the decoupled Acceptance Conditions from the BRAMAgent (ANAC2011).
16 * The code was taken from the ANAC2011 BRAMAgent and adapted to work within the
17 * BOA framework.
18 *
19 * Decoupling Negotiating Agents to Explore the Space of Negotiation Strategies
20 * T. Baarslag, K. Hindriks, M. Hendrikx, A. Dirkzwager, C.M. Jonker
21 *
22 * @author Alex Dirkzwager, Mark Hendrikx
23 * @version 26/12/11
24 */
25public class AC_BRAMAgent extends AcceptanceStrategy {
26
27 private boolean activeHelper = false;
28 private BidDetails bestBid;
29 private Bid worstBid;
30
31 /**
32 * Empty constructor for the BOA framework.
33 */
34 public AC_BRAMAgent() {
35 }
36
37 public AC_BRAMAgent(NegotiationSession negoSession, OfferingStrategy strat) throws Exception {
38 init(negoSession, strat, null, null);
39 }
40
41 @Override
42 public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
43 Map<String, Double> parameters) throws Exception {
44 this.negotiationSession = negoSession;
45 this.offeringStrategy = strat;
46 bestBid = negoSession.getMaxBidinDomain();
47 worstBid = negoSession.getUtilitySpace().getMinUtilityBid();
48
49 // checking if offeringStrategy SAS is a BRAMAgentSAS
50 if (offeringStrategy.getHelper() == null || (!offeringStrategy.getHelper().getName().equals("BRAMAgent"))) {
51 helper = new BRAMAgentSAS(negotiationSession);
52 activeHelper = true;
53 } else {
54 helper = (BRAMAgentSAS) offeringStrategy.getHelper();
55 }
56 }
57
58 @Override
59 public Actions determineAcceptability() {
60 double offeredUtility = negotiationSession.getUtilitySpace().getUtilityWithDiscount(
61 negotiationSession.getOpponentBidHistory().getLastBidDetails().getBid(), negotiationSession.getTime());
62 double threshold;
63
64 if (activeHelper) {
65 threshold = ((BRAMAgentSAS) helper).getNewThreshold(worstBid, bestBid.getBid());
66 } else {
67 threshold = ((BRAMAgentSAS) helper).getThreshold();// Update the
68 // threshold
69 // according to
70 // the discount
71 // factor
72 }
73
74 // If the utility of the bid that we received from the opponent is
75 // larger than the threshold that we ready to accept,
76 // we will accept the offer OR if the opponent bid is greater than what
77 // we are about to offer.
78 double nextBidDiscounted = negotiationSession.getUtilitySpace()
79 .getUtilityWithDiscount(offeringStrategy.getNextBid().getBid(), negotiationSession.getTime());
80 if ((offeredUtility >= threshold)
81 || (offeringStrategy.getNextBid() != null && offeredUtility >= nextBidDiscounted)) {
82 return Actions.Accept;
83 }
84 return Actions.Reject;
85 }
86
87 @Override
88 public String getName() {
89 return "2011 - BRAMAgent";
90 }
91}
Note: See TracBrowser for help on using the repository browser.