source: src/main/java/onetomany/bargainingchipsgame/players/AbstractTimeDependentNegotiationParty.java@ 301

Last change on this file since 301 was 301, checked in by Tim Baarslag, 5 years ago

Boulware works with UF_CloseToQuantityMaxPrice

File size: 4.2 KB
Line 
1package onetomany.bargainingchipsgame.players;
2
3import static java.lang.Math.pow;
4
5import java.util.concurrent.BlockingQueue;
6
7import genius.core.protocol.MultilateralProtocol;
8import onetomany.bargainingchipsgame.Bundle;
9import onetomany.bargainingchipsgame.OutcomeSpace;
10import onetomany.bargainingchipsgame.interactions.Accept;
11import onetomany.bargainingchipsgame.interactions.Offer;
12import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction;
13
14/**
15 * Boulware/Conceder tactics, by Tim Baarslag, adapted from [1].
16 *
17 * [1] S. Shaheen Fatima Michael Wooldridge Nicholas R. Jennings Optimal
18 * Negotiation Strategies for Agents with Incomplete Information
19 * http://eprints.ecs.soton.ac.uk/6151/1/atal01.pdf
20 *
21 * @author Tim Baarslag, Mark Hendrikx
22 */
23public abstract class AbstractTimeDependentNegotiationParty extends Agent
24{
25
26 private static final int DEADLINE = 20;
27 OutcomeSpace outcomeSpace;
28 Bundle lastReceivedBid = null;
29
30 public AbstractTimeDependentNegotiationParty(String name, UtilityFunction u,
31 BlockingQueue<onetomany.bargainingchipsgame.interactions.Offer> in,
32 BlockingQueue<onetomany.bargainingchipsgame.interactions.Offer> out,
33 BlockingQueue<CoordinationMessage> cin,
34 BlockingQueue<NegotiationStatusMessage> cout) {
35 super(name, u, in, out, cin, cout);
36 outcomeSpace = new OutcomeSpace(null);
37 }
38
39 /**
40 * When this class is called, it is expected that the Party chooses one of
41 * the actions from the possible action list and returns an instance of the
42 * chosen action. This class is only called if this
43 * {@link genius.core.parties.NegotiationParty} is in the
44 * {@link MultilateralProtocol#getRoundStructure(java.util.List, negotiator.session.Session)}
45 * .
46 *
47 * @param possibleActions
48 * List of all actions possible.
49 * @return The chosen action
50 */
51 @Override
52 protected Offer sendOffer()
53 {
54 Bundle nextBid = getNextBid();
55
56 double lastUtil = lastReceivedBid != null ? u.getUtility(lastReceivedBid) : 0;
57 double nextUtil = nextBid != null ? u.getUtility(nextBid) : 0;
58
59 // Accept
60 if (nextUtil < lastUtil)
61 return new Accept();
62 // Counter offer based actions
63 else
64 return new Offer(nextBid);
65 }
66
67 /**
68 * Get the next bid we should do
69 */
70 protected Bundle getNextBid()
71 {
72 return outcomeSpace.getBidNearUtility(getTargetUtility(), u);
73 }
74
75 @Override
76 protected void receiveOffer(Offer o)
77 {
78 lastReceivedBid = o.getBundle();
79 }
80
81 /**
82 * Gets the target utility for the next bid
83 *
84 * @return The target utility for the given time
85 */
86 public double getTargetUtility()
87 {
88 // timeline runs from 0.0 to 1.0
89 int totalrounds = DEADLINE;
90 double time = (double) k / totalrounds;
91 double target = 1d - f(time);
92 System.out.println("t = " + time + ". Target util: " + target);
93 return target;
94 }
95
96 /**
97 * From [1]:
98 *
99 * A wide range of time dependent functions can be defined by varying the
100 * way in which f(t) is computed. However, functions must ensure that 0 <=
101 * f(t) <= 1, f(0) = k, and f(1) = 1.
102 *
103 * That is, the offer will always be between the value range, at the
104 * beginning it will give the initial constant and when the deadline is
105 * reached, it will offer the reservation value.
106 *
107 * For e = 0 (special case), it will behave as a Hardliner.
108 */
109 public double f(double t) {
110 if (getE() == 0) {
111 return 0;
112 }
113 return pow(t, 1 / getE());
114 }
115
116 /**
117 * Depending on the value of e, extreme sets show clearly different patterns
118 * of behaviour [1]:
119 *
120 * 1. Boulware: For this strategy e < 1 and the initial offer is maintained
121 * till time is almost exhausted, when the agent concedes up to its
122 * reservation value.
123 *
124 * 2. Conceder: For this strategy e > 1 and the agent goes to its
125 * reservation value very quickly.
126 *
127 * 3. When e = 1, the price is increased linearly.
128 *
129 * 4. When e = 0, the agent plays hardball.
130 */
131 public abstract double getE();
132
133 @Override
134 protected Offer sendOpeningOffer()
135 {
136 return sendOffer();
137 }
138
139 @Override
140 protected void receiveCoordinationMessage(CoordinationMessage cpoll)
141 {
142 // Update the utility function
143 u = cpoll.f;
144 }
145}
Note: See TracBrowser for help on using the repository browser.