[200] | 1 | package agents.anac.y2019.harddealer;
|
---|
| 2 |
|
---|
| 3 | import java.util.HashSet;
|
---|
| 4 | import java.util.Map;
|
---|
| 5 | import java.util.Set;
|
---|
| 6 |
|
---|
| 7 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
| 8 | import genius.core.boaframework.Actions;
|
---|
| 9 | import genius.core.boaframework.BOAparameter;
|
---|
| 10 | import genius.core.boaframework.NegotiationSession;
|
---|
| 11 | import genius.core.boaframework.OfferingStrategy;
|
---|
| 12 | import genius.core.boaframework.OpponentModel;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * This Acceptance Condition will accept an opponent bid if the utility is
|
---|
| 16 | * higher than the acceptance boundary or higher than the bid the agent is
|
---|
| 17 | * ready to present.
|
---|
| 18 | */
|
---|
| 19 | public class HardDealer_AS extends AcceptanceStrategy {
|
---|
| 20 | private double a;
|
---|
| 21 | private double b;
|
---|
| 22 | private double reservationValue;
|
---|
| 23 | private double k;
|
---|
| 24 | /** Concession factor */
|
---|
| 25 | private double e;
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * Empty constructor for the BOA framework.
|
---|
| 29 | */
|
---|
| 30 | public HardDealer_AS() {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public double f(double t) {
|
---|
| 34 | // First 10% of session: Slowly come up from bids with util .9
|
---|
| 35 | if (t < .1)
|
---|
| 36 | {
|
---|
| 37 | return 20*(t-0.1)*(t-0.1);
|
---|
| 38 | }
|
---|
| 39 | else
|
---|
| 40 | {
|
---|
| 41 | if (e == 0)
|
---|
| 42 | {
|
---|
| 43 | return k;
|
---|
| 44 | }
|
---|
| 45 | double ft = k + (1 - k) * Math.pow(t, 1.0 / e);
|
---|
| 46 | return ft;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | public double p(double t) {
|
---|
| 52 | return this.reservationValue + (1 - this.reservationValue) * (1 - f(t));
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * Method directly called after creating the party which is used to
|
---|
| 57 | * initialize the component.
|
---|
| 58 | */
|
---|
| 59 | @Override
|
---|
| 60 | public void init(NegotiationSession negoSession, OfferingStrategy strat,
|
---|
| 61 | OpponentModel opponentModel, Map<String, Double> parameters)
|
---|
| 62 | throws Exception {
|
---|
| 63 | this.negotiationSession = negoSession;
|
---|
| 64 | this.offeringStrategy = strat;
|
---|
| 65 | this.e = (1.8) / negotiationSession.getTimeline().getTotalTime();
|
---|
| 66 |
|
---|
| 67 | if (parameters.get("a") != null || parameters.get("b") != null) {
|
---|
| 68 | a = parameters.get("a");
|
---|
| 69 | b = parameters.get("b");
|
---|
| 70 | } else {
|
---|
| 71 | a = 1;
|
---|
| 72 | b = 0;
|
---|
| 73 | }
|
---|
| 74 | this.reservationValue = negotiationSession.getUtilitySpace().getReservationValue();
|
---|
| 75 |
|
---|
| 76 | if (parameters.get("k") != null)
|
---|
| 77 | this.k = parameters.get("k");
|
---|
| 78 | else
|
---|
| 79 | this.k = 0;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | @Override
|
---|
| 83 | public String printParameters() {
|
---|
| 84 | String str = "[a: " + a + " b: " + b + "]";
|
---|
| 85 | return str;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[204] | 88 |
|
---|
[200] | 89 | /**
|
---|
[204] | 90 | * Method which determines if the party should accept the opponent�s bid.
|
---|
[200] | 91 | */
|
---|
| 92 | @Override
|
---|
| 93 | public Actions determineAcceptability() {
|
---|
| 94 | double normalizedTime = negotiationSession.getTime(); // Normalized time
|
---|
| 95 |
|
---|
| 96 | //CURVE Accepting
|
---|
| 97 | double acceptationValue = p(normalizedTime);
|
---|
| 98 |
|
---|
| 99 | double nextMyBidUtil = offeringStrategy.getNextBid()
|
---|
| 100 | .getMyUndiscountedUtil(); // The next bid to propose
|
---|
| 101 | double lastOpponentBidUtil = negotiationSession.getOpponentBidHistory()
|
---|
| 102 | .getLastBidDetails().getMyUndiscountedUtil();
|
---|
| 103 | if ((a * lastOpponentBidUtil + b >= nextMyBidUtil) || (a * lastOpponentBidUtil + b >= acceptationValue)) {
|
---|
| 104 | return Actions.Accept;
|
---|
| 105 | }
|
---|
| 106 | // Otherwise reject
|
---|
| 107 | return Actions.Reject;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | @Override
|
---|
| 111 | public Set<BOAparameter> getParameterSpec() {
|
---|
| 112 |
|
---|
| 113 | Set<BOAparameter> set = new HashSet<BOAparameter>();
|
---|
| 114 | set.add(new BOAparameter("a", 1.0,
|
---|
| 115 | "Accept when the opponent's utility * a + b is greater than "
|
---|
| 116 | + "the utility of our current bid or our acceptance boundary"));
|
---|
| 117 | set.add(new BOAparameter("b", 0.0,
|
---|
| 118 | "Accept when the opponent's utility * a + b is greater than "
|
---|
| 119 | + "the utility of our current bid or our acceptance boundary"));
|
---|
| 120 |
|
---|
| 121 | return set;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | @Override
|
---|
| 125 | public String getName() {
|
---|
| 126 | return "HardDealer_AS";
|
---|
| 127 | }
|
---|
| 128 | }
|
---|