1 | package agents.anac.y2018.groupy;
|
---|
2 | import java.util.List;
|
---|
3 |
|
---|
4 | import java.util.HashMap;
|
---|
5 |
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.issue.Issue;
|
---|
8 | import genius.core.issue.IssueDiscrete;
|
---|
9 | import genius.core.issue.Value;
|
---|
10 | import genius.core.issue.ValueDiscrete;
|
---|
11 | import genius.core.utility.UtilitySpace;
|
---|
12 |
|
---|
13 | public 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 | }
|
---|