source: src/test/java/boaexample/AC_Next.java@ 127

Last change on this file since 127 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 boaexample;
2
3import java.util.HashSet;
4import java.util.Map;
5import java.util.Set;
6
7import genius.core.boaframework.AcceptanceStrategy;
8import genius.core.boaframework.Actions;
9import genius.core.boaframework.BOAparameter;
10import genius.core.boaframework.NegotiationSession;
11import genius.core.boaframework.OfferingStrategy;
12import genius.core.boaframework.OpponentModel;
13
14/**
15 * This Acceptance Condition will accept an opponent bid if the utility is
16 * higher than the bid the agent is ready to present.
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 */
22public class AC_Next extends AcceptanceStrategy {
23
24 private double a;
25 private double b;
26
27 /**
28 * Empty constructor for the BOA framework.
29 */
30 public AC_Next() {
31 }
32
33 public AC_Next(NegotiationSession negoSession, OfferingStrategy strat,
34 double alpha, double beta) {
35 this.negotiationSession = negoSession;
36 this.offeringStrategy = strat;
37 this.a = alpha;
38 this.b = beta;
39 }
40
41 @Override
42 public void init(NegotiationSession negoSession, OfferingStrategy strat,
43 OpponentModel opponentModel, Map<String, Double> parameters)
44 throws Exception {
45 this.negotiationSession = negoSession;
46 this.offeringStrategy = strat;
47
48 if (parameters.get("a") != null || parameters.get("b") != null) {
49 a = parameters.get("a");
50 b = parameters.get("b");
51 } else {
52 a = 1;
53 b = 0;
54 }
55 }
56
57 @Override
58 public String printParameters() {
59 String str = "[a: " + a + " b: " + b + "]";
60 return str;
61 }
62
63 @Override
64 public Actions determineAcceptability() {
65 double nextMyBidUtil = offeringStrategy.getNextBid()
66 .getMyUndiscountedUtil();
67 double lastOpponentBidUtil = negotiationSession.getOpponentBidHistory()
68 .getLastBidDetails().getMyUndiscountedUtil();
69
70 if (a * lastOpponentBidUtil + b >= nextMyBidUtil) {
71 return Actions.Accept;
72 }
73 return Actions.Reject;
74 }
75
76 @Override
77 public Set<BOAparameter> getParameterSpec() {
78
79 Set<BOAparameter> set = new HashSet<BOAparameter>();
80 set.add(new BOAparameter("a", 1.0,
81 "Accept when the opponent's utility * a + b is greater than the utility of our current bid"));
82 set.add(new BOAparameter("b", 0.0,
83 "Accept when the opponent's utility * a + b is greater than the utility of our current bid"));
84
85 return set;
86 }
87
88 @Override
89 public String getName() {
90 return "AC_Next example";
91 }
92}
Note: See TracBrowser for help on using the repository browser.