source: src/main/java/negotiator/boaframework/opponentmodel/PerfectScalableBayesianModel.java@ 126

Last change on this file since 126 was 126, 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

Added input for strategyParameters to SessionPanel (gui)

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

Our own package:

  • 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: 4.0 KB
Line 
1package negotiator.boaframework.opponentmodel;
2
3import java.util.Map;
4
5import javax.swing.JOptionPane;
6
7import agents.bayesianopponentmodel.OpponentModelUtilSpace;
8import agents.bayesianopponentmodel.PerfectBayesianOpponentModelScalable;
9import genius.core.Bid;
10import genius.core.boaframework.NegotiationSession;
11import genius.core.boaframework.OpponentModel;
12import genius.core.issue.Issue;
13import genius.core.issue.ValueDiscrete;
14import genius.core.protocol.BilateralAtomicNegotiationSession;
15import genius.core.tournament.TournamentConfiguration;
16import genius.core.utility.AdditiveUtilitySpace;
17
18/**
19 * Adapter for BayesianOpponentModelScalable for the BOA framework. Modified
20 * such that it has perfect knowledge about the opponent's strategy.
21 *
22 * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
23 * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
24 * Strategies
25 *
26 * KNOWN BUGS: 1. Opponent model does not take the opponent's strategy into
27 * account, in contrast to the original paper which depicts an assumption about
28 * the opponent'strategy which adapts over time.
29 *
30 * 2. The opponent model becomes invalid after a while as NaN occurs in some
31 * hypotheses, corrupting the overall estimation.
32 *
33 * @author Mark Hendrikx
34 */
35public class PerfectScalableBayesianModel extends OpponentModel {
36
37 private PerfectBayesianOpponentModelScalable model;
38 private int startingBidIssue = 0;
39
40 @Override
41 public void init(NegotiationSession negoSession, Map<String, Double> parameters) {
42 initializeModel(negoSession);
43 }
44
45 @Override
46 public void setOpponentUtilitySpace(AdditiveUtilitySpace opponentUtilitySpace) {
47 System.out.println("called");
48 model.setOpponentUtilitySpace(opponentUtilitySpace);
49 }
50
51 @Override
52 public void setOpponentUtilitySpace(BilateralAtomicNegotiationSession session) {
53
54 if (TournamentConfiguration.getBooleanOption("accessPartnerPreferences", false)) {
55 opponentUtilitySpace = (AdditiveUtilitySpace) session.getAgentAUtilitySpace();
56 if (negotiationSession.getUtilitySpace().getFileName().equals(opponentUtilitySpace.getFileName())) {
57 opponentUtilitySpace = (AdditiveUtilitySpace) session.getAgentBUtilitySpace();
58 }
59 model.setOpponentUtilitySpace((AdditiveUtilitySpace) opponentUtilitySpace);
60 } else {
61 JOptionPane.showMessageDialog(null,
62 "This opponent model needs access to the opponent's\npreferences. See tournament options.",
63 "Model error", 0);
64 System.err.println("Global.experimentalSetup should be enabled!");
65 }
66 }
67
68 public void initializeModel(NegotiationSession negotiationSession) {
69 this.negotiationSession = negotiationSession;
70 while (!testIndexOfFirstIssue(negotiationSession.getUtilitySpace().getDomain().getRandomBid(null),
71 startingBidIssue)) {
72 startingBidIssue++;
73 }
74 model = new PerfectBayesianOpponentModelScalable((AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
75 }
76
77 /**
78 * Just an auxiliary function to calculate the index where issues start on a
79 * bid because we found out that it depends on the domain.
80 *
81 * @return true when the received index is the proper index
82 */
83 private boolean testIndexOfFirstIssue(Bid bid, int i) {
84 try {
85 @SuppressWarnings("unused")
86 ValueDiscrete valueOfIssue = (ValueDiscrete) bid.getValue(i);
87 } catch (Exception e) {
88 return false;
89 }
90 return true;
91 }
92
93 @Override
94 public void updateModel(Bid opponentBid, double time) {
95 try {
96 // time is not used by this opponent model
97 model.updateBeliefs(opponentBid);
98 } catch (Exception e) {
99 e.printStackTrace();
100 }
101 }
102
103 @Override
104 public double getBidEvaluation(Bid bid) {
105 try {
106 return model.getNormalizedUtility(bid);
107 } catch (Exception e) {
108 e.printStackTrace();
109 }
110 return 0;
111 }
112
113 public double getWeight(Issue issue) {
114 return model.getNormalizedWeight(issue, startingBidIssue);
115 }
116
117 @Override
118 public AdditiveUtilitySpace getOpponentUtilitySpace() {
119 return new OpponentModelUtilSpace(model);
120 }
121
122 public void cleanUp() {
123 super.cleanUp();
124 }
125
126 @Override
127 public String getName() {
128 return "Scalable Bayesian Model";
129 }
130}
Note: See TracBrowser for help on using the repository browser.