1 | package negotiator.boaframework.opponentmodel;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 |
|
---|
5 | import agents.bayesianopponentmodel.OpponentModelUtilSpace;
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.boaframework.NegotiationSession;
|
---|
8 | import genius.core.boaframework.OpponentModel;
|
---|
9 | import genius.core.issue.Issue;
|
---|
10 | import genius.core.issue.ValueDiscrete;
|
---|
11 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
12 | import negotiator.boaframework.opponentmodel.fsegaagent.FSEGAOpponentModel;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Adapter to opponent model of FSEGA. This opponent model gives a nullpointer
|
---|
16 | * in UtilitySpaceHypothesis and therefore does not work.
|
---|
17 | *
|
---|
18 | * Adapted by Mark Hendrikx to be compatible with the BOA framework.
|
---|
19 | *
|
---|
20 | * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
|
---|
21 | * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
|
---|
22 | * Strategies
|
---|
23 | *
|
---|
24 | * @author Mark Hendrikx
|
---|
25 | */
|
---|
26 | public class FSEGABayesianModel extends OpponentModel {
|
---|
27 |
|
---|
28 | FSEGAOpponentModel model;
|
---|
29 | private int startingBidIssue = 0;
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void init(NegotiationSession negotiationSession, Map<String, Double> parameters) {
|
---|
33 | this.negotiationSession = negotiationSession;
|
---|
34 | model = new FSEGAOpponentModel((AdditiveUtilitySpace) negotiationSession.getUtilitySpace());
|
---|
35 | while (!testIndexOfFirstIssue(negotiationSession.getUtilitySpace().getDomain().getRandomBid(null),
|
---|
36 | startingBidIssue)) {
|
---|
37 | startingBidIssue++;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Just an auxiliary function to calculate the index where issues start on a
|
---|
43 | * bid because we found out that it depends on the domain.
|
---|
44 | *
|
---|
45 | * @return true when the received index is the proper index
|
---|
46 | */
|
---|
47 | private boolean testIndexOfFirstIssue(Bid bid, int i) {
|
---|
48 | try {
|
---|
49 | @SuppressWarnings("unused")
|
---|
50 | ValueDiscrete valueOfIssue = (ValueDiscrete) bid.getValue(i);
|
---|
51 | } catch (Exception e) {
|
---|
52 | return false;
|
---|
53 | }
|
---|
54 | return true;
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Override
|
---|
58 | public void updateModel(Bid opponentBid, double time) {
|
---|
59 | try {
|
---|
60 | model.updateBeliefs(opponentBid);
|
---|
61 | } catch (Exception e) {
|
---|
62 | e.printStackTrace();
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public double getBidEvaluation(Bid bid) {
|
---|
68 | try {
|
---|
69 | return model.getNormalizedUtility(bid);
|
---|
70 | } catch (Exception e) {
|
---|
71 | e.printStackTrace();
|
---|
72 | }
|
---|
73 | return 0;
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public AdditiveUtilitySpace getOpponentUtilitySpace() {
|
---|
78 | return new OpponentModelUtilSpace(model);
|
---|
79 | }
|
---|
80 |
|
---|
81 | public double getWeight(Issue issue) {
|
---|
82 | return model.getNormalizedWeight(issue, startingBidIssue);
|
---|
83 | }
|
---|
84 |
|
---|
85 | public void cleanUp() {
|
---|
86 | super.cleanUp();
|
---|
87 | model = null;
|
---|
88 | }
|
---|
89 | } |
---|