source: src/main/java/negotiator/boaframework/offeringstrategy/other/ChoosingAllBids.java

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

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 2.4 KB
Line 
1package negotiator.boaframework.offeringstrategy.other;
2
3import java.util.Map;
4
5import genius.core.bidding.BidDetails;
6import genius.core.boaframework.NegotiationSession;
7import genius.core.boaframework.OMStrategy;
8import genius.core.boaframework.OfferingStrategy;
9import genius.core.boaframework.OpponentModel;
10import 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 */
22public 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}
Note: See TracBrowser for help on using the repository browser.