source: src/main/java/parties/in4010/q12015/group13/DiscreteIssueModel.java@ 126

Last change on this file since 126 was 126, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

Added input for strategyParameters to SessionPanel (gui)

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

Our own package:

  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 1.0 KB
Line 
1package parties.in4010.q12015.group13;
2
3import java.util.HashMap;
4
5import genius.core.issue.IssueDiscrete;
6import genius.core.issue.ValueDiscrete;
7
8public class DiscreteIssueModel implements IssueModel<ValueDiscrete> {
9
10 private HashMap<ValueDiscrete, Integer> frequency;
11
12 public DiscreteIssueModel(IssueDiscrete i) {
13 frequency = new HashMap(i.getNumberOfValues());
14
15 for (ValueDiscrete v : i.getValues()) {
16 frequency.put(v, 0);
17 }
18 }
19
20 @Override
21 public void addBid(ValueDiscrete v) {
22 int f = frequency.get(v);
23
24 frequency.put(v, f + 1);
25 }
26
27 @Override
28 public double estimateUtility(ValueDiscrete v) {
29 Integer max = Util.getMaximum(frequency.values());
30
31 return frequency.get(v) / (double) max;
32 }
33
34 @Override
35 public String toString() {
36 String ret = "";
37
38 Integer max = Util.getMaximum(frequency.values());
39
40 if (max == 0) {
41 return "Not enough data\n";
42 }
43
44 for (ValueDiscrete v : frequency.keySet()) {
45 ret += " " + v.toString() + " : " + frequency.get(v)
46 / (double) max + "\n";
47 }
48
49 return ret;
50 }
51
52}
Note: See TracBrowser for help on using the repository browser.