source: src/main/java/agents/anac/y2019/harddealer/HardDealer_BS.java@ 201

Last change on this file since 201 was 200, checked in by Katsuhide Fujita, 6 years ago

Add ANAC 2019 agents

  • Property svn:executable set to *
File size: 4.8 KB
Line 
1package agents.anac.y2019.harddealer;
2
3import java.util.HashSet;
4import java.util.Map;
5import java.util.Set;
6
7import genius.core.bidding.BidDetails;
8import genius.core.boaframework.BOAparameter;
9import genius.core.boaframework.NegotiationSession;
10import genius.core.boaframework.NoModel;
11import genius.core.boaframework.OMStrategy;
12import genius.core.boaframework.OfferingStrategy;
13import genius.core.boaframework.OpponentModel;
14import genius.core.boaframework.SortedOutcomeSpace;
15import genius.core.timeline.Timeline;
16
17/**
18 * We have used the TimedependentAgent class to implement our bidding strategy.
19 * Below are the original creators, the code is edited by Sven Hendrikx.
20 */
21/**
22 * This is an abstract class used to implement a TimeDependentAgent Strategy
23 * adapted from [1] [1] S. Shaheen Fatima Michael Wooldridge Nicholas R.
24 * Jennings Optimal Negotiation Strategies for Agents with Incomplete
25 * Information http://eprints.ecs.soton.ac.uk/6151/1/atal01.pdf
26 *
27 * The default strategy was extended to enable the usage of opponent models.
28 */
29public class HardDealer_BS extends OfferingStrategy {
30
31 /**
32 * k in [0, 1]. For k = 0 the agent starts with a bid of maximum utility
33 */
34 private double reservationValue;
35 private double k;
36 /** Maximum target utility */
37 private double Pmax;
38 /** Minimum target utility */
39 private double Pmin;
40 /** Concession factor */
41 private double e;
42 /** Outcome space */
43 private SortedOutcomeSpace outcomespace;
44 /**
45 * Method which initializes the agent by setting all parameters. The
46 * parameter "e" is the only parameter which is required.
47 */
48 @Override
49 public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
50 Map<String, Double> parameters) throws Exception {
51 super.init(negoSession, parameters);
52 if (parameters.get("e") != null) {
53 this.negotiationSession = negoSession;
54
55 outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
56
57 negotiationSession.setOutcomeSpace(outcomespace);
58
59 // We initialize "e" as a function of the negotiation length since different lengths require different concession rates.
60 // This will be overwritten if the the timeline is of type Time
61 // for more info see report section on bidding strategy
62 this.e = (1.8) / negotiationSession.getTimeline().getTotalTime();
63 this.reservationValue = negotiationSession.getUtilitySpace().getReservationValue();
64
65 if (parameters.get("k") != null)
66 this.k = parameters.get("k");
67 else
68 this.k = 0;
69
70 if (parameters.get("min") != null)
71 this.Pmin = parameters.get("min");
72 else
73 this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
74
75 if (parameters.get("max") != null) {
76 Pmax = parameters.get("max");
77 } else {
78 BidDetails maxBid = negoSession.getMaxBidinDomain();
79 Pmax = maxBid.getMyUndiscountedUtil();
80 }
81
82 this.opponentModel = model;
83
84 this.omStrategy = oms;
85 } else {
86 throw new Exception("Constant \"e\" for the concession speed was not set.");
87 }
88 }
89
90 @Override
91 public BidDetails determineOpeningBid() {
92 return determineNextBid();
93 }
94
95 /**
96 * Simple offering strategy which retrieves the target utility and looks for
97 * the nearest bid if no opponent model is specified. If an opponent model
98 * is specified, then the agent return a bid according to the opponent model
99 * strategy.
100 */
101 @Override
102 public BidDetails determineNextBid() {
103 double time = negotiationSession.getTime();
104 double TargetValue;
105
106 if (p(time) < reservationValue)
107 TargetValue = reservationValue;
108 else
109 TargetValue = p(time);
110
111 // In case there is no model, just be time dependent
112 if (opponentModel instanceof NoModel) {
113 nextBid = negotiationSession.getOutcomeSpace().getBidNearUtility(TargetValue);
114 } else {
115 nextBid = omStrategy.getBid(outcomespace, TargetValue);
116 }
117
118 return nextBid;
119 }
120
121 public double f(double t) {
122 // First 10% of session: Slowly come up from bids with util .9 to allow the opponent to model us.
123 if (t < .1)
124 {
125 return 20*(t-0.1)*(t-0.1);
126 }
127 else
128 {
129 if (e == 0)
130 return k;
131
132 double ft = k + (1 - k) * Math.pow(t, 1.0 / e);
133 return ft;
134 }
135
136 }
137
138 public double p(double t) {
139 return Pmin + (Pmax - Pmin) * (1 - f(t));
140
141 }
142
143 public NegotiationSession getNegotiationSession() {
144 return negotiationSession;
145 }
146
147 @Override
148 public Set<BOAparameter> getParameterSpec() {
149 Set<BOAparameter> set = new HashSet<BOAparameter>();
150 set.add(new BOAparameter("e", this.e, "Concession rate"));
151 set.add(new BOAparameter("k", this.k, "Offset"));
152 set.add(new BOAparameter("min", this.Pmin, "Minimum utility"));
153 set.add(new BOAparameter("max", this.Pmax, "Maximum utility"));
154
155 return set;
156 }
157
158 @Override
159 public String getName() {
160 return "HardDealer_BS";
161 }
162}
Note: See TracBrowser for help on using the repository browser.