source: src/main/java/agents/anac/y2014/BraveCat/OpponentModelStrategies/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: 2.2 KB
Line 
1 package agents.anac.y2014.BraveCat.OpponentModelStrategies;
2
3 import agents.anac.y2014.BraveCat.OpponentModels.OpponentModel;
4 import java.util.HashMap;
5 import java.util.List;
6
7import agents.anac.y2014.BraveCat.necessaryClasses.NegotiationSession;
8 import agents.anac.y2014.BraveCat.necessaryClasses.OutcomeSpace;
9 import agents.anac.y2014.BraveCat.necessaryClasses.SortedOutcomeSpace;
10import genius.core.bidding.BidDetails;
11import genius.core.misc.Range;
12
13 public abstract class OMStrategy
14 {
15 protected NegotiationSession negotiationSession;
16 protected OpponentModel model;
17 private final double RANGE_INCREMENT = 0.01D;
18
19 private final int EXPECTED_BIDS_IN_WINDOW = 100;
20
21 private final double INITIAL_WINDOW_RANGE = 0.01D;
22
23 public void init(NegotiationSession negotiationSession, OpponentModel model, HashMap<String, Double> parameters)
24 throws Exception
25 {
26 this.negotiationSession = negotiationSession;
27 this.model = model;
28 }
29
30 public void init(NegotiationSession negotiationSession, OpponentModel model)
31 throws Exception
32 {
33 this.negotiationSession = negotiationSession;
34 this.model = model;
35 }
36
37 public abstract BidDetails getBid(List<BidDetails> paramList);
38
39 public BidDetails getBid(OutcomeSpace space, Range range)
40 {
41 List bids = space.getBidsinRange(range);
42 if (bids.size() == 0) {
43 if (range.getUpperbound() < 1.01D) {
44 range.increaseUpperbound(0.01D);
45 return getBid(space, range);
46 }
47 this.negotiationSession.setOutcomeSpace(space);
48 return this.negotiationSession.getMaxBidinDomain();
49 }
50
51 return getBid(bids);
52 }
53
54 public void setOpponentModel(OpponentModel model) {
55 this.model = model;
56 }
57
58 public BidDetails getBid(SortedOutcomeSpace space, double targetUtility)
59 {
60 Range range = new Range(targetUtility, targetUtility + 0.01D);
61 List bids = space.getBidsinRange(range);
62 if (bids.size() < 100) {
63 if (range.getUpperbound() < 1.01D) {
64 range.increaseUpperbound(0.01D);
65 return getBid(space, range);
66 }
67
68 return getBid(bids);
69 }
70
71 return getBid(bids);
72 }
73
74 public abstract boolean canUpdateOM();
75 }
Note: See TracBrowser for help on using the repository browser.