1 | package negotiator.boaframework.acceptanceconditions.anac2012;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
7 | import genius.core.boaframework.Actions;
|
---|
8 | import genius.core.boaframework.NegotiationSession;
|
---|
9 | import genius.core.boaframework.OfferingStrategy;
|
---|
10 | import genius.core.boaframework.OpponentModel;
|
---|
11 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * This is the decoupled Acceptance Condition from OMACagent (ANAC2012). The
|
---|
15 | * code was taken from the ANAC2012 OMACagent and adapted to work within the BOA
|
---|
16 | * 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
|
---|
22 | * @version 31/10/12
|
---|
23 | */
|
---|
24 | public class AC_OMACagent extends AcceptanceStrategy {
|
---|
25 |
|
---|
26 | private double discount = 1.0;
|
---|
27 | private AdditiveUtilitySpace utilitySpace;
|
---|
28 | public double discountThreshold = 0.845D;
|
---|
29 |
|
---|
30 | public AC_OMACagent() {
|
---|
31 | }
|
---|
32 |
|
---|
33 | public AC_OMACagent(NegotiationSession negoSession, OfferingStrategy strat) throws Exception {
|
---|
34 | init(negoSession, strat, null, null);
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
|
---|
39 | Map<String, Double> parameters) throws Exception {
|
---|
40 | this.negotiationSession = negoSession;
|
---|
41 | offeringStrategy = strat;
|
---|
42 | utilitySpace = (AdditiveUtilitySpace) negoSession.getUtilitySpace();
|
---|
43 |
|
---|
44 | if (utilitySpace.getDiscountFactor() <= 1D && utilitySpace.getDiscountFactor() > 0D)
|
---|
45 | discount = utilitySpace.getDiscountFactor();
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public Actions determineAcceptability() {
|
---|
51 | Bid partnerBid = negotiationSession.getOpponentBidHistory().getLastBid();
|
---|
52 | double time = negotiationSession.getTime();
|
---|
53 | if (discount < discountThreshold) {
|
---|
54 | if (bidAlreadyMade(partnerBid)) {
|
---|
55 | System.out.println("Decoupled accept1");
|
---|
56 | return Actions.Accept;
|
---|
57 | }
|
---|
58 | } else if (time > 0.97) {
|
---|
59 | // System.out.println("Decoupled bidAlreadyMade: " +
|
---|
60 | // bidAlreadyMade(partnerBid));
|
---|
61 | if (bidAlreadyMade(partnerBid)) {
|
---|
62 | System.out.println("Decoupled accept2");
|
---|
63 | return Actions.Accept;
|
---|
64 |
|
---|
65 | }
|
---|
66 | }
|
---|
67 | double myOfferedUtil = negotiationSession.getDiscountedUtility(offeringStrategy.getNextBid().getBid(), time);
|
---|
68 | double offeredUtilFromOpponent = negotiationSession
|
---|
69 | .getDiscountedUtility(negotiationSession.getOpponentBidHistory().getLastBid(), time);
|
---|
70 | // accept under certain conditions
|
---|
71 | try {
|
---|
72 | // System.out.println("Decoupled accept3");
|
---|
73 |
|
---|
74 | if (isAcceptable(offeredUtilFromOpponent, myOfferedUtil, time, partnerBid))
|
---|
75 | return Actions.Accept;
|
---|
76 | } catch (Exception e) {
|
---|
77 | e.printStackTrace();
|
---|
78 | }
|
---|
79 |
|
---|
80 | return Actions.Reject;
|
---|
81 | }
|
---|
82 |
|
---|
83 | private boolean isAcceptable(double offeredUtilFromOpponent, double myOfferedUtil, double time, Bid oppBid)
|
---|
84 | throws Exception {
|
---|
85 |
|
---|
86 | if (offeredUtilFromOpponent >= myOfferedUtil) {
|
---|
87 | return true;
|
---|
88 | }
|
---|
89 |
|
---|
90 | return false;
|
---|
91 | }
|
---|
92 |
|
---|
93 | public boolean bidAlreadyMade(Bid a) {
|
---|
94 | boolean result = false;
|
---|
95 | for (int i = 0; i < negotiationSession.getOwnBidHistory().size(); i++) {
|
---|
96 | if (a.equals(negotiationSession.getOwnBidHistory().getHistory().get(i).getBid())) {
|
---|
97 | result = true;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | return result;
|
---|
101 | }
|
---|
102 |
|
---|
103 | @Override
|
---|
104 | public String getName() {
|
---|
105 | return "2012 - OMACagent";
|
---|
106 | }
|
---|
107 | }
|
---|