source: src/main/java/negotiator/boaframework/acceptanceconditions/other/AC_CombiProb.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.1 KB
Line 
1package negotiator.boaframework.acceptanceconditions.other;
2
3import java.util.Map;
4
5import genius.core.BidHistory;
6import genius.core.boaframework.AcceptanceStrategy;
7import genius.core.boaframework.Actions;
8import genius.core.boaframework.NegotiationSession;
9import genius.core.boaframework.OfferingStrategy;
10import genius.core.boaframework.OpponentModel;
11
12/**
13 * This is the decoupled Acceptance Conditions Based on Tim Baarslag's paper on
14 * Acceptance Conditions: "Acceptance Conditions in Automated Negotiation"
15 *
16 * This Acceptance Condition accepts a bid if it is higher than any bid seen so
17 * far
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
23 */
24public class AC_CombiProb extends AcceptanceStrategy {
25
26 private double time;
27
28 /**
29 * Empty constructor for the BOA framework.
30 */
31 public AC_CombiProb() {
32 }
33
34 public AC_CombiProb(NegotiationSession negoSession, OfferingStrategy strat, double t) {
35 this.negotiationSession = negoSession;
36 this.offeringStrategy = strat;
37 this.time = t;
38 }
39
40 @Override
41 public void init(NegotiationSession negoSession, OfferingStrategy strat, OpponentModel opponentModel,
42 Map<String, Double> parameters) throws Exception {
43 this.negotiationSession = negoSession;
44 if (parameters.get("t") != null) {
45 time = parameters.get("t");
46 } else {
47 throw new Exception("Paramaters were not correctly set");
48 }
49 }
50
51 @Override
52 public String printParameters() {
53 return "[t: " + time + "]";
54 }
55
56 @Override
57 public Actions determineAcceptability() {
58 if (negotiationSession.getOpponentBidHistory().getLastBidDetails().getMyUndiscountedUtil() >= offeringStrategy
59 .getNextBid().getMyUndiscountedUtil()) {
60 return Actions.Accept;
61 }
62
63 if (negotiationSession.getTime() < time) {
64 return Actions.Reject;
65 }
66
67 double offeredUndiscountedUtility = negotiationSession.getOpponentBidHistory().getLastBidDetails()
68 .getMyUndiscountedUtil();
69 double now = negotiationSession.getTime();
70 double timeLeft = 1 - now;
71
72 // if we will still see a lot of bids
73 BidHistory recentBids = negotiationSession.getOpponentBidHistory().filterBetweenTime(now - timeLeft, now);
74 int remainingBids = recentBids.size();
75 if (remainingBids > 10)
76 return Actions.Reject;
77
78 // v2.0
79 double window = timeLeft;
80 // double window = 5 * timeLeft;
81 BidHistory recentBetterBids = negotiationSession.getOpponentBidHistory()
82 .filterBetween(offeredUndiscountedUtility, 1, now - window, now);
83 int n = recentBetterBids.size();
84 double p = timeLeft / window;
85 if (p > 1)
86 p = 1;
87
88 double pAllMiss = Math.pow(1 - p, n);
89 if (n == 0)
90 pAllMiss = 1;
91 double pAtLeastOneHit = 1 - pAllMiss;
92
93 double avg = recentBetterBids.getAverageUtility();
94
95 double expectedUtilOfWaitingForABetterBid = pAtLeastOneHit * avg;
96
97 if (offeredUndiscountedUtility > expectedUtilOfWaitingForABetterBid)
98 return Actions.Accept;
99
100 return Actions.Reject;
101 }
102
103 @Override
104 public String getName() {
105 return "Other - CombiProb";
106 }
107
108}
Note: See TracBrowser for help on using the repository browser.