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

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

BoulwareNegotiationParty in BC

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