source: src/main/java/agents/anac/y2018/groupy/OpponentModel.java@ 341

Last change on this file since 341 was 341, checked in by Katsuhide Fujita, 5 years ago

Katsuhide Fujita added ANAC2018 agents.

File size: 1.8 KB
Line 
1package agents.anac.y2018.groupy;
2import java.util.HashMap;
3import java.util.List;
4
5import negotiator.Bid;
6import negotiator.issue.Issue;
7import negotiator.issue.IssueDiscrete;
8import negotiator.issue.Value;
9import negotiator.issue.ValueDiscrete;
10import negotiator.utility.UtilitySpace;
11
12public class OpponentModel {
13 private double time;
14 private HashMap<Issue, HashMap<Value, Double>> seenWeigth;
15
16 public OpponentModel(UtilitySpace utilitySpace, double time) {
17
18 this.time = time;
19 init(utilitySpace);
20
21 }
22
23 private void init(UtilitySpace utilitySpace) {
24 seenWeigth = new HashMap<Issue, HashMap<Value, Double>>();
25 for (Issue issue : utilitySpace.getDomain().getIssues()) {
26
27 List<ValueDiscrete> values = ((IssueDiscrete) issue).getValues();
28 HashMap<Value, Double> valueMap = new HashMap<Value, Double>();
29 for (Value value : values) {
30 valueMap.put(value, 0.0);
31 }
32 seenWeigth.put(issue, valueMap);
33 }
34 }
35
36 public double timeEffect() {
37 return Math.pow((double) (1 - time), Math.E);
38
39 }
40
41 public void updateModel(Bid bid,int normalize) {
42
43 for (int issueIndex = 0; issueIndex < bid.getIssues().size(); issueIndex++) {
44 Issue issue = bid.getIssues().get(issueIndex);
45 Value issueValue = bid.getValue(issueIndex + 1);
46 HashMap<Value, Double> valueMap = seenWeigth.get(issue);
47
48 valueMap.put(issueValue, valueMap.get(issueValue) + timeEffect()/normalize);
49
50 }
51 }
52
53 public double ExpectedUtility(Bid bid) {
54
55 double utility = 0;
56 for (int issueIndex = 0; issueIndex < bid.getIssues().size(); issueIndex++) {
57 Issue issue = bid.getIssues().get(issueIndex);
58 Value issueValue = bid.getValue(issueIndex + 1);
59
60 HashMap<Value, Double> valueMap = seenWeigth.get(issue);
61 double weight = valueMap.get(issueValue);
62
63 utility += weight;
64 }
65 return utility;
66 }
67
68}
Note: See TracBrowser for help on using the repository browser.