1 | package parties.in4010.q12015.group7;
|
---|
2 |
|
---|
3 | import java.util.HashMap;
|
---|
4 | import java.util.Map;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | import genius.core.AgentID;
|
---|
8 | import genius.core.Bid;
|
---|
9 | import genius.core.BidHistory;
|
---|
10 | import genius.core.bidding.BidDetails;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Keep track of IssueEstimators of multiple opponents with the
|
---|
14 | * MultipleIssueEstimator
|
---|
15 | *
|
---|
16 | * @author svanbekhoven
|
---|
17 | *
|
---|
18 | */
|
---|
19 | public class MultipleIssueEstimator {
|
---|
20 | /**
|
---|
21 | * BidHistories of all opponents
|
---|
22 | */
|
---|
23 | private HashMap<AgentID, IssueEstimator> issueEstimators;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * IssueEstimator sensitivity parameter
|
---|
27 | */
|
---|
28 | private double n;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Constructor
|
---|
32 | *
|
---|
33 | * @param n
|
---|
34 | * sensitivity parameter
|
---|
35 | */
|
---|
36 | public MultipleIssueEstimator(double n) {
|
---|
37 | this.n = n;
|
---|
38 | this.issueEstimators = new HashMap<AgentID, IssueEstimator>();
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Add a bid to the issueEstimator of a particular agent
|
---|
43 | *
|
---|
44 | * @param agentId
|
---|
45 | * @param bidDetails
|
---|
46 | * @param bidHistory
|
---|
47 | */
|
---|
48 | public void addBid(AgentID agentId, BidDetails bidDetails,
|
---|
49 | BidHistory bidHistory) {
|
---|
50 | if (!this.issueEstimators.containsKey(agentId)) {
|
---|
51 | this.issueEstimators.put(agentId, new IssueEstimator(this.n));
|
---|
52 | }
|
---|
53 | this.issueEstimators.get(agentId).addBid(bidDetails.getBid(),
|
---|
54 | bidHistory);
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Returns the issueEstimator of a particular agent
|
---|
59 | *
|
---|
60 | * @param agentId
|
---|
61 | * @return
|
---|
62 | */
|
---|
63 | public IssueEstimator getIssueEstimator(AgentID agentId) {
|
---|
64 | return issueEstimators.get(agentId);
|
---|
65 | }
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Returns all issueEstimators
|
---|
69 | *
|
---|
70 | * @return
|
---|
71 | */
|
---|
72 | public HashMap<AgentID, IssueEstimator> getIssueEstimators() {
|
---|
73 | return issueEstimators;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Returns the average estimated utility of a bid for all opponents
|
---|
78 | *
|
---|
79 | * @param bid
|
---|
80 | * @return
|
---|
81 | */
|
---|
82 | public double getAverageUtility(Bid bid) {
|
---|
83 | double sum = 0;
|
---|
84 | for (Map.Entry<AgentID, IssueEstimator> entry : issueEstimators
|
---|
85 | .entrySet()) {
|
---|
86 | sum += entry.getValue().getUtility(bid);
|
---|
87 | }
|
---|
88 |
|
---|
89 | return sum / issueEstimators.size();
|
---|
90 | }
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Returns the set of AgentIds in this MultipleIssueEstimator
|
---|
94 | *
|
---|
95 | * @return
|
---|
96 | */
|
---|
97 | public Set<AgentID> getAgentIds() {
|
---|
98 | return this.issueEstimators.keySet();
|
---|
99 | }
|
---|
100 | } |
---|