source: src/main/java/agents/anac/y2015/cuhkagent2015/OwnBidHistory.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

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