source: src/main/java/negotiator/boaframework/opponentmodel/AgentLGModel.java@ 316

Last change on this file since 316 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: 3.4 KB
Line 
1package negotiator.boaframework.opponentmodel;
2
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6
7import genius.core.Bid;
8import genius.core.boaframework.NegotiationSession;
9import genius.core.boaframework.OpponentModel;
10import genius.core.issue.Issue;
11import genius.core.issue.Value;
12import genius.core.utility.AdditiveUtilitySpace;
13import negotiator.boaframework.opponentmodel.agentlg.BidStatistic;
14import negotiator.boaframework.opponentmodel.tools.UtilitySpaceAdapter;
15
16/**
17 * Adaptation of the opponent model used by AgentLG in the ANAC2012 to be
18 * compatible with the BOA framework.
19 *
20 * Note that originally, the model sums up all value scores which entails that
21 * the total preference of a bid can be as high as offered bids * issues. The
22 * value score was equal to the amount of times the value was offered divided by
23 * total amount of bids offered by the opponent.
24 *
25 * In my implementation I normalize each value score by the highest value,
26 * similar to the implementation of preference profiles in Genius. Finally I sum
27 * all results and divide by the amount of issues. This is identical to assuming
28 * that the issue weights are uniform.
29 *
30 * Tim Baarslag, Koen Hindriks, Mark Hendrikx, Alex Dirkzwager and Catholijn M.
31 * Jonker. Decoupling Negotiating Agents to Explore the Space of Negotiation
32 * Strategies
33 *
34 * @author Mark Hendrikx
35 */
36public class AgentLGModel extends OpponentModel {
37
38 /**
39 * Creates objects to keep track of how many times each value has been
40 * offered for an issue
41 */
42 private HashMap<Issue, BidStatistic> statistic = new HashMap<Issue, BidStatistic>();
43 /** Cache the issues of the domain for performanc reasons */
44 private List<Issue> issues;
45
46 /**
47 * Initialize the opponent model by creating an object to keep track of the
48 * values for each issue.
49 */
50 @Override
51 public void init(NegotiationSession negotiationSession, Map<String, Double> parameters) {
52 this.negotiationSession = negotiationSession;
53 issues = negotiationSession.getUtilitySpace().getDomain().getIssues();
54 for (Issue issue : issues) {
55 statistic.put(issue, new BidStatistic(issue));
56 }
57 }
58
59 /**
60 * Update the opponent model by updating the value score for each issue.
61 *
62 * @param opponentBid
63 * @param time
64 * of offering
65 */
66 @Override
67 public void updateModel(Bid opponentBid, double time) {
68 try {
69 // updates statistics
70 for (Issue issue : statistic.keySet()) {
71 Value v = opponentBid.getValue(issue.getNumber());
72 statistic.get(issue).add(v);
73 }
74 } catch (Exception e) {
75 e.printStackTrace();
76 }
77 }
78
79 /**
80 * @return utility of the opponent's bid
81 */
82 public double getBidEvaluation(Bid bid) {
83 double ret = 0;
84 for (Issue issue : issues) {
85 try {
86 ret += statistic.get(issue).getValueUtility(bid.getValue(issue.getNumber()));
87 } catch (Exception e) {
88 e.printStackTrace();
89 }
90 }
91 return (ret / issues.size());
92 }
93
94 /**
95 * @return the uniform issue weight
96 */
97 public double getWeight(Issue issue) {
98 return (1.0 / issues.size());
99 }
100
101 /**
102 * @return utilityspace created by using the opponent model adapter.
103 */
104 @Override
105 public AdditiveUtilitySpace getOpponentUtilitySpace() {
106 return new UtilitySpaceAdapter(this, negotiationSession.getUtilitySpace().getDomain());
107 }
108
109 public void cleanUp() {
110 super.cleanUp();
111 }
112
113 @Override
114 public String getName() {
115 return "AgentLG Model";
116 }
117}
Note: See TracBrowser for help on using the repository browser.