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

Last change on this file since 346 was 343, checked in by Tim Baarslag, 4 years ago

Fixed all errors in all 2018 agents

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