1 | package negotiator.boaframework.opponentmodel.nash;
|
---|
2 |
|
---|
3 | import genius.core.issue.ISSUETYPE;
|
---|
4 | import genius.core.issue.Issue;
|
---|
5 | import genius.core.issue.Value;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * This is the base version of the evaluation of an issue. It holds the issue we are evaluating for later reference,
|
---|
9 | * and keep track of the firstOfferedValue (which we suppose is important).
|
---|
10 | *
|
---|
11 | * This base class offers the guidelines that a specific IssueEvaluation should implement.
|
---|
12 | *
|
---|
13 | * @author Roland van der Linden
|
---|
14 | *
|
---|
15 | */
|
---|
16 | public abstract class AIssueEvaluation
|
---|
17 | {
|
---|
18 | // ********************************
|
---|
19 | // Fields
|
---|
20 | // ********************************
|
---|
21 |
|
---|
22 | //The issue we are evaluating.
|
---|
23 | protected Issue issue;
|
---|
24 | //This is the value that has been offered the first time (probably the most preferred value).
|
---|
25 | protected Value firstOfferedValue;
|
---|
26 |
|
---|
27 |
|
---|
28 | // ********************************
|
---|
29 | // Constructor & init
|
---|
30 | // ********************************
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * This constructs the AIssueEvaluation. You need to provide the issue that will
|
---|
34 | * be evaluated, so that the appropriate fields can be initialized.
|
---|
35 | * @param issue The issue we are evaluating. May not be null.
|
---|
36 | */
|
---|
37 | public AIssueEvaluation(Issue issue)
|
---|
38 | {
|
---|
39 | if(issue == null)
|
---|
40 | throw new IllegalArgumentException("The provided issue was null.");
|
---|
41 |
|
---|
42 | this.issue = issue;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | // ********************************
|
---|
47 | // Update
|
---|
48 | // ********************************
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * This method updates the issueEvaluation. Subclasses should override this
|
---|
52 | * method to handle values that have been chosen in a newly offered bid.
|
---|
53 | *
|
---|
54 | * We also save the first value that has been offered to find out if this always is they're
|
---|
55 | * most important value.
|
---|
56 | * @param chosenValue The value of the issue we are evaluating that has just been chosen. May not be null.
|
---|
57 | */
|
---|
58 | public void updateIssueEvaluation(Value chosenValue)
|
---|
59 | {
|
---|
60 | if(chosenValue == null)
|
---|
61 | throw new IllegalArgumentException("The chosenValue may not be null.");
|
---|
62 |
|
---|
63 | //We save the first offered value.
|
---|
64 | if(!this.isFirstValueOffered())
|
---|
65 | this.firstOfferedValue = chosenValue;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | // ********************************
|
---|
70 | // Getters
|
---|
71 | // ********************************
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * This method specifies that each subclass needs to implement a function that gives us
|
---|
75 | * the normalized weight for the given value. Since the value can be either discrete or numerical,
|
---|
76 | * we need to subclass to define how to extract the normalized valueWeight.
|
---|
77 | *
|
---|
78 | * Note that normalization for the valueWeights is done like this:
|
---|
79 | * - The value with the highest estimated utility has normalized weight 1.
|
---|
80 | * - The normalized weight of the other values is scaled accordingly.
|
---|
81 | *
|
---|
82 | * @param value The value (discrete or non-discrete) of which we want to know the normalized weight.
|
---|
83 | * @return The normalized weight of the given value, ranging between 1 and 0.
|
---|
84 | */
|
---|
85 | public abstract double getNormalizedValueWeight(Value value);
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * This method tells us whether a first value has been offered or not.
|
---|
89 | * @return true if first value has been offered.
|
---|
90 | */
|
---|
91 | public boolean isFirstValueOffered()
|
---|
92 | {
|
---|
93 | return this.firstOfferedValue != null;
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * This returns the ID of the issue we are evaluating.
|
---|
98 | * @return The ID of the issue.
|
---|
99 | */
|
---|
100 | public int getIssueID()
|
---|
101 | {
|
---|
102 | return this.issue.getNumber();
|
---|
103 | }
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * This returns the name of the issue we are evaluating.
|
---|
107 | * @return The name of the issue.
|
---|
108 | */
|
---|
109 | public String getIssueName()
|
---|
110 | {
|
---|
111 | return this.issue.getName();
|
---|
112 | }
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * This returns the type of the issue we are evaluating.
|
---|
116 | * @return The type of the issue.
|
---|
117 | */
|
---|
118 | public ISSUETYPE getIssueType()
|
---|
119 | {
|
---|
120 | return this.issue.getType();
|
---|
121 | }
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * This returns a string representation of the issueEvaluation.
|
---|
125 | * @return The string representation.
|
---|
126 | */
|
---|
127 | public String toString()
|
---|
128 | {
|
---|
129 | String result = "";
|
---|
130 | String nl = "\n";
|
---|
131 | String pre = " ";
|
---|
132 |
|
---|
133 | String firstOffered = "null";
|
---|
134 | if(this.firstOfferedValue != null)
|
---|
135 | firstOffered = this.firstOfferedValue.toString();
|
---|
136 |
|
---|
137 | result += "##### IssueEvaluation #####" + nl;
|
---|
138 | result += "===== IssueID, IssueName, IssueType, FirstOfferedValue =====" + nl;
|
---|
139 | result += pre + this.getIssueID() + " - " + this.getIssueName() + " - " + this.getIssueType() + " - " + firstOffered + nl;
|
---|
140 |
|
---|
141 | return result;
|
---|
142 | }
|
---|
143 | } |
---|