1 | package agents.anac.y2011.ValueModelAgent;
|
---|
2 |
|
---|
3 | import java.util.Comparator;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.utility.AbstractUtilitySpace;
|
---|
7 |
|
---|
8 | public class BidWrapper {
|
---|
9 | public boolean sentByUs;
|
---|
10 | public boolean sentByThem;
|
---|
11 | public int lastSentBid;
|
---|
12 | public double ourUtility;
|
---|
13 | public double theirUtility;
|
---|
14 | public double theirUtilityReliability;
|
---|
15 | public Bid bid;
|
---|
16 |
|
---|
17 | public BidWrapper(Bid bid, AbstractUtilitySpace space, double maxUtil) {
|
---|
18 | this.bid = bid;
|
---|
19 | sentByUs = false;
|
---|
20 | sentByThem = false;
|
---|
21 | try {
|
---|
22 | ourUtility = space.getUtility(bid) / maxUtil;
|
---|
23 | } catch (Exception e) {
|
---|
24 | ourUtility = 0;
|
---|
25 | }
|
---|
26 | theirUtility = 0;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public void update(ValueModeler model) {
|
---|
30 | try {
|
---|
31 | ValueDecrease val = model.utilityLoss(bid);
|
---|
32 | theirUtility = 1 - val.getDecrease();
|
---|
33 | theirUtilityReliability = val.getReliabilty();
|
---|
34 | } catch (Exception ex) {
|
---|
35 |
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public class OpponentUtilityComperator implements Comparator<BidWrapper> {
|
---|
40 |
|
---|
41 | public int compare(BidWrapper o1, BidWrapper o2) {
|
---|
42 | if (o1.theirUtility < o2.theirUtility) {
|
---|
43 | return 1;
|
---|
44 | }
|
---|
45 | if (o1.theirUtility > o2.theirUtility) {
|
---|
46 | return -1;
|
---|
47 | }
|
---|
48 | return 0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | public class OurUtilityComperator implements Comparator<BidWrapper> {
|
---|
54 |
|
---|
55 | public int compare(BidWrapper o1, BidWrapper o2) {
|
---|
56 | if (o1.ourUtility < o2.ourUtility) {
|
---|
57 | return 1;
|
---|
58 | }
|
---|
59 | if (o1.ourUtility > o2.ourUtility) {
|
---|
60 | return -1;
|
---|
61 | }
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 | }
|
---|
66 |
|
---|
67 | public boolean equals(BidWrapper o) {
|
---|
68 | return bid.equals(o.bid);
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public boolean equals(Object obj) {
|
---|
73 | if (obj instanceof BidWrapper)
|
---|
74 | return equals((BidWrapper) obj);
|
---|
75 | return false;
|
---|
76 | }
|
---|
77 |
|
---|
78 | }
|
---|