source: src/main/java/negotiator/boaframework/omstrategy/NullStrategy.java

Last change on this file was 165, checked in by Tim Baarslag, 6 years ago

Cleanup of BOA repository

File size: 2.8 KB
Line 
1package negotiator.boaframework.omstrategy;
2
3import java.util.List;
4
5import java.util.HashMap;
6import java.util.HashSet;
7import java.util.Set;
8
9import agents.anac.y2012.TheNegotiatorReloaded.TheNegotiatorReloaded;
10import genius.core.bidding.BidDetails;
11import genius.core.boaframework.BOAparameter;
12import genius.core.boaframework.NegotiationSession;
13import genius.core.boaframework.OMStrategy;
14import genius.core.boaframework.OpponentModel;
15
16/**
17 * Baseline strategy which simply returns a random bid from the given array of
18 * bids. Basically, the opponent model is ignored.
19 *
20 * @author Mark Hendrikx
21 */
22public class NullStrategy extends OMStrategy {
23
24 /**
25 * when to stop updating the opponentmodel. Note that this value is not
26 * exactly one as a match sometimes lasts slightly longer.
27 */
28 private double updateThreshold = 1.1;
29
30 /**
31 * Empty constructor used for reflexion. Note this constructor assumes that
32 * init is called next.
33 */
34 public NullStrategy() {
35 }
36
37 /**
38 * Special constructor for {@link TheNegotiatorReloaded}
39 *
40 * @param negotiationSession
41 * nego session
42 * @param time
43 * update time
44 */
45 public NullStrategy(NegotiationSession negotiationSession, double time) {
46 this.negotiationSession = negotiationSession;
47 updateThreshold = time;
48 }
49
50 /**
51 * Normal constructor used to initialize the NullStrategy opponent model
52 * strategy.
53 *
54 * @param negotiationSession
55 * symbolizing the negotiation state.
56 */
57 public NullStrategy(NegotiationSession negotiationSession) {
58 this.negotiationSession = negotiationSession;
59 }
60
61 public void init(NegotiationSession negotiationSession, OpponentModel model, HashMap<String, Double> parameters)
62 throws Exception {
63 super.init(negotiationSession, model, parameters);
64 this.negotiationSession = negotiationSession;
65 if (parameters.containsKey("t")) {
66 updateThreshold = parameters.get("t");
67 }
68 }
69
70 /**
71 * Returns a random bid from the give array of similarly preferred bids.
72 *
73 * @param allBids
74 * list of similarly preferred bids.
75 * @return random bid from given array.
76 */
77 @Override
78 public BidDetails getBid(List<BidDetails> allBids) {
79 return allBids.get(0);
80 }
81
82 /**
83 * Returns true if the opponent model be updated, which is in this case if
84 * the time is lower than the given threshold.
85 *
86 * @return true if model may be updated.
87 */
88 @Override
89 public boolean canUpdateOM() {
90 return negotiationSession.getTime() < updateThreshold;
91 }
92
93 @Override
94 public Set<BOAparameter> getParameterSpec() {
95 Set<BOAparameter> set = new HashSet<BOAparameter>();
96 set.add(new BOAparameter("t", 1.1, "Time after which the OM should not be updated"));
97 return set;
98 }
99
100 @Override
101 public String getName() {
102 return "Random";
103 }
104}
Note: See TracBrowser for help on using the repository browser.