1 | package negotiator.parties;
|
---|
2 |
|
---|
3 | import static java.lang.Math.pow;
|
---|
4 |
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import genius.core.AgentID;
|
---|
8 | import genius.core.Bid;
|
---|
9 | import genius.core.actions.Accept;
|
---|
10 | import genius.core.actions.Action;
|
---|
11 | import genius.core.actions.NoAction;
|
---|
12 | import genius.core.actions.Offer;
|
---|
13 | import genius.core.actions.OfferForVoting;
|
---|
14 | import genius.core.actions.Reject;
|
---|
15 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
16 | import genius.core.parties.AbstractNegotiationParty;
|
---|
17 | import genius.core.parties.NegotiationInfo;
|
---|
18 | import genius.core.protocol.MultilateralProtocol;
|
---|
19 | import 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 Tim Baarslag, Mark Hendrikx
|
---|
31 | */
|
---|
32 | public abstract class AbstractTimeDependentNegotiationParty extends AbstractNegotiationParty
|
---|
33 | {
|
---|
34 | SortedOutcomeSpace outcomeSpace;
|
---|
35 | Bid lastReceivedBid = null;
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void init(NegotiationInfo info)
|
---|
39 | {
|
---|
40 | super.init(info);
|
---|
41 | outcomeSpace = new SortedOutcomeSpace(getUtilitySpace());
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * When this class is called, it is expected that the Party chooses one of
|
---|
46 | * the actions from the possible action list and returns an instance of the
|
---|
47 | * chosen action. This class is only called if this
|
---|
48 | * {@link genius.core.parties.NegotiationParty} is in the
|
---|
49 | * {@link MultilateralProtocol#getRoundStructure(java.util.List, negotiator.session.Session)}
|
---|
50 | * .
|
---|
51 | *
|
---|
52 | * @param possibleActions
|
---|
53 | * List of all actions possible.
|
---|
54 | * @return The chosen action
|
---|
55 | */
|
---|
56 | @Override
|
---|
57 | public Action chooseAction(List<Class<? extends Action>> possibleActions) {
|
---|
58 | Bid nextBid = getNextBid();
|
---|
59 | double lastUtil = lastReceivedBid != null ? utilitySpace.getUtilityWithDiscount(lastReceivedBid, timeline) : 0;
|
---|
60 | double nextUtil = nextBid != null ? utilitySpace.getUtilityWithDiscount(nextBid, timeline) : 0;
|
---|
61 |
|
---|
62 | // Accept is for both voting and counter offer protocols
|
---|
63 | if (possibleActions.contains(Accept.class) && nextUtil < lastUtil)
|
---|
64 | return new Accept(getPartyId(), lastReceivedBid);
|
---|
65 |
|
---|
66 | // Counter offer based actions
|
---|
67 | else if (possibleActions.contains(Offer.class))
|
---|
68 | return new Offer(getPartyId(), nextBid);
|
---|
69 |
|
---|
70 | // Voting based actions
|
---|
71 | else if (possibleActions.contains(OfferForVoting.class))
|
---|
72 | return new OfferForVoting(getPartyId(), nextBid);
|
---|
73 | else if (possibleActions.contains(Reject.class))
|
---|
74 | return new Reject(getPartyId(), lastReceivedBid); // Accept is higher up the chain
|
---|
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 | lastReceivedBid = ((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 | double target = 1d - f(timeline.getTime() - offset);
|
---|
116 | // System.out.println("Target util: " + target);
|
---|
117 | return target;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * From [1]:
|
---|
122 | *
|
---|
123 | * A wide range of time dependent functions can be defined by varying the
|
---|
124 | * way in which f(t) is computed. However, functions must ensure that 0 <=
|
---|
125 | * f(t) <= 1, f(0) = k, and f(1) = 1.
|
---|
126 | *
|
---|
127 | * That is, the offer will always be between the value range, at the
|
---|
128 | * beginning it will give the initial constant and when the deadline is
|
---|
129 | * reached, it will offer the reservation value.
|
---|
130 | *
|
---|
131 | * For e = 0 (special case), it will behave as a Hardliner.
|
---|
132 | */
|
---|
133 | public double f(double t) {
|
---|
134 | if (getE() == 0) {
|
---|
135 | return 0;
|
---|
136 | }
|
---|
137 | return pow(t, 1 / getE());
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Depending on the value of e, extreme sets show clearly different patterns
|
---|
142 | * of behaviour [1]:
|
---|
143 | *
|
---|
144 | * 1. Boulware: For this strategy e < 1 and the initial offer is maintained
|
---|
145 | * till time is almost exhausted, when the agent concedes up to its
|
---|
146 | * reservation value.
|
---|
147 | *
|
---|
148 | * 2. Conceder: For this strategy e > 1 and the agent goes to its
|
---|
149 | * reservation value very quickly.
|
---|
150 | *
|
---|
151 | * 3. When e = 1, the price is increased linearly.
|
---|
152 | *
|
---|
153 | * 4. When e = 0, the agent plays hardball.
|
---|
154 | */
|
---|
155 | public abstract double getE();
|
---|
156 | }
|
---|