[1] | 1 | package agents;
|
---|
| 2 |
|
---|
| 3 | import java.util.ArrayList;
|
---|
| 4 |
|
---|
| 5 | import genius.core.Bid;
|
---|
| 6 | import genius.core.SupportedNegotiationSetting;
|
---|
| 7 | import genius.core.timeline.DiscreteTimeline;
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * uses the cutoffs to accept
|
---|
| 11 | */
|
---|
| 12 | public class FunctionalAcceptor extends TimeDependentAgent {
|
---|
| 13 | double rv = -0.1;
|
---|
| 14 | int ownTotalRounds = 0;
|
---|
| 15 | private static ArrayList<Double> cutoffs;
|
---|
| 16 |
|
---|
| 17 | public void init() {
|
---|
| 18 | rv = utilitySpace.getReservationValue();
|
---|
| 19 | ownTotalRounds = (getTotalRounds() - 1) / 2;
|
---|
| 20 |
|
---|
| 21 | cutoffs = new ArrayList<Double>(ownTotalRounds);
|
---|
| 22 | for (int i = 0; i < ownTotalRounds; i++)
|
---|
| 23 | cutoffs.add(bid(i + 1));
|
---|
| 24 |
|
---|
| 25 | super.init();
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | @Override
|
---|
| 29 | public double getE() {
|
---|
| 30 | return 0;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | @Override
|
---|
| 34 | public String getName() {
|
---|
| 35 | return "FunctionalAcceptor";
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | public double bid(int j) {
|
---|
| 39 | if (j == 1)
|
---|
| 40 | return 0.5 + 0.5 * rv;
|
---|
| 41 | else
|
---|
| 42 | return 0.5 + 0.5 * Math.pow(bid(j - 1), 2);
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | public double functionalReservationValue() {
|
---|
| 46 | boolean immediate = false;
|
---|
| 47 |
|
---|
| 48 | if (!immediate) {
|
---|
| 49 | return cutoffs.get(getOwnRoundsLeft());
|
---|
| 50 | } else {
|
---|
| 51 | // immediate acceptance case
|
---|
| 52 | return utilitySpace.getReservationValue();
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | @Override
|
---|
| 57 | public boolean isAcceptable(Bid plannedBid) {
|
---|
| 58 | Bid opponentLastBid = getOpponentLastBid();
|
---|
| 59 | if (getUtility(opponentLastBid) >= functionalReservationValue())
|
---|
| 60 | return true;
|
---|
| 61 | return false;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | // discrete rounds' methods
|
---|
| 65 | public int getRound() {
|
---|
| 66 | return ((DiscreteTimeline) timeline).getRound();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | public int getRoundsLeft() {
|
---|
| 70 | return ((DiscreteTimeline) timeline).getRoundsLeft();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | public int getOwnRoundsLeft() {
|
---|
| 74 | return ((DiscreteTimeline) timeline).getOwnRoundsLeft();
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | public int getTotalRounds() {
|
---|
| 78 | return ((DiscreteTimeline) timeline).getTotalRounds();
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | public double getTotalTime() {
|
---|
| 82 | return ((DiscreteTimeline) timeline).getTotalTime();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | @Override
|
---|
| 86 | public SupportedNegotiationSetting getSupportedNegotiationSetting() {
|
---|
| 87 | return SupportedNegotiationSetting.getLinearUtilitySpaceInstance();
|
---|
| 88 | }
|
---|
| 89 | }
|
---|