1 | package negotiator.boaframework.opponentmodel;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 |
|
---|
5 | import agents.bayesianopponentmodel.BayesianOpponentModelScalable;
|
---|
6 | import agents.bayesianopponentmodel.OpponentModelUtilSpace;
|
---|
7 | import genius.core.Bid;
|
---|
8 | import genius.core.boaframework.NegotiationSession;
|
---|
9 | import genius.core.boaframework.OpponentModel;
|
---|
10 | import genius.core.issue.Issue;
|
---|
11 | import genius.core.issue.ValueDiscrete;
|
---|
12 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Adapter for BayesianOpponentModelScalable for the BOA framework.
|
---|
16 | *
|
---|
17 | * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
|
---|
18 | * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
|
---|
19 | * Strategies
|
---|
20 | *
|
---|
21 | * KNOWN BUGS: 1. Opponent model does not take the opponent's strategy into
|
---|
22 | * account, in contrast to the original paper which depicts an assumption about
|
---|
23 | * the opponent'strategy which adapts over time.
|
---|
24 | *
|
---|
25 | * 2. The opponent model becomes invalid after a while as NaN occurs in some
|
---|
26 | * hypotheses, corrupting the overall estimation.
|
---|
27 | *
|
---|
28 | * @author Mark Hendrikx
|
---|
29 | */
|
---|
30 | public class ScalableBayesianModel extends OpponentModel {
|
---|
31 |
|
---|
32 | private BayesianOpponentModelScalable model;
|
---|
33 | private int startingBidIssue = 0;
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public void init(NegotiationSession negoSession, Map<String, Double> parameters) {
|
---|
37 | initializeModel(negoSession);
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void initializeModel(NegotiationSession negotiationSession) {
|
---|
41 | this.negotiationSession = negotiationSession;
|
---|
42 | while (!testIndexOfFirstIssue(negotiationSession.getUtilitySpace().getDomain().getRandomBid(null),
|
---|
43 | startingBidIssue)) {
|
---|
44 | startingBidIssue++;
|
---|
45 | }
|
---|
46 |
|
---|
47 | model = new BayesianOpponentModelScalable((AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
|
---|
48 |
|
---|
49 | }
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Just an auxiliary function to calculate the index where issues start on a
|
---|
53 | * bid because we found out that it depends on the domain.
|
---|
54 | *
|
---|
55 | * @return true when the received index is the proper index
|
---|
56 | */
|
---|
57 | private boolean testIndexOfFirstIssue(Bid bid, int i) {
|
---|
58 | try {
|
---|
59 | @SuppressWarnings("unused")
|
---|
60 | ValueDiscrete valueOfIssue = (ValueDiscrete) bid.getValue(i);
|
---|
61 | } catch (Exception e) {
|
---|
62 | return false;
|
---|
63 | }
|
---|
64 | return true;
|
---|
65 | }
|
---|
66 |
|
---|
67 | @Override
|
---|
68 | public void updateModel(Bid opponentBid, double time) {
|
---|
69 | try {
|
---|
70 | // time is not used by this opponent model
|
---|
71 | model.updateBeliefs(opponentBid);
|
---|
72 | } catch (Exception e) {
|
---|
73 | e.printStackTrace();
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | @Override
|
---|
78 | public double getBidEvaluation(Bid bid) {
|
---|
79 | try {
|
---|
80 | return model.getNormalizedUtility(bid);
|
---|
81 | } catch (Exception e) {
|
---|
82 | e.printStackTrace();
|
---|
83 | }
|
---|
84 | return 0;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public double getWeight(Issue issue) {
|
---|
88 | return model.getNormalizedWeight(issue, startingBidIssue);
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Override
|
---|
92 | public AdditiveUtilitySpace getOpponentUtilitySpace() {
|
---|
93 | return new OpponentModelUtilSpace(model);
|
---|
94 | }
|
---|
95 |
|
---|
96 | public void cleanUp() {
|
---|
97 | super.cleanUp();
|
---|
98 | }
|
---|
99 |
|
---|
100 | @Override
|
---|
101 | public String getName() {
|
---|
102 | return "Scalable Bayesian Model";
|
---|
103 | }
|
---|
104 | } |
---|