source: src/main/java/negotiator/boaframework/opponentmodel/FSEGABayesianModel.java@ 320

Last change on this file since 320 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 2.5 KB
Line 
1package negotiator.boaframework.opponentmodel;
2
3import java.util.Map;
4
5import agents.bayesianopponentmodel.OpponentModelUtilSpace;
6import genius.core.Bid;
7import genius.core.boaframework.NegotiationSession;
8import genius.core.boaframework.OpponentModel;
9import genius.core.issue.Issue;
10import genius.core.issue.ValueDiscrete;
11import genius.core.utility.AdditiveUtilitySpace;
12import 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 */
26public 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}
Note: See TracBrowser for help on using the repository browser.