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

Last change on this file since 1 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 5.0 KB
RevLine 
[1]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 super.init(info);
39 outcomeSpace = new SortedOutcomeSpace(info.getUtilitySpace());
40 }
41
42 /**
43 * When this class is called, it is expected that the Party chooses one of
44 * the actions from the possible action list and returns an instance of the
45 * chosen action. This class is only called if this
46 * {@link genius.core.parties.NegotiationParty} is in the
47 * {@link MultilateralProtocol#getRoundStructure(java.util.List, negotiator.session.Session)}
48 * .
49 *
50 * @param possibleActions
51 * List of all actions possible.
52 * @return The chosen action
53 */
54 @Override
55 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
56 Bid nextBid = getNextBid();
57 double lastUtil = lastBid != null ? utilitySpace.getUtilityWithDiscount(lastBid, timeline) : 0;
58 double nextUtil = nextBid != null ? utilitySpace.getUtilityWithDiscount(nextBid, timeline) : 0;
59
60 // Accept is for both voting and counter offer protocols
61 if (possibleActions.contains(Accept.class) && nextUtil < lastUtil)
62 return new Accept(getPartyId(), lastBid);
63
64 // Counter offer based actions
65 else if (possibleActions.contains(Offer.class))
66 return new Offer(getPartyId(), nextBid);
67
68 // Voting based actions
69 else if (possibleActions.contains(OfferForVoting.class))
70 return new OfferForVoting(getPartyId(), nextBid);
71 else if (possibleActions.contains(Reject.class))
72 return new Reject(getPartyId(), lastBid); // Accept is higher up the
73 // chain
74
75 // default action
76 else
77 return new NoAction(getPartyId());
78 }
79
80 /**
81 * Get the next bid we should do
82 */
83 protected Bid getNextBid() {
84 return outcomeSpace.getBidNearUtility(getTargetUtility()).getBid();
85 }
86
87 /**
88 * This method is called when an observable action is performed. Observable
89 * actions are defined in
90 * {@link MultilateralProtocol#getActionListeners(java.util.List)}
91 *
92 * @param sender
93 * The initiator of the action
94 * @param arguments
95 * The action performed
96 */
97 @Override
98 public void receiveMessage(AgentID sender, Action arguments) {
99 if (arguments instanceof Offer)
100 lastBid = ((Offer) arguments).getBid();
101 }
102
103 /**
104 * Gets the target utility for the next bid
105 *
106 * @return The target utility for the given time
107 */
108 public double getTargetUtility() {
109
110 // timeline runs from 0.0 to 1.0
111
112 // we have a slight offset because discrete timeline is 1-based, this
113 // needs to be addressed
114 double offset = timeline instanceof DiscreteTimeline ? 1d / ((DiscreteTimeline) timeline).getTotalRounds() : 0d;
115 return 1d - f(timeline.getTime() - offset);
116 }
117
118 /**
119 * From [1]:
120 *
121 * A wide range of time dependent functions can be defined by varying the
122 * way in which f(t) is computed. However, functions must ensure that 0 <=
123 * f(t) <= 1, f(0) = k, and f(1) = 1.
124 *
125 * That is, the offer will always be between the value range, at the
126 * beginning it will give the initial constant and when the deadline is
127 * reached, it will offer the reservation value.
128 *
129 * For e = 0 (special case), it will behave as a Hardliner.
130 */
131 public double f(double t) {
132 if (getE() == 0) {
133 return 0;
134 }
135 return pow(t, 1 / getE());
136 }
137
138 /**
139 * Depending on the value of e, extreme sets show clearly different patterns
140 * of behaviour [1]:
141 *
142 * 1. Boulware: For this strategy e < 1 and the initial offer is maintained
143 * till time is almost exhausted, when the agent concedes up to its
144 * reservation value.
145 *
146 * 2. Conceder: For this strategy e > 1 and the agent goes to its
147 * reservation value very quickly.
148 *
149 * 3. When e = 1, the price is increased linearly.
150 *
151 * 4. When e = 0, the agent plays hardball.
152 */
153 public abstract double getE();
154}
Note: See TracBrowser for help on using the repository browser.