[341] | 1 | package agents.anac.y2018.condagent;
|
---|
| 2 |
|
---|
[343] | 3 | import genius.core.Bid;
|
---|
| 4 | import genius.core.BidIterator;
|
---|
| 5 | import genius.core.Domain;
|
---|
[341] | 6 |
|
---|
| 7 | public class OpponentModel
|
---|
| 8 | {
|
---|
| 9 | public OpponentModel() {}
|
---|
| 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 | Double minUtility = null; Double maxUtility = null;
|
---|
| 18 | public double getExpectedUtility(Bid pBid) throws Exception { return -1.0D; }
|
---|
| 19 |
|
---|
| 20 | public double getNormalizedUtility(Bid pBid) throws Exception {
|
---|
| 21 | double u = getExpectedUtility(pBid);
|
---|
| 22 | if ((minUtility == null) || (maxUtility == null)) findMinMaxUtility();
|
---|
| 23 | double value = (u - minUtility.doubleValue()) / (maxUtility.doubleValue() - minUtility.doubleValue());
|
---|
| 24 | if (Double.isNaN(value)) {
|
---|
| 25 | if (!isCrashed) {
|
---|
| 26 | isCrashed = true;
|
---|
| 27 | System.err.println("Bayesian scalable encountered NaN and therefore crashed");
|
---|
| 28 | }
|
---|
| 29 | return 0.0D;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | return (u - minUtility.doubleValue()) / (maxUtility.doubleValue() - minUtility.doubleValue()); }
|
---|
| 33 | public void updateBeliefs(Bid pBid) throws Exception
|
---|
| 34 | {}
|
---|
| 35 | public double getExpectedWeight(int pIssueNumber) { return 0.0D; }
|
---|
| 36 |
|
---|
| 37 | public boolean haveSeenBefore(Bid pBid) { for (Bid tmpBid : fBiddingHistory) {
|
---|
| 38 | if (pBid.equals(tmpBid)) return true;
|
---|
| 39 | }
|
---|
| 40 | return false;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | protected void findMinMaxUtility() throws Exception {
|
---|
| 44 | BidIterator biditer = new BidIterator(fDomain);
|
---|
| 45 | minUtility = Double.valueOf(1.0D);maxUtility = Double.valueOf(0.0D);
|
---|
| 46 |
|
---|
| 47 | while (biditer.hasNext())
|
---|
| 48 | {
|
---|
| 49 | Bid b = biditer.next();
|
---|
| 50 | double u = getExpectedUtility(b);
|
---|
| 51 |
|
---|
| 52 | if (minUtility.doubleValue() > u) minUtility = Double.valueOf(u);
|
---|
| 53 | if (maxUtility.doubleValue() < u) maxUtility = Double.valueOf(u);
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | public boolean isCrashed() {
|
---|
| 58 | return isCrashed;
|
---|
| 59 | }
|
---|
| 60 | }
|
---|