1 | package negotiator.boaframework.offeringstrategy.other;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 |
|
---|
5 | import genius.core.bidding.BidDetails;
|
---|
6 | import genius.core.boaframework.NegotiationSession;
|
---|
7 | import genius.core.boaframework.OMStrategy;
|
---|
8 | import genius.core.boaframework.OfferingStrategy;
|
---|
9 | import genius.core.boaframework.OpponentModel;
|
---|
10 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * This class implements an offering strategy which creates a list of possible
|
---|
14 | * bids and then offers them in descending order. If all bids are offered, then
|
---|
15 | * the last bid is repeated.
|
---|
16 | *
|
---|
17 | * This strategy has no straight-forward extension of using opponent models.
|
---|
18 | *
|
---|
19 | * @author Alex Dirkzwager, Mark Hendrikx
|
---|
20 | * @version 15-12-11
|
---|
21 | */
|
---|
22 | public class ChoosingAllBids extends OfferingStrategy {
|
---|
23 | /**
|
---|
24 | * counter used to determine which bid to offer from the sorted list of
|
---|
25 | * possible bids
|
---|
26 | */
|
---|
27 | private int counter = 0;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Empty constructor used for reflexion. Note this constructor assumes that
|
---|
31 | * init is called next.
|
---|
32 | */
|
---|
33 | public ChoosingAllBids() {
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Constructor which can be used to createFrom the agent without the GUI.
|
---|
38 | *
|
---|
39 | * @param negoSession
|
---|
40 | * reference to the negotiationsession object
|
---|
41 | * @param model
|
---|
42 | * reference to the opponent model
|
---|
43 | */
|
---|
44 | public ChoosingAllBids(NegotiationSession negoSession, OpponentModel model) {
|
---|
45 | initializeAgent(negoSession, model);
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public void init(NegotiationSession domainKnow, OpponentModel model, OMStrategy omStrat,
|
---|
50 | Map<String, Double> parameters) throws Exception {
|
---|
51 | initializeAgent(domainKnow, model);
|
---|
52 | }
|
---|
53 |
|
---|
54 | private void initializeAgent(NegotiationSession negoSession, OpponentModel model) {
|
---|
55 | this.negotiationSession = negoSession;
|
---|
56 |
|
---|
57 | SortedOutcomeSpace space = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
58 | negotiationSession.setOutcomeSpace(space);
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Returns the next bid in the sorted array of bids. If there are no more
|
---|
63 | * bids in the list, then the last bid is returned.
|
---|
64 | */
|
---|
65 | @Override
|
---|
66 | public BidDetails determineNextBid() {
|
---|
67 | nextBid = negotiationSession.getOutcomeSpace().getAllOutcomes().get(counter);
|
---|
68 | if (counter < negotiationSession.getOutcomeSpace().getAllOutcomes().size() - 1) {
|
---|
69 | counter++;
|
---|
70 | }
|
---|
71 |
|
---|
72 | return nextBid;
|
---|
73 | }
|
---|
74 |
|
---|
75 | @Override
|
---|
76 | public BidDetails determineOpeningBid() {
|
---|
77 | return determineNextBid();
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Override
|
---|
81 | public String getName() {
|
---|
82 | return "Other - ChoosingAllBids";
|
---|
83 | }
|
---|
84 | } |
---|