source: src/main/java/agents/ai2014/group4/IssueModel.java@ 61

Last change on this file since 61 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.5 KB
Line 
1package agents.ai2014.group4;
2
3import java.util.HashMap;
4import java.util.List;
5
6import genius.core.issue.ValueDiscrete;
7
8public class IssueModel{
9
10 private List<ValueDiscrete> values;
11 private HashMap<String, Double> utility;
12 private double value;
13 private String name;
14
15 public IssueModel(String name, List<ValueDiscrete> values){
16 this.setName(name);
17 this.values = values;
18
19 this.utility = new HashMap<String, Double>();
20 for (ValueDiscrete option: values) {
21 utility.put(option.getValue(), 1.0);
22 }
23 }
24
25 public double getUtility(ValueDiscrete option){
26 return utility.get(option.getValue());
27 }
28
29 public void updateUtility(ValueDiscrete option, double change){
30 utility.put(option.getValue(), utility.get(option.getValue()) + change);
31 //normalisation
32 double max=0;
33 for(ValueDiscrete o: values){
34 max=Math.max(max, utility.get(o));
35 }
36 for(ValueDiscrete o: values){
37 utility.put(o.getValue(), Math.max(0, utility.get(o.getValue()))/max);
38 }
39 }
40
41 public void setValue(double a){
42 value = a;
43 }
44
45 public double getValue(){
46 return value;
47 }
48
49 public String getName() {
50 return name;
51 }
52
53 public void setName(String name) {
54 this.name = name;
55 }
56
57 public HashMap<String, Double> getUtility() {
58 return utility;
59 }
60
61 public void setUtility(HashMap<String, Double> utility) {
62 this.utility = utility;
63 }
64
65 public List<ValueDiscrete> getValues() {
66 return values;
67 }
68
69 public void setValues(List<ValueDiscrete> values) {
70 this.values = values;
71 }
72
73
74
75}
Note: See TracBrowser for help on using the repository browser.