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