[127] | 1 | package agents.anac.y2011.ValueModelAgent;
|
---|
| 2 |
|
---|
| 3 | import genius.core.timeline.TimeLineInfo;
|
---|
| 4 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
| 5 |
|
---|
| 6 | public class OpponentModeler {
|
---|
| 7 | AdditiveUtilitySpace utilitySpace;
|
---|
| 8 | double lastTime;
|
---|
| 9 | public double delta;
|
---|
| 10 | double discount;
|
---|
| 11 | TimeLineInfo timeline;
|
---|
| 12 | BidList ourPastBids;
|
---|
| 13 | BidList theirPastBids;
|
---|
| 14 | BidList allBids;
|
---|
| 15 | ValueModeler vmodel;
|
---|
| 16 | ValueModelAgent agent;
|
---|
| 17 | // reasonable to assume that this is the ratio between how much
|
---|
| 18 | // they gave us and how much they lost.
|
---|
| 19 | // i.e. if they gave us 9% than its reasonable to assume they lost at least
|
---|
| 20 | // 3%.
|
---|
| 21 | // this is used for fail safe estimation
|
---|
| 22 | double paretoRatioEstimation = 5;
|
---|
| 23 |
|
---|
| 24 | public OpponentModeler(int bidCount, AdditiveUtilitySpace space, TimeLineInfo timeline, BidList our, BidList their,
|
---|
| 25 | ValueModeler vmodeler, BidList allBids, ValueModelAgent agent) {
|
---|
| 26 | ourPastBids = our;
|
---|
| 27 | theirPastBids = their;
|
---|
| 28 | utilitySpace = space;
|
---|
| 29 | lastTime = timeline.getTime() * timeline.getTotalTime() * 1000;
|
---|
| 30 | discount = utilitySpace.getDiscountFactor();
|
---|
| 31 | if (discount >= 1) {
|
---|
| 32 | discount = 0; // compatiblity with old discount mode
|
---|
| 33 | }
|
---|
| 34 | this.timeline = timeline;
|
---|
| 35 | delta = 1.0 / (timeline.getTotalTime() * 1000);
|
---|
| 36 | vmodel = vmodeler;
|
---|
| 37 | this.allBids = allBids;
|
---|
| 38 | this.agent = agent;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public void tick() {
|
---|
| 42 | double newTime = timeline.getTime() * timeline.getTotalTime() * 1000;
|
---|
| 43 | delta = 0.8 * delta + (newTime - lastTime) / 5;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | private int expectedBidsToConvergence() {
|
---|
| 47 | return 10;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | public int expectedBidsToTimeout() {
|
---|
| 51 | if (delta > 0)
|
---|
| 52 | return (int) ((1 - timeline.getTime()) / delta);
|
---|
| 53 | else
|
---|
| 54 | return (int) (1 - timeline.getTime()) * 1000;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | public double expectedDiscountRatioToConvergence() {
|
---|
| 58 | double expectedPart = (double) (expectedBidsToConvergence() * delta);
|
---|
| 59 | if (timeline.getTime() + expectedPart > 1) {
|
---|
| 60 | return 1.1;
|
---|
| 61 | } else {
|
---|
| 62 | double div = 1 - (discount * expectedPart);
|
---|
| 63 | if (div > 0) {
|
---|
| 64 | return 1 / div;
|
---|
| 65 | } else
|
---|
| 66 | return 1.1;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | public double guessCurrentBidUtil() {
|
---|
| 71 | int s2 = theirPastBids.bids.size();
|
---|
| 72 | if (s2 == 0) {
|
---|
| 73 | return 1;
|
---|
| 74 | }
|
---|
| 75 | double sum = 0;
|
---|
| 76 | double count = 0;
|
---|
| 77 | double symetricLowerBound = allBids.bids.get(s2).ourUtility;
|
---|
| 78 | // trying to learn the average of the current bids
|
---|
| 79 | for (int i = s2 - 2; i >= 0 && i > s2 - 50; i--) {
|
---|
| 80 | theirPastBids.bids.get(i).update(vmodel);
|
---|
| 81 | if (theirPastBids.bids.get(i).theirUtilityReliability > 0.7) {
|
---|
| 82 | sum += theirPastBids.bids.get(i).theirUtility;
|
---|
| 83 | count++;
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | double shield = timeline.getTime() * 0.6;
|
---|
| 87 | if (shield < 0.03)
|
---|
| 88 | shield = 0.03;
|
---|
| 89 | double minBound = symetricLowerBound;
|
---|
| 90 | if (count >= 5 && sum / count < minBound) {
|
---|
| 91 | minBound = sum / count;
|
---|
| 92 | }
|
---|
| 93 | if (minBound > (1 - shield))
|
---|
| 94 | return minBound;
|
---|
| 95 | // it is very unsafe to assume our opponent conceded more than 15...
|
---|
| 96 | else
|
---|
| 97 | return (1 - shield);
|
---|
| 98 | }
|
---|
| 99 | }
|
---|