Last change
on this file was 127, checked in by Wouter Pasman, 6 years ago |
#41 ROLL BACK of rev.126 . So this version is equal to rev. 125
|
File size:
1.2 KB
|
Rev | Line | |
---|
[127] | 1 | package agents.anac.y2012.AgentLG;
|
---|
| 2 | import java.util.HashMap;
|
---|
| 3 |
|
---|
| 4 | import genius.core.issue.Issue;
|
---|
| 5 | import genius.core.issue.Value;
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * Class that is used to learn opponent utility.
|
---|
| 9 | */
|
---|
| 10 | public class BidStatistic {
|
---|
| 11 |
|
---|
| 12 | private HashMap<Value,Integer> valStatis = new HashMap<Value,Integer>();
|
---|
| 13 | private Issue issue= null;
|
---|
| 14 | private double numVotes =0;
|
---|
| 15 |
|
---|
| 16 | public BidStatistic(Issue issue) {
|
---|
| 17 | super();
|
---|
| 18 | this.issue = issue;
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | public void add(Value v)
|
---|
| 25 | {
|
---|
| 26 | if(valStatis.get(v)== null)
|
---|
| 27 | valStatis.put(v,1);
|
---|
| 28 | else
|
---|
| 29 | valStatis.put(v,valStatis.get(v)+1);
|
---|
| 30 | numVotes++;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public Value getMostBided()
|
---|
| 34 | {
|
---|
| 35 | Value maxval = null;
|
---|
| 36 | Integer maxtimes=0;
|
---|
| 37 | for(Value val:valStatis.keySet())
|
---|
| 38 | {
|
---|
| 39 | if (valStatis.get(val)>maxtimes)
|
---|
| 40 | {
|
---|
| 41 | maxtimes=valStatis.get(val);
|
---|
| 42 | maxval=val;
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 | return maxval;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | public int getMostVotedCount()
|
---|
| 49 | {
|
---|
| 50 | Integer maxtimes=0;
|
---|
| 51 | for(Value val:valStatis.keySet())
|
---|
| 52 | {
|
---|
| 53 | if (valStatis.get(val)>maxtimes)
|
---|
| 54 | {
|
---|
| 55 | maxtimes=valStatis.get(val);
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | return maxtimes;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | public double getValueUtility(Value value)
|
---|
| 62 | {
|
---|
| 63 | double ret = 0;
|
---|
| 64 | if (valStatis.get(value)!= null)
|
---|
| 65 | ret = ((double)valStatis.get(value))/getMostVotedCount();
|
---|
| 66 | return ret;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.