source: src/main/java/negotiator/parties/AbstractTimeDependentNegotiationParty.java@ 48

Last change on this file since 48 was 48, checked in by Tim Baarslag, 6 years ago

TDT agents get their getUtilitySpace() from the API, not the info object anymore

File size: 5.0 KB
Line 
1package negotiator.parties;
2
3import static java.lang.Math.pow;
4
5import java.util.List;
6
7import genius.core.AgentID;
8import genius.core.Bid;
9import genius.core.actions.Accept;
10import genius.core.actions.Action;
11import genius.core.actions.NoAction;
12import genius.core.actions.Offer;
13import genius.core.actions.OfferForVoting;
14import genius.core.actions.Reject;
15import genius.core.boaframework.SortedOutcomeSpace;
16import genius.core.parties.AbstractNegotiationParty;
17import genius.core.parties.NegotiationInfo;
18import genius.core.protocol.MultilateralProtocol;
19import genius.core.timeline.DiscreteTimeline;
20
21/**
22 * Boulware/Conceder tactics, by Tim Baarslag, adapted from [1]. Adapted by Mark
23 * Hendrikx to use the SortedOutcomeSpace instead of BidHistory. Adapted by
24 * David Festen for multilateral case.
25 *
26 * [1] S. Shaheen Fatima Michael Wooldridge Nicholas R. Jennings Optimal
27 * Negotiation Strategies for Agents with Incomplete Information
28 * http://eprints.ecs.soton.ac.uk/6151/1/atal01.pdf
29 *
30 * @author David Festen, Tim Baarslag, Mark Hendrikx
31 */
32public abstract class AbstractTimeDependentNegotiationParty extends AbstractNegotiationParty {
33 SortedOutcomeSpace outcomeSpace;
34 Bid lastBid = null; // last RECEIVED bid
35
36 @Override
37 public void init(NegotiationInfo info)
38 {
39 super.init(info);
40 outcomeSpace = new SortedOutcomeSpace(getUtilitySpace());
41 }
42
43 /**
44 * When this class is called, it is expected that the Party chooses one of
45 * the actions from the possible action list and returns an instance of the
46 * chosen action. This class is only called if this
47 * {@link genius.core.parties.NegotiationParty} is in the
48 * {@link MultilateralProtocol#getRoundStructure(java.util.List, negotiator.session.Session)}
49 * .
50 *
51 * @param possibleActions
52 * List of all actions possible.
53 * @return The chosen action
54 */
55 @Override
56 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
57 Bid nextBid = getNextBid();
58 double lastUtil = lastBid != null ? utilitySpace.getUtilityWithDiscount(lastBid, timeline) : 0;
59 double nextUtil = nextBid != null ? utilitySpace.getUtilityWithDiscount(nextBid, timeline) : 0;
60
61 // Accept is for both voting and counter offer protocols
62 if (possibleActions.contains(Accept.class) && nextUtil < lastUtil)
63 return new Accept(getPartyId(), lastBid);
64
65 // Counter offer based actions
66 else if (possibleActions.contains(Offer.class))
67 return new Offer(getPartyId(), nextBid);
68
69 // Voting based actions
70 else if (possibleActions.contains(OfferForVoting.class))
71 return new OfferForVoting(getPartyId(), nextBid);
72 else if (possibleActions.contains(Reject.class))
73 return new Reject(getPartyId(), lastBid); // Accept is higher up the
74 // chain
75
76 // default action
77 else
78 return new NoAction(getPartyId());
79 }
80
81 /**
82 * Get the next bid we should do
83 */
84 protected Bid getNextBid() {
85 return outcomeSpace.getBidNearUtility(getTargetUtility()).getBid();
86 }
87
88 /**
89 * This method is called when an observable action is performed. Observable
90 * actions are defined in
91 * {@link MultilateralProtocol#getActionListeners(java.util.List)}
92 *
93 * @param sender
94 * The initiator of the action
95 * @param arguments
96 * The action performed
97 */
98 @Override
99 public void receiveMessage(AgentID sender, Action arguments) {
100 if (arguments instanceof Offer)
101 lastBid = ((Offer) arguments).getBid();
102 }
103
104 /**
105 * Gets the target utility for the next bid
106 *
107 * @return The target utility for the given time
108 */
109 public double getTargetUtility() {
110
111 // timeline runs from 0.0 to 1.0
112
113 // we have a slight offset because discrete timeline is 1-based, this
114 // needs to be addressed
115 double offset = timeline instanceof DiscreteTimeline ? 1d / ((DiscreteTimeline) timeline).getTotalRounds() : 0d;
116 return 1d - f(timeline.getTime() - offset);
117 }
118
119 /**
120 * From [1]:
121 *
122 * A wide range of time dependent functions can be defined by varying the
123 * way in which f(t) is computed. However, functions must ensure that 0 <=
124 * f(t) <= 1, f(0) = k, and f(1) = 1.
125 *
126 * That is, the offer will always be between the value range, at the
127 * beginning it will give the initial constant and when the deadline is
128 * reached, it will offer the reservation value.
129 *
130 * For e = 0 (special case), it will behave as a Hardliner.
131 */
132 public double f(double t) {
133 if (getE() == 0) {
134 return 0;
135 }
136 return pow(t, 1 / getE());
137 }
138
139 /**
140 * Depending on the value of e, extreme sets show clearly different patterns
141 * of behaviour [1]:
142 *
143 * 1. Boulware: For this strategy e < 1 and the initial offer is maintained
144 * till time is almost exhausted, when the agent concedes up to its
145 * reservation value.
146 *
147 * 2. Conceder: For this strategy e > 1 and the agent goes to its
148 * reservation value very quickly.
149 *
150 * 3. When e = 1, the price is increased linearly.
151 *
152 * 4. When e = 0, the agent plays hardball.
153 */
154 public abstract double getE();
155}
Note: See TracBrowser for help on using the repository browser.