1 | package negotiator.boaframework.acceptanceconditions.anac2010;
|
---|
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.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 | */
|
---|
25 | public 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 | } |
---|