source: src/main/java/agents/rlboa/OppositionCalculator.java

Last change on this file was 153, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

This commit finalized the RLBOA project and it is now ready for use

Our own package (uva.project.:

  • Moved to agents.rlboa
  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 2.6 KB
RevLine 
[153]1package agents.rlboa;
2import genius.core.Bid;
3import genius.core.actions.Action;
4import genius.core.boaframework.BOAagentBilateral;
5import genius.core.boaframework.OutcomeSpace;
6import genius.core.boaframework.SortedOutcomeSpace;
7import genius.core.protocol.BilateralAtomicNegotiationSession;
8import negotiator.boaframework.acceptanceconditions.other.AC_Next;
9import negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering;
10import negotiator.boaframework.omstrategy.BestBid;
11import negotiator.boaframework.opponentmodel.AgentXFrequencyModel;
12import negotiator.boaframework.opponentmodel.PerfectModel;
13
14import java.io.File;
15import java.util.ArrayList;
16import java.util.HashMap;
17import java.util.List;
18
19public 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}
Note: See TracBrowser for help on using the repository browser.