source: anac2020/BlingBling/src/main/java/geniusweb/blingbling/IssueTracker.java@ 3

Last change on this file since 3 was 1, checked in by wouter, 4 years ago

#1910 added anac2020 parties

File size: 2.7 KB
Line 
1package geniusweb.blingbling;
2
3import java.math.BigInteger;
4import java.util.HashMap;
5import java.util.Map;
6
7import geniusweb.issuevalue.Bid;
8import geniusweb.issuevalue.Value;
9import geniusweb.issuevalue.DiscreteValueSet;
10import geniusweb.issuevalue.ValueSet;
11
12//
13//Old represent is the orignial SFM model.
14
15public class IssueTracker {
16 private String issue;
17 private int numValues;
18 private int seenValues = 0;
19
20 private Map<Value, ValueTracker> valueTrackers = new HashMap<Value, ValueTracker>();
21 private Value maxValue = null;
22 private DiscreteValueSet valueset = null;
23 private int maxValueCount = 0;
24
25 private double weight = 0.0;
26
27 public IssueTracker(String issuename, ValueSet valueset) {
28// if (valueset instanceof DiscreteValueSet)
29// throw new RuntimeException("Opponent model is designed for discrete issues only");
30
31 this.issue = issuename;
32 this.valueset = (DiscreteValueSet) valueset;
33 this.numValues = Integer.valueOf(this.valueset.size().toString());//transfer biginteger to int
34 }
35
36 public void registerValue(Value value, int bidsReceived) {//bidsReceived指的是收到的bid的总长度。
37 // create value tracker if needed
38 if (valueTrackers.get(value) == null) {
39 valueTrackers.put(value, new ValueTracker());
40 seenValues++;
41 }
42
43 // register max offered value with count
44 int valueCount = valueTrackers.get(value).incrementGet();
45 if (valueCount > maxValueCount) {
46 maxValueCount = valueCount;
47 maxValue = value;
48 }
49
50 // update issue weight
51 if (numValues > 1) {
52 double equalShares = ((double) bidsReceived / (double) numValues);
53 weight = ((double) maxValueCount - equalShares) / ((double) bidsReceived - equalShares);
54 }
55
56 // update all value evaluations
57 for (ValueTracker valueTracker : valueTrackers.values())
58 valueTracker.updateEvaluation(maxValueCount, weight);
59 }
60
61 public double getEvaluationOld(Value value) {//原SFM的eval
62 return (valueTrackers.get(value) == null) ? 0.0
63 : ((double) valueTrackers.get(value).getCount() / (double) maxValueCount);
64 }
65
66 public double getEvaluation(Value value) {
67 return (valueTrackers.get(value) == null) ? 0.0 : valueTrackers.get(value).getEvaluation();
68 }
69
70 public double getWeight() {
71 return weight;
72 }
73
74 public double getOldWeight(int bidsReceived) {
75 return (bidsReceived == 0) ? 0.0 : (double) maxValueCount / (double) bidsReceived;
76 }
77
78 public Value getMaxValue() {
79 return maxValue;
80 }
81
82 public String toString() {
83 return issue.toString() + ":\n" + valueTrackers.toString() + "\n";
84 }
85}
Note: See TracBrowser for help on using the repository browser.