source: src/main/java/agents/anac/y2012/CUHKAgent/OwnBidHistory.java@ 84

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

Initial import : Genius 9.0.0

File size: 1.8 KB
Line 
1/*
2 * OwnBidHistory class
3 */
4package agents.anac.y2012.CUHKAgent;
5
6import java.util.ArrayList;
7
8import genius.core.Bid;
9import genius.core.utility.AdditiveUtilitySpace;
10
11/**
12 *
13 * @author Justin
14 */
15public class OwnBidHistory {
16
17 private ArrayList<Bid> BidHistory;
18 private Bid minBidInHistory;
19
20 public OwnBidHistory() {
21 BidHistory = new ArrayList<Bid>();
22 }
23
24 public void addBid(Bid bid, AdditiveUtilitySpace utilitySpace) {
25 if (BidHistory.indexOf(bid) == -1) {
26 BidHistory.add(bid);
27 }
28 try {
29 if (BidHistory.size() == 1) {
30 this.minBidInHistory = BidHistory.get(0);
31 } else {
32 if (utilitySpace.getUtility(bid) < utilitySpace.getUtility(this.minBidInHistory)) {
33 this.minBidInHistory = bid;
34 }
35 }
36 } catch (Exception e) {
37 System.out.println("error in addBid method of OwnBidHistory class" + e.getMessage());
38 }
39 }
40
41 protected Bid GetMinBidInHistory() {
42
43 return this.minBidInHistory;
44 }
45
46 protected Bid getLastBid() {
47 if (BidHistory.size() >= 1) {
48 return BidHistory.get(BidHistory.size() - 1);
49 } else {
50 return null;
51 }
52 }
53
54 public int numOfBidsProposed() {
55 return BidHistory.size();
56 }
57
58 protected Bid chooseLowestBidInHistory(AdditiveUtilitySpace utilitySpace) {
59 double minUtility = 100;
60 Bid minBid = null;
61 try {
62 for (Bid bid : BidHistory) {
63 if (utilitySpace.getUtility(bid) < minUtility) {
64 minUtility = utilitySpace.getUtility(bid);
65 minBid = bid;
66 }
67 }
68 } catch (Exception e) {
69 System.out.println("Exception in chooseLowestBidInHistory");
70 }
71 return minBid;
72 }
73}
Note: See TracBrowser for help on using the repository browser.