source: src/main/java/genius/core/boaframework/OMStrategy.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: 4.2 KB
Line 
1package genius.core.boaframework;
2
3import java.io.Serializable;
4import java.util.List;
5import java.util.Map;
6
7import genius.core.bidding.BidDetails;
8import genius.core.misc.Range;
9
10/**
11 * This is the abstract class which determines when the opponent model may be
12 * updated, and how it used to select a bid for the opponent.
13 *
14 * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
15 * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
16 * Strategies
17 *
18 * @author Mark Hendrikx
19 */
20public abstract class OMStrategy extends BOA {
21
22 /** Reference to the opponent model */
23 protected OpponentModel model;
24 /**
25 * Increment used to increase the upperbound in case no bid is found in the
26 * range
27 */
28 private final double RANGE_INCREMENT = 0.01;
29 /** Amount of bids expected in window */
30 private final int EXPECTED_BIDS_IN_WINDOW = 100;
31 /**
32 * Intitial range which is being searched for similarly preferable bids.
33 * This range is increased with the RANGE_INCREMENT until
34 * EXPECTED_BIDS_IN_WINDOW are found or the window is of maximum size
35 */
36 private final double INITIAL_WINDOW_RANGE = 0.01;
37
38 /**
39 * Initialize method to be used by the BOA framework.
40 *
41 * @param negotiationSession
42 * state of the negotiation.
43 * @param model
44 * opponent model to which the opponent model strategy applies.
45 * @param parameters
46 * for the opponent model strategy, for example the maximum
47 * receiveMessage time.
48 */
49 public void init(NegotiationSession negotiationSession, OpponentModel model, Map<String, Double> parameters) {
50 super.init(negotiationSession, parameters);
51 this.model = model;
52 }
53
54 /**
55 * Returns a bid selected using the opponent model from the given set of
56 * similarly preferred bids.
57 *
58 * @param bidsInRange
59 * set of similarly preferred bids
60 * @return bid
61 */
62 public abstract BidDetails getBid(List<BidDetails> bidsInRange);
63
64 /**
65 * Returns a bid selected using the opponent model with a utility in the
66 * given range.
67 *
68 * @param space
69 * of all possible outcomes
70 * @param range
71 * of utility
72 * @return bid
73 */
74 public BidDetails getBid(OutcomeSpace space, Range range) {
75 List<BidDetails> bids = space.getBidsinRange(range);
76 if (bids.size() == 0) {
77 if (range.getUpperbound() < 1.01) {
78 range.increaseUpperbound(RANGE_INCREMENT);
79 return getBid(space, range);
80 } else {
81 negotiationSession.setOutcomeSpace(space);
82 return negotiationSession.getMaxBidinDomain();
83 }
84 }
85 return getBid(bids);
86 }
87
88 public void setOpponentModel(OpponentModel model) {
89 this.model = model;
90 }
91
92 /**
93 * Use this method in case no range is specified, but only a target utility.
94 *
95 * This method has two steps: First a set of bids is generated using the
96 * following procedure. The method looks at the bids in the range
97 * [targetUtility, targetUtility + INITIAL_WINDOW_RANGE]. If there are less
98 * than EXPECTED_BIDS_IN_WINDOW in the window, then the upperbound is
99 * increased by RANGE_INCREMENT.
100 *
101 * Second a bid for the opponent is selected by calling
102 * getBid(List<BidDetails> bidsInRange) with the generated set.
103 *
104 * @param space
105 * of all possible outcomes
106 * @param targetUtility
107 * minimum utility to
108 * @return bid selected by using the opponent model strategy.
109 */
110 public BidDetails getBid(SortedOutcomeSpace space, double targetUtility) {
111 Range range = new Range(targetUtility, targetUtility + INITIAL_WINDOW_RANGE);
112 List<BidDetails> bids = space.getBidsinRange(range);
113 if (bids.size() < EXPECTED_BIDS_IN_WINDOW) {
114 if (range.getUpperbound() < 1.01) {
115 range.increaseUpperbound(RANGE_INCREMENT);
116 return getBid(space, range);
117 } else {
118 // futher increasing the window does not help
119 return getBid(bids);
120 }
121 }
122 return getBid(bids);
123 }
124
125 /**
126 * @return if given the negotiation state the opponent model may be updated
127 */
128 public abstract boolean canUpdateOM();
129
130 @Override
131 public final void storeData(Serializable object) {
132 }
133
134 @Override
135 public final Serializable loadData() {
136 return null;
137 }
138
139}
Note: See TracBrowser for help on using the repository browser.