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

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

UF_CloseToQuantity

Accept(Offer agreement)

File size: 4.5 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 Offer lastReceivedOffer = 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 // Nothing received yet
55 if (lastReceivedOffer == null)
56 return new Offer(getNextBid());
57
58 // Our last bid got accepted. We are also accepting (and we should notify the coordinator).
59 if (lastReceivedOffer.isAccept())
60 return new Accept(lastReceivedOffer);
61
62 Bundle lastReceivedBid = lastReceivedOffer.getBundle();
63 Bundle nextBid = getNextBid();
64
65 double lastUtil = lastReceivedBid != null ? u.getUtility(lastReceivedBid) : 0;
66 double nextUtil = nextBid != null ? u.getUtility(nextBid) : 0;
67
68 // Accept
69 if (nextUtil <= lastUtil)
70 return new Accept(lastReceivedOffer);
71 // Counter offer based actions
72 else
73 return new Offer(nextBid);
74 }
75
76 /**
77 * Get the next bid we should do
78 */
79 protected Bundle getNextBid()
80 {
81 return outcomeSpace.getBidNearUtility(getTargetUtility(), u, this);
82 }
83
84 @Override
85 protected void receiveOffer(Offer o)
86 {
87 lastReceivedOffer = o;
88 }
89
90 /**
91 * Gets the target utility for the next bid
92 *
93 * @return The target utility for the given time
94 */
95 private double getTargetUtility()
96 {
97 // timeline runs from 0.0 to 1.0
98 int totalrounds = DEADLINE;
99 double time = (double) k / totalrounds;
100 double target = 1d - f(time);
101// System.out.println(this + ": t = " + time + ". Target util: " + target);
102 return target;
103 }
104
105 /**
106 * From [1]:
107 *
108 * A wide range of time dependent functions can be defined by varying the
109 * way in which f(t) is computed. However, functions must ensure that 0 <=
110 * f(t) <= 1, f(0) = k, and f(1) = 1.
111 *
112 * That is, the offer will always be between the value range, at the
113 * beginning it will give the initial constant and when the deadline is
114 * reached, it will offer the reservation value.
115 *
116 * For e = 0 (special case), it will behave as a Hardliner.
117 */
118 private double f(double t) {
119 if (getE() == 0) {
120 return 0;
121 }
122 return pow(t, 1 / getE());
123 }
124
125 /**
126 * Depending on the value of e, extreme sets show clearly different patterns
127 * of behaviour [1]:
128 *
129 * 1. Boulware: For this strategy e < 1 and the initial offer is maintained
130 * till time is almost exhausted, when the agent concedes up to its
131 * reservation value.
132 *
133 * 2. Conceder: For this strategy e > 1 and the agent goes to its
134 * reservation value very quickly.
135 *
136 * 3. When e = 1, the price is increased linearly.
137 *
138 * 4. When e = 0, the agent plays hardball.
139 */
140 public abstract double getE();
141
142 @Override
143 protected Offer sendOpeningOffer()
144 {
145 return sendOffer();
146 }
147
148 @Override
149 protected void receiveCoordinationMessage(CoordinationMessage cpoll)
150 {
151 // Update the utility function
152 u = cpoll.f;
153 }
154}
Note: See TracBrowser for help on using the repository browser.