1 | package negotiator.boaframework.opponentmodel.agentsmithv2;
|
---|
2 |
|
---|
3 | import genius.core.Bid;
|
---|
4 | import genius.core.issue.Issue;
|
---|
5 | import genius.core.issue.Value;
|
---|
6 | import genius.core.misc.ScoreKeeper;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Class which keeps track of the issues for an optimized version of the Smith Frequency Model.
|
---|
10 | *
|
---|
11 | * @author Mark Hendrikx
|
---|
12 | */
|
---|
13 | public class IssueModel {
|
---|
14 |
|
---|
15 | /** Object to keep track of how many times each value of the issue has been offered */
|
---|
16 | private ScoreKeeper<Value> keeper;
|
---|
17 | /** The index of the issue in the domain's XML file */
|
---|
18 | private int issueNr;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * @param issue of which values is kept track in this class
|
---|
22 | */
|
---|
23 | public IssueModel(Issue issue) {
|
---|
24 | keeper = new ScoreKeeper<Value>();
|
---|
25 | this.issueNr = issue.getNumber();
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Method which scores the value which was offered.
|
---|
30 | */
|
---|
31 | public void addValue(Bid pBid) {
|
---|
32 | keeper.score(getBidValueByIssue(pBid, issueNr));
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * The utility of a bid, which can be real, integer or discrete
|
---|
37 | */
|
---|
38 | public double getUtility(Bid pBid) {
|
---|
39 | double lUtility = keeper.getRelativeScore(getBidValueByIssue(pBid, issueNr));
|
---|
40 | return lUtility;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Get's the importance of this issues utility
|
---|
45 | */
|
---|
46 | public double getWeight() {
|
---|
47 | return ((double) keeper.getMaxValue() / (double) keeper.getTotal());
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * returns the value of an issue in a bid
|
---|
52 | */
|
---|
53 | public static Value getBidValueByIssue(Bid pBid, int issueNumber) {
|
---|
54 | Value lValue = null;
|
---|
55 | try {
|
---|
56 | lValue = pBid.getValue(issueNumber);
|
---|
57 | } catch(Exception e) { }
|
---|
58 |
|
---|
59 | return lValue;
|
---|
60 |
|
---|
61 | }
|
---|
62 | }
|
---|