1 | package agents.anac.y2017.tucagent;
|
---|
2 |
|
---|
3 | import genius.core.Bid;
|
---|
4 | import genius.core.BidIterator;
|
---|
5 | import genius.core.Domain;
|
---|
6 |
|
---|
7 | public class OpponentModel {
|
---|
8 | public OpponentModel() {
|
---|
9 | }
|
---|
10 |
|
---|
11 | private boolean isCrashed = false;
|
---|
12 | protected Domain fDomain;
|
---|
13 | public java.util.ArrayList<Bid> fBiddingHistory;
|
---|
14 |
|
---|
15 | public Domain getDomain() {
|
---|
16 | return fDomain;
|
---|
17 | }
|
---|
18 |
|
---|
19 | Double minUtility = null;
|
---|
20 | Double maxUtility = null;
|
---|
21 |
|
---|
22 | public double getExpectedUtility(Bid pBid) throws Exception {
|
---|
23 | return -1.0D;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public double getNormalizedUtility(Bid pBid) throws Exception {
|
---|
27 | double u = getExpectedUtility(pBid);
|
---|
28 | if ((minUtility == null) || (maxUtility == null))
|
---|
29 | findMinMaxUtility();
|
---|
30 | double value = (u - minUtility.doubleValue()) / (maxUtility.doubleValue() - minUtility.doubleValue());
|
---|
31 | if (Double.isNaN(value)) {
|
---|
32 | if (!isCrashed) {
|
---|
33 | isCrashed = true;
|
---|
34 | System.err.println("Bayesian scalable encountered NaN and therefore crashed");
|
---|
35 | }
|
---|
36 | return 0.0D;
|
---|
37 | }
|
---|
38 |
|
---|
39 | return (u - minUtility.doubleValue()) / (maxUtility.doubleValue() - minUtility.doubleValue());
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void updateBeliefs(Bid pBid) throws Exception {
|
---|
43 | }
|
---|
44 |
|
---|
45 | public double getExpectedWeight(int pIssueNumber) {
|
---|
46 | return 0.0D;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public boolean haveSeenBefore(Bid pBid) {
|
---|
50 | for (Bid tmpBid : fBiddingHistory) {
|
---|
51 | if (pBid.equals(tmpBid))
|
---|
52 | return true;
|
---|
53 | }
|
---|
54 | return false;
|
---|
55 | }
|
---|
56 |
|
---|
57 | protected void findMinMaxUtility() throws Exception {
|
---|
58 | BidIterator biditer = new BidIterator(fDomain);
|
---|
59 | minUtility = Double.valueOf(1.0D);
|
---|
60 | maxUtility = Double.valueOf(0.0D);
|
---|
61 |
|
---|
62 | while (biditer.hasNext()) {
|
---|
63 | Bid b = biditer.next();
|
---|
64 | double u = getExpectedUtility(b);
|
---|
65 |
|
---|
66 | if (minUtility.doubleValue() > u)
|
---|
67 | minUtility = Double.valueOf(u);
|
---|
68 | if (maxUtility.doubleValue() < u)
|
---|
69 | maxUtility = Double.valueOf(u);
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | public boolean isCrashed() {
|
---|
74 | return isCrashed;
|
---|
75 | }
|
---|
76 | }
|
---|