1 | package negotiator.boaframework.acceptanceconditions.anac2011;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 | import java.util.Random;
|
---|
5 |
|
---|
6 | import genius.core.bidding.BidDetails;
|
---|
7 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
8 | import genius.core.boaframework.Actions;
|
---|
9 | import genius.core.boaframework.NegotiationSession;
|
---|
10 | import genius.core.boaframework.OfferingStrategy;
|
---|
11 | import genius.core.boaframework.OpponentModel;
|
---|
12 | import negotiator.boaframework.sharedagentstate.anac2011.AgentK2SAS;
|
---|
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 | */
|
---|
25 | public class AC_AgentK2 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_AgentK2() {
|
---|
35 | }
|
---|
36 |
|
---|
37 | public AC_AgentK2(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("AgentK2"))) {
|
---|
52 | helper = new AgentK2SAS(negotiationSession);
|
---|
53 | activeHelper = true;
|
---|
54 | } else {
|
---|
55 | helper = (AgentK2SAS) offeringStrategy.getHelper();
|
---|
56 | }
|
---|
57 |
|
---|
58 | if (TEST_EQUIVALENCE) {
|
---|
59 | random100 = new Random(100);
|
---|
60 | } else {
|
---|
61 | random100 = new Random();
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | @Override
|
---|
66 | public Actions determineAcceptability() {
|
---|
67 | BidDetails opponentBid = negotiationSession.getOpponentBidHistory().getLastBidDetails();
|
---|
68 | if (opponentBid != null) {
|
---|
69 | double p;
|
---|
70 | if (activeHelper) {
|
---|
71 | p = ((AgentK2SAS) helper).calculateAcceptProbability();
|
---|
72 | } else {
|
---|
73 | p = ((AgentK2SAS) helper).getAcceptProbability();
|
---|
74 | }
|
---|
75 | if (p > random100.nextDouble()) {
|
---|
76 | return Actions.Accept;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | return Actions.Reject;
|
---|
80 | }
|
---|
81 |
|
---|
82 | @Override
|
---|
83 | public String getName() {
|
---|
84 | return "2011 - AgentK2";
|
---|
85 | }
|
---|
86 | } |
---|