source: src/main/java/parties/in4010/q12015/group7/MultipleBidHistory.java@ 126

Last change on this file since 126 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 2.0 KB
Line 
1package parties.in4010.q12015.group7;
2
3import java.util.HashMap;
4import java.util.Set;
5
6import genius.core.AgentID;
7import genius.core.bidding.BidDetails;
8
9/**
10 * Keep track of bid histories of multiple agents using this MultipleBidHistory
11 *
12 * @author svanbekhoven
13 *
14 */
15public class MultipleBidHistory {
16 /**
17 * BidHistories of all agent distinct
18 */
19 private HashMap<AgentID, EnhancedBidHistory> bidHistories;
20
21 /**
22 * BidHistories of all agents combined
23 */
24 private EnhancedBidHistory combinedBidHistory;
25
26 /**
27 * Constructor
28 */
29 public MultipleBidHistory() {
30 this.bidHistories = new HashMap<AgentID, EnhancedBidHistory>();
31 this.combinedBidHistory = new EnhancedBidHistory();
32 }
33
34 /**
35 * Add a bid to a bidHistory of a certain agent
36 *
37 * @param agentId
38 * @param bidDetails
39 */
40 public void addBid(AgentID agentId, BidDetails bidDetails) {
41 if (!this.bidHistories.containsKey(agentId)) {
42 this.bidHistories.put(agentId, new EnhancedBidHistory());
43 }
44 this.bidHistories.get(agentId).add(bidDetails);
45 this.combinedBidHistory.add(bidDetails);
46 }
47
48 /**
49 * Returns the history of a particular agent
50 *
51 * @param agentId
52 * @return
53 */
54 public EnhancedBidHistory getHistory(AgentID agentId) {
55 if (!bidHistories.containsKey(agentId))
56 return new EnhancedBidHistory();
57 return bidHistories.get(agentId);
58 }
59
60 /**
61 * Returns the combined history of all agents
62 *
63 * @return
64 */
65 public EnhancedBidHistory getCombinedHistory() {
66 return this.combinedBidHistory;
67 }
68
69 /**
70 * Returns the set of all agent ids in this multipleBidHistory
71 *
72 * @return
73 */
74 public Set<AgentID> getAgentIds() {
75 return this.bidHistories.keySet();
76 }
77
78 /**
79 * Returns the minimum toughness of all agents (so it returns the toughness
80 * of the toughest agent)
81 *
82 * @return
83 */
84 public double getMinToughness(int numberOfBids) {
85 double min = 1;
86 for (AgentID AgentId : this.getAgentIds()) {
87 min = Math.min(min,
88 this.getHistory(AgentId).getToughness(numberOfBids));
89 }
90 return min;
91 }
92}
Note: See TracBrowser for help on using the repository browser.