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