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