1 | package agents.anac.y2015.agentBuyogV2;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.List;
|
---|
5 | import java.util.Map.Entry;
|
---|
6 |
|
---|
7 | import genius.core.Bid;
|
---|
8 | import genius.core.BidHistory;
|
---|
9 | import genius.core.bidding.BidDetails;
|
---|
10 | import genius.core.issue.IssueDiscrete;
|
---|
11 | import genius.core.issue.IssueInteger;
|
---|
12 | import genius.core.issue.Objective;
|
---|
13 | import genius.core.issue.ValueDiscrete;
|
---|
14 | import genius.core.issue.ValueInteger;
|
---|
15 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
16 | import genius.core.utility.Evaluator;
|
---|
17 | import genius.core.utility.EvaluatorDiscrete;
|
---|
18 | import genius.core.utility.EvaluatorInteger;
|
---|
19 |
|
---|
20 | public class OpponentInfo {
|
---|
21 |
|
---|
22 | private String agentID;
|
---|
23 | private BidHistory agentBidHistory, bestBids;
|
---|
24 | private AdditiveUtilitySpace utilitySpace;
|
---|
25 | private Double leniency, domainCompetitiveness, agentDifficulty;
|
---|
26 | private Bid bestBid;
|
---|
27 | private List<Integer> bidPointWeights;
|
---|
28 |
|
---|
29 | public OpponentInfo(String agentID, AdditiveUtilitySpace utilitySpace){
|
---|
30 | this.agentID = agentID;
|
---|
31 | this.agentBidHistory = new BidHistory();
|
---|
32 | this.bestBids = new BidHistory();
|
---|
33 | this.domainCompetitiveness = null;
|
---|
34 | this.leniency = null;
|
---|
35 | this.utilitySpace = new AdditiveUtilitySpace(utilitySpace);
|
---|
36 | this.bidPointWeights = new ArrayList<Integer>();
|
---|
37 | this.agentDifficulty = null;
|
---|
38 |
|
---|
39 | initializeOpponentUtilitySpace();
|
---|
40 |
|
---|
41 | }
|
---|
42 |
|
---|
43 | private void initializeOpponentUtilitySpace() {
|
---|
44 | int numberOfIssues = utilitySpace.getDomain().getIssues().size();
|
---|
45 | double commonWeight = 1D/numberOfIssues;
|
---|
46 | //An evaluator for an issue contains a list of issue value evaluations as well as the weight of that issue.
|
---|
47 | //Each issue has one evaluator.
|
---|
48 | for(Entry<Objective, Evaluator> issueEvaluatorEntry : utilitySpace.getEvaluators()){
|
---|
49 | utilitySpace.unlock(issueEvaluatorEntry.getKey());
|
---|
50 | issueEvaluatorEntry.getValue().setWeight(commonWeight);
|
---|
51 |
|
---|
52 | if(issueEvaluatorEntry.getKey() instanceof IssueDiscrete){
|
---|
53 | for(ValueDiscrete value: ((IssueDiscrete) issueEvaluatorEntry.getKey()).getValues()){
|
---|
54 | try {
|
---|
55 | ((EvaluatorDiscrete) issueEvaluatorEntry.getValue()).setEvaluation(value, 1);
|
---|
56 | } catch (Exception e) {
|
---|
57 | // TODO Auto-generated catch block
|
---|
58 | e.printStackTrace();
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 | else if(issueEvaluatorEntry.getKey() instanceof IssueInteger){
|
---|
63 | ((EvaluatorInteger) issueEvaluatorEntry.getValue()).setLinearFunction(0.5, 0.5);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * @return the agentID
|
---|
71 | */
|
---|
72 | public String getAgentID() {
|
---|
73 | return agentID;
|
---|
74 | }
|
---|
75 | /**
|
---|
76 | * @param agentID the agentID to set
|
---|
77 | */
|
---|
78 | public void setAgentID(String agentID) {
|
---|
79 | this.agentID = agentID;
|
---|
80 | }
|
---|
81 | /**
|
---|
82 | * @return the agentBidHistory
|
---|
83 | */
|
---|
84 | public BidHistory getAgentBidHistory() {
|
---|
85 | return agentBidHistory;
|
---|
86 | }
|
---|
87 | /**
|
---|
88 | * @param agentBidHistory the agentBidHistory to set
|
---|
89 | */
|
---|
90 | public void setAgentBidHistory(BidHistory agentBidHistory) {
|
---|
91 | this.agentBidHistory = agentBidHistory;
|
---|
92 | }
|
---|
93 | /**
|
---|
94 | * @return the bestBids
|
---|
95 | */
|
---|
96 | public BidHistory getBestBids() {
|
---|
97 | return bestBids;
|
---|
98 | }
|
---|
99 | /**
|
---|
100 | * @param bestBids the bestBids to set
|
---|
101 | */
|
---|
102 | public void setBestBids(BidHistory bestBids) {
|
---|
103 | this.bestBids = bestBids;
|
---|
104 | }
|
---|
105 | /**
|
---|
106 | * @return the opponentUtilitySpace
|
---|
107 | */
|
---|
108 | public AdditiveUtilitySpace getOpponentUtilitySpace() {
|
---|
109 | return utilitySpace;
|
---|
110 | }
|
---|
111 | /**
|
---|
112 | * @param opponentUtilitySpace the opponentUtilitySpace to set
|
---|
113 | */
|
---|
114 | public void setOpponentUtilitySpace(AdditiveUtilitySpace opponentUtilitySpace) {
|
---|
115 | this.utilitySpace = opponentUtilitySpace;
|
---|
116 | }
|
---|
117 | /**
|
---|
118 | * @return the leniency
|
---|
119 | */
|
---|
120 | public Double getLeniency() {
|
---|
121 | return leniency;
|
---|
122 | }
|
---|
123 | /**
|
---|
124 | * @param leniency the leniency to set
|
---|
125 | */
|
---|
126 | public void setLeniency(Double leniency) {
|
---|
127 | this.leniency = leniency;
|
---|
128 | }
|
---|
129 | /**
|
---|
130 | * @return the domainCompetitiveness
|
---|
131 | */
|
---|
132 | public Double getDomainCompetitiveness() {
|
---|
133 | return domainCompetitiveness;
|
---|
134 | }
|
---|
135 | /**
|
---|
136 | * @param domainCompetitiveness the domainCompetitiveness to set
|
---|
137 | */
|
---|
138 | public void setDomainCompetitiveness(Double domainCompetitiveness) {
|
---|
139 | this.domainCompetitiveness = domainCompetitiveness;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * @return the bestBi
|
---|
144 | */
|
---|
145 | public Bid getBestBid() {
|
---|
146 | return bestBid;
|
---|
147 | }
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * @param bestBidUtility the bestBidUtility to set
|
---|
151 | */
|
---|
152 | public void setBestBid(Bid bestBid) {
|
---|
153 | this.bestBid = bestBid;
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * @return the weights
|
---|
159 | */
|
---|
160 | public List<Integer> getBidPointWeights() {
|
---|
161 | return bidPointWeights;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * @param weights the weights to set
|
---|
166 | */
|
---|
167 | public void setBidPointWeights(List<Integer> weights) {
|
---|
168 | this.bidPointWeights = weights;
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * @return the agentDifficulty
|
---|
175 | */
|
---|
176 | public Double getAgentDifficulty() {
|
---|
177 | return agentDifficulty;
|
---|
178 | }
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * @param agentDifficulty the agentDifficulty to set
|
---|
182 | */
|
---|
183 | public void setAgentDifficulty(Double agentDifficulty) {
|
---|
184 | this.agentDifficulty = agentDifficulty;
|
---|
185 | }
|
---|
186 |
|
---|
187 | public boolean containsBid(Bid bid) {
|
---|
188 | for(BidDetails bidDetails: this.agentBidHistory.getHistory()){
|
---|
189 | if(bidDetails.getBid().equals(bid)){
|
---|
190 | return true;
|
---|
191 | }
|
---|
192 | }
|
---|
193 | return false;
|
---|
194 | }
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|
198 |
|
---|
199 |
|
---|
200 |
|
---|
201 | }
|
---|