[341] | 1 |
|
---|
| 2 | package agents.anac.y2018.fullagent;
|
---|
| 3 |
|
---|
| 4 | import java.util.HashMap;
|
---|
| 5 | import java.util.HashSet;
|
---|
| 6 | import java.util.Map;
|
---|
| 7 | import java.util.Set;
|
---|
| 8 |
|
---|
[343] | 9 | import genius.core.bidding.BidDetails;
|
---|
| 10 | import genius.core.boaframework.BOAparameter;
|
---|
| 11 | import genius.core.boaframework.NegotiationSession;
|
---|
| 12 | import genius.core.boaframework.NoModel;
|
---|
| 13 | import genius.core.boaframework.OMStrategy;
|
---|
| 14 | import genius.core.boaframework.OfferingStrategy;
|
---|
| 15 | import genius.core.boaframework.OpponentModel;
|
---|
| 16 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
[341] | 17 |
|
---|
| 18 | /**
|
---|
| 19 | * This is an abstract class used to implement a TimeDependentAgent Strategy
|
---|
| 20 | * adapted from [1] [1] S. Shaheen Fatima Michael Wooldridge Nicholas R.
|
---|
| 21 | * Jennings Optimal Negotiation Strategies for Agents with Incomplete
|
---|
| 22 | * Information http://eprints.ecs.soton.ac.uk/6151/1/atal01.pdf
|
---|
| 23 | *
|
---|
| 24 | * The default strategy was extended to enable the usage of opponent models.
|
---|
| 25 | *
|
---|
| 26 | * Note that this agent is not fully equivalent to the theoretical model,
|
---|
| 27 | * loading the domain may take some time, which may lead to the agent skipping
|
---|
| 28 | * the first bid. A better implementation is GeniusTimeDependent_Offering.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 | public class OfferingStrategy_lgsmi extends OfferingStrategy {
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * k in [0, 1]. For k = 0 the agent starts with a bid of maximum utility
|
---|
| 36 | */
|
---|
| 37 | private double k;
|
---|
| 38 | /** Maximum target utility */
|
---|
| 39 | private double Pmax;
|
---|
| 40 | /** Minimum target utility */
|
---|
| 41 | private double Pmin;
|
---|
| 42 | /** Concession factor */
|
---|
| 43 | private double e;
|
---|
| 44 | /** Outcome space */
|
---|
| 45 | private SortedOutcomeSpace outcomespace;
|
---|
| 46 |
|
---|
| 47 | private BidsManager bidsManager;
|
---|
| 48 |
|
---|
| 49 | public OfferingStrategy_lgsmi(BidsManager bidsManager) {
|
---|
| 50 | super();
|
---|
| 51 | this.bidsManager = bidsManager;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | /**
|
---|
| 55 | * Method which initializes the agent by setting all parameters. The
|
---|
| 56 | * parameter "e" is the only parameter which is required.
|
---|
| 57 | */
|
---|
| 58 | @Override
|
---|
| 59 | public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
|
---|
| 60 | Map<String, Double> parameters) throws Exception {
|
---|
| 61 | super.init(negoSession, parameters);
|
---|
| 62 | if (parameters.get("e") != null) {
|
---|
| 63 | this.negotiationSession = negoSession;
|
---|
| 64 |
|
---|
| 65 | outcomespace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
| 66 | negotiationSession.setOutcomeSpace(outcomespace);
|
---|
| 67 |
|
---|
| 68 | this.e = parameters.get("e");
|
---|
| 69 |
|
---|
| 70 | if (parameters.get("k") != null)
|
---|
| 71 | this.k = parameters.get("k");
|
---|
| 72 | else
|
---|
| 73 | this.k = 0;
|
---|
| 74 |
|
---|
| 75 | if (parameters.get("min") != null)
|
---|
| 76 | this.Pmin = parameters.get("min");
|
---|
| 77 | else
|
---|
| 78 | this.Pmin = negoSession.getMinBidinDomain().getMyUndiscountedUtil();
|
---|
| 79 |
|
---|
| 80 | if (parameters.get("max") != null) {
|
---|
| 81 | Pmax = parameters.get("max");
|
---|
| 82 | } else {
|
---|
| 83 | BidDetails maxBid = negoSession.getMaxBidinDomain();
|
---|
| 84 | Pmax = maxBid.getMyUndiscountedUtil();
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | this.opponentModel = model;
|
---|
| 88 | this.omStrategy = oms;
|
---|
| 89 | } else {
|
---|
| 90 | throw new Exception("Constant \"e\" for the concession speed was not set.");
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | @Override
|
---|
| 95 | public BidDetails determineOpeningBid() {
|
---|
| 96 | return determineNextBid();
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /**
|
---|
| 100 | * Simple offering strategy which retrieves the target utility and looks for
|
---|
| 101 | * the nearest bid if no opponent model is specified. If an opponent model
|
---|
| 102 | * is specified, then the agent return a bid according to the opponent model
|
---|
| 103 | * strategy.
|
---|
| 104 | */
|
---|
| 105 | @Override
|
---|
| 106 | public BidDetails determineNextBid() {
|
---|
| 107 | double time = negotiationSession.getTime();
|
---|
| 108 | double utilityGoal;
|
---|
| 109 | utilityGoal = p(time);
|
---|
| 110 |
|
---|
| 111 | // System.out.println("[e=" + e + ", Pmin = " +
|
---|
| 112 | // BilateralAgent.round2(Pmin) + "] t = " + BilateralAgent.round2(time)
|
---|
| 113 | // + ". Aiming for " + utilityGoal);
|
---|
| 114 |
|
---|
| 115 | // if there is no opponent model available
|
---|
| 116 | if (opponentModel instanceof NoModel) {
|
---|
| 117 | nextBid = negotiationSession.getOutcomeSpace().getBidNearUtility(utilityGoal);
|
---|
| 118 | } else {
|
---|
| 119 | nextBid = omStrategy.getBid(outcomespace, utilityGoal);
|
---|
| 120 | }
|
---|
| 121 | //
|
---|
| 122 | boolean almostEndOfTime = bidsManager.isTheEndOfTimeArriving();
|
---|
| 123 | double minimalThreshold = 0.25;
|
---|
| 124 | if (almostEndOfTime) {
|
---|
| 125 | if (bidsManager.getUtilityOfMaximalBidThatWasAccepted() >= minimalThreshold) {
|
---|
| 126 | nextBid = new BidDetails(bidsManager.getMaximalBidThatWasAccepted(), bidsManager.getUtilityOfMaximalBidThatWasAccepted()) ;
|
---|
| 127 | } else if (bidsManager.getUtilityOfMaximalOppBid() >= minimalThreshold) {
|
---|
| 128 | nextBid = new BidDetails(bidsManager.getMaximalOppBid(), bidsManager.getUtilityOfMaximalOppBid()) ;
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | return nextBid;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /**
|
---|
| 135 | * From [1]:
|
---|
| 136 | *
|
---|
| 137 | * A wide range of time dependent functions can be defined by varying the
|
---|
| 138 | * way in which f(t) is computed. However, functions must ensure that 0 <=
|
---|
| 139 | * f(t) <= 1, f(0) = k, and f(1) = 1.
|
---|
| 140 | *
|
---|
| 141 | * That is, the offer will always be between the value range, at the
|
---|
| 142 | * beginning it will give the initial constant and when the deadline is
|
---|
| 143 | * reached, it will offer the reservation value.
|
---|
| 144 | *
|
---|
| 145 | * For e = 0 (special case), it will behave as a Hardliner.
|
---|
| 146 | */
|
---|
| 147 | public double f(double t) {
|
---|
| 148 | if (e == 0)
|
---|
| 149 | return k;
|
---|
| 150 | double ft = k + (1 - k) * Math.pow(t, 1.0 / e);
|
---|
| 151 | return ft;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /**
|
---|
| 155 | * Makes sure the target utility with in the acceptable range according to
|
---|
| 156 | * the domain Goes from Pmax to Pmin!
|
---|
| 157 | *
|
---|
| 158 | * @param t
|
---|
| 159 | * @return double
|
---|
| 160 | */
|
---|
| 161 | public double p(double t) {
|
---|
| 162 | return Pmin + (Pmax - Pmin) * (1 - f(t));
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | public NegotiationSession getNegotiationSession() {
|
---|
| 166 | return negotiationSession;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | @Override
|
---|
| 170 | public Set<BOAparameter> getParameterSpec() {
|
---|
| 171 | Set<BOAparameter> set = new HashSet<BOAparameter>();
|
---|
| 172 | set.add(new BOAparameter("e", 1.0, "Concession rate"));
|
---|
| 173 | set.add(new BOAparameter("k", 0.0, "Offset"));
|
---|
| 174 | set.add(new BOAparameter("min", 0.0, "Minimum utility"));
|
---|
| 175 | set.add(new BOAparameter("max", 0.99, "Maximum utility"));
|
---|
| 176 |
|
---|
| 177 | return set;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 |
|
---|
| 181 | public Map<String, Double> getParameters() {
|
---|
| 182 | Map<String, Double> map = new HashMap<String, Double>();
|
---|
| 183 | //Concession rate
|
---|
| 184 | map.put("e", 0.25);
|
---|
| 185 | //Offset
|
---|
| 186 | map.put("k", 0.0);
|
---|
| 187 | //Minimum utility
|
---|
| 188 | map.put( "min", 0.0);
|
---|
| 189 | //Maximum utility
|
---|
| 190 | map.put("max", 0.99);
|
---|
| 191 | return map;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | @Override
|
---|
| 195 | public String getName() {
|
---|
| 196 | return "OfferingStrategy_lgsmi";
|
---|
| 197 |
|
---|
| 198 | }
|
---|
| 199 | }
|
---|