1 | package agents.anac.y2014.BraveCat.OpponentModels;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.util.HashMap;
|
---|
5 |
|
---|
6 | import agents.anac.y2014.BraveCat.necessaryClasses.NegotiationSession;
|
---|
7 | import genius.core.Bid;
|
---|
8 | import genius.core.NegotiationResult;
|
---|
9 | import genius.core.bidding.BidDetails;
|
---|
10 | import genius.core.boaframework.BoaType;
|
---|
11 | import genius.core.issue.Issue;
|
---|
12 | import genius.core.protocol.BilateralAtomicNegotiationSession;
|
---|
13 | import genius.core.utility.AbstractUtilitySpace;
|
---|
14 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
15 | import genius.core.utility.UTILITYSPACETYPE;
|
---|
16 |
|
---|
17 | public abstract class OpponentModel {
|
---|
18 | protected NegotiationSession negotiationSession;
|
---|
19 | protected AbstractUtilitySpace opponentUtilitySpace;
|
---|
20 | private boolean cleared;
|
---|
21 |
|
---|
22 | public void init(NegotiationSession negotiationSession, HashMap<String, Double> parameters,
|
---|
23 | UTILITYSPACETYPE utilitySpaceType) throws Exception {
|
---|
24 | this.negotiationSession = negotiationSession;
|
---|
25 | this.opponentUtilitySpace = (AbstractUtilitySpace) negotiationSession.getUtilitySpace().copy();
|
---|
26 | this.cleared = false;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public void init(NegotiationSession negotiationSession) throws Exception {
|
---|
30 | this.negotiationSession = negotiationSession;
|
---|
31 | this.cleared = false;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public void init(NegotiationSession negotiationSession, UTILITYSPACETYPE utilitySpaceType) throws Exception {
|
---|
35 | this.negotiationSession = negotiationSession;
|
---|
36 | this.opponentUtilitySpace = (AbstractUtilitySpace) negotiationSession.getUtilitySpace().copy();
|
---|
37 | this.cleared = false;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void updateModel(Bid opponentBid) {
|
---|
41 | updateModel(opponentBid, this.negotiationSession.getTime());
|
---|
42 | }
|
---|
43 |
|
---|
44 | public abstract void updateModel(Bid paramBid, double paramDouble);
|
---|
45 |
|
---|
46 | public double getBidEvaluation(Bid bid) throws Exception {
|
---|
47 | try {
|
---|
48 | return this.opponentUtilitySpace.getUtility(bid);
|
---|
49 | } catch (Exception e) {
|
---|
50 | }
|
---|
51 | return -1.0D;
|
---|
52 | }
|
---|
53 |
|
---|
54 | public double getBidEvaluation(BidDetails bid) throws Exception {
|
---|
55 | return 0;
|
---|
56 | }
|
---|
57 |
|
---|
58 | public double getRealBidEvaluation(Bid bid) throws Exception {
|
---|
59 | return 0;
|
---|
60 | }
|
---|
61 |
|
---|
62 | public AbstractUtilitySpace getOpponentUtilitySpace() {
|
---|
63 | return this.opponentUtilitySpace;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public void setOpponentUtilitySpace(BilateralAtomicNegotiationSession fNegotiation) {
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void setOpponentUtilitySpace(AdditiveUtilitySpace opponentUtilitySpace) {
|
---|
70 | }
|
---|
71 |
|
---|
72 | public double getWeight(Issue issue) {
|
---|
73 | if (opponentUtilitySpace instanceof AdditiveUtilitySpace) {
|
---|
74 | return ((AdditiveUtilitySpace) this.opponentUtilitySpace).getWeight(issue.getNumber());
|
---|
75 | }
|
---|
76 | return 0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | public double[] getIssueWeights() {
|
---|
80 | double[] estimatedIssueWeights = new double[this.negotiationSession.getUtilitySpace().getDomain().getIssues()
|
---|
81 | .size()];
|
---|
82 | int i = 0;
|
---|
83 | for (Issue issue : this.negotiationSession.getUtilitySpace().getDomain().getIssues()) {
|
---|
84 | estimatedIssueWeights[i] = getWeight(issue);
|
---|
85 | i++;
|
---|
86 | }
|
---|
87 | return estimatedIssueWeights;
|
---|
88 | }
|
---|
89 |
|
---|
90 | public void cleanUp() {
|
---|
91 | this.negotiationSession = null;
|
---|
92 | this.cleared = true;
|
---|
93 | }
|
---|
94 |
|
---|
95 | public boolean isCleared() {
|
---|
96 | return this.cleared;
|
---|
97 | }
|
---|
98 |
|
---|
99 | public String getName() {
|
---|
100 | return "Default";
|
---|
101 | }
|
---|
102 |
|
---|
103 | public final void storeData(Serializable object) {
|
---|
104 | this.negotiationSession.setData(BoaType.OPPONENTMODEL, object);
|
---|
105 | }
|
---|
106 |
|
---|
107 | public final Serializable loadData() {
|
---|
108 | return this.negotiationSession.getData(BoaType.OPPONENTMODEL);
|
---|
109 | }
|
---|
110 |
|
---|
111 | public void endSession(NegotiationResult result) {
|
---|
112 | }
|
---|
113 | } |
---|