[153] | 1 | package agents.rlboa;
|
---|
| 2 | import genius.core.Bid;
|
---|
| 3 | import genius.core.actions.Action;
|
---|
| 4 | import genius.core.boaframework.BOAagentBilateral;
|
---|
| 5 | import genius.core.boaframework.OutcomeSpace;
|
---|
| 6 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
| 7 | import genius.core.protocol.BilateralAtomicNegotiationSession;
|
---|
| 8 | import negotiator.boaframework.acceptanceconditions.other.AC_Next;
|
---|
| 9 | import negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering;
|
---|
| 10 | import negotiator.boaframework.omstrategy.BestBid;
|
---|
| 11 | import negotiator.boaframework.opponentmodel.AgentXFrequencyModel;
|
---|
| 12 | import negotiator.boaframework.opponentmodel.PerfectModel;
|
---|
| 13 |
|
---|
| 14 | import java.io.File;
|
---|
| 15 | import java.util.ArrayList;
|
---|
| 16 | import java.util.HashMap;
|
---|
| 17 | import java.util.List;
|
---|
| 18 |
|
---|
| 19 | public class OppositionCalculator extends BOAagentBilateral {
|
---|
| 20 | @Override
|
---|
| 21 | public void agentSetup() {
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | HashMap<String, Double> params = new HashMap<String, Double>();
|
---|
| 25 |
|
---|
| 26 | // TODO: implement perfect opponent model
|
---|
| 27 | opponentModel = new AgentXFrequencyModel();
|
---|
| 28 | opponentModel.init(this.negotiationSession, params);
|
---|
| 29 |
|
---|
| 30 | offeringStrategy = new TimeDependent_Offering();
|
---|
| 31 |
|
---|
| 32 | // Accept if the incoming offer is higher than what you would offer yourself
|
---|
| 33 | acceptConditions = new AC_Next(negotiationSession, offeringStrategy, 1, 0);
|
---|
| 34 |
|
---|
| 35 | // Opponent model strategy always selects best bid it has available
|
---|
| 36 | omStrategy = new BestBid();
|
---|
| 37 | omStrategy.init(negotiationSession, opponentModel, params);
|
---|
| 38 | setDecoupledComponents(acceptConditions, offeringStrategy, opponentModel, omStrategy);
|
---|
| 39 |
|
---|
| 40 | OutcomeSpace outcomeSpace = new OutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
| 41 | this.negotiationSession.setOutcomeSpace(outcomeSpace);
|
---|
| 42 |
|
---|
| 43 | System.out.print("Opposition:");
|
---|
| 44 | System.out.println(this.calculateOpposition());
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | @Override
|
---|
| 48 | public String getName() {
|
---|
| 49 | return "Opposition Calculator";
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | private double calculateOpposition() {
|
---|
| 53 | List<Bid> allOutcomes = this.negotiationSession.getOutcomeSpace().getAllBidsWithoutUtilities();
|
---|
| 54 | double shortestDistanceToPerfect = Math.hypot(1, 1);
|
---|
| 55 |
|
---|
| 56 | for (Bid bid : allOutcomes) {
|
---|
| 57 | double x_util = this.getUtility(bid);
|
---|
| 58 | double y_util = this.opponentModel.getBidEvaluation(bid);
|
---|
| 59 | double distance = Math.hypot(1 - x_util, 1 - y_util);
|
---|
| 60 |
|
---|
| 61 | // System.out.println(String.format("%s -- OppModel: %s", bid, y_util));
|
---|
| 62 | if (distance < shortestDistanceToPerfect) {
|
---|
| 63 | shortestDistanceToPerfect = distance;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | return shortestDistanceToPerfect;
|
---|
| 68 | }
|
---|
| 69 | }
|
---|