source: src/main/java/negotiator/boaframework/acceptanceconditions/anac2010/AC_AgentK.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.5 KB
Line 
1package negotiator.boaframework.acceptanceconditions.anac2010;
2
3import java.util.Map;
4import java.util.Random;
5
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.anac2010.AgentKSAS;
13
14/**
15 * This is the decoupled Acceptance Condition from Agent K (ANAC2010). The code
16 * was taken from the ANAC2010 Agent K and adapted to work within the BOA
17 * 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 Mark Hendrikx
23 * @version 25/12/11
24 */
25public class AC_AgentK extends AcceptanceStrategy {
26
27 private Random random100;
28 private boolean activeHelper = false;
29 private final boolean TEST_EQUIVALENCE = false;
30
31 /**
32 * Empty constructor for the BOA framework.
33 */
34 public AC_AgentK() {
35 }
36
37 public AC_AgentK(NegotiationSession negoSession, OfferingStrategy strat) throws Exception {
38 initializeAgent(negoSession, strat);
39 }
40
41 @Override
42 public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
43 Map<String, Double> parameters) throws Exception {
44 initializeAgent(negoSession, strat);
45 }
46
47 public void initializeAgent(NegotiationSession negotiationSession, OfferingStrategy os) throws Exception {
48 this.negotiationSession = negotiationSession;
49 this.offeringStrategy = os;
50
51 if (offeringStrategy.getHelper() == null || (!offeringStrategy.getHelper().getName().equals("AgentK"))) {
52 helper = new AgentKSAS(negotiationSession);
53 activeHelper = true;
54 } else {
55 helper = (AgentKSAS) offeringStrategy.getHelper();
56 }
57 if (TEST_EQUIVALENCE) {
58 random100 = new Random(100);
59 } else {
60 random100 = new Random();
61 }
62 }
63
64 @Override
65 public Actions determineAcceptability() {
66 BidDetails opponentBid = negotiationSession.getOpponentBidHistory().getLastBidDetails();
67 if (opponentBid != null) {
68 double p;
69 if (activeHelper) {
70 p = ((AgentKSAS) helper).calculateAcceptProbability();
71 } else {
72 p = ((AgentKSAS) helper).getAcceptProbability();
73 }
74 if (p > random100.nextDouble()) {
75 return Actions.Accept;
76 }
77 }
78 return Actions.Reject;
79 }
80
81 @Override
82 public String getName() {
83 return "2010 - AgentK";
84 }
85}
Note: See TracBrowser for help on using the repository browser.