public class EvaluatorDiscrete extends java.lang.Object implements Evaluator
ValueDiscrete
is evaluated, there are two possibilities:
Integer
utilities.
This is because we need to stay backwards compatible with older versions of
Genius.Constructor and Description |
---|
EvaluatorDiscrete()
Creates a new discrete evaluator with weight 0 and no values.
|
EvaluatorDiscrete(java.util.HashMap<ValueDiscrete,java.lang.Double> fEval) |
Modifier and Type | Method and Description |
---|---|
void |
addEvaluation(ValueDiscrete value,
java.lang.Integer evaluation)
Add a new possible value to the issue.
|
void |
clear()
wipe evaluation values.
|
EvaluatorDiscrete |
clone() |
boolean |
equals(java.lang.Object obj) |
java.lang.Double |
getDoubleValue(ValueDiscrete value) |
double |
getEvalMax() |
java.lang.Double |
getEvaluation(AdditiveUtilitySpace uspace,
Bid bid,
int issueID)
This method returns the utility of the value of an issue.
|
java.lang.Double |
getEvaluation(ValueDiscrete value) |
java.lang.Integer |
getEvaluationNotNormalized(Bid bid,
int ID) |
java.lang.Integer |
getEvaluationNotNormalized(ValueDiscrete value) |
Value |
getMaxValue() |
Value |
getMinValue() |
EVALUATORTYPE |
getType() |
java.lang.Integer |
getValue(ValueDiscrete value) |
java.util.Set<ValueDiscrete> |
getValues() |
double |
getWeight() |
int |
hashCode() |
java.lang.String |
isComplete(Objective whichobj)
Check whether the evaluator has enough information to make an evaluation.
|
void |
loadFromXML(SimpleElement pRoot)
Loads
fEval from a SimpleElement containing something like this:
<item index="1" description=
"Buy bags of chips and party nuts for all guests."
value="Chips and Nuts" cost="100.0" evaluation="3"> . |
void |
lockWeight()
lockWeight is a flag affecting the behaviour of the normalize function in
the utility space.
|
java.lang.Double |
normalize(double EvalValueL) |
void |
normalizeAll()
Sets the maximum value to 1 and scales values and weights accordingly
|
void |
scaleAllValuesFrom0To1()
Sets the maximum value to 1, the minimum value to 0, and scales values accordingly
|
void |
setEvaluation(Value val,
int evaluation)
Sets the evaluation for Value
val . |
void |
setEvaluationDouble(ValueDiscrete val,
double evaluation)
identical to
setEvaluation(Value, int) but accepts double. |
void |
setWeight(double wt)
Sets the weigth with which an Objective or Issue is evaluated.
|
SimpleElement |
setXML(SimpleElement evalObj)
Sets weights and evaluator properties for the object in SimpleElement
representation that is passed to it.
|
java.lang.String |
toString() |
void |
unlockWeight()
Method to unlock a weight.
|
boolean |
weightLocked() |
public EvaluatorDiscrete()
public EvaluatorDiscrete(java.util.HashMap<ValueDiscrete,java.lang.Double> fEval)
public double getWeight()
public void setWeight(double wt)
Evaluator
public void lockWeight()
Evaluator
lockWeight
in interface Evaluator
public void unlockWeight()
Evaluator
unlockWeight
in interface Evaluator
public boolean weightLocked()
weightLocked
in interface Evaluator
public void loadFromXML(SimpleElement pRoot)
fEval
from a SimpleElement containing something like this:
<item index="1" description=
"Buy bags of chips and party nuts for all guests."
value="Chips and Nuts" cost="100.0" evaluation="3">
.
Only the value and evaluation are used, the rest is ignored. NOTICE: the
fWeight of this EvaluatorDiscrete is not set.loadFromXML
in interface Evaluator
public java.lang.String isComplete(Objective whichobj)
Evaluator
isComplete
in interface Evaluator
whichobj
- is the objective/issue to which this evaluator is attached.public EvaluatorDiscrete clone()
public java.lang.Double getEvaluation(AdditiveUtilitySpace uspace, Bid bid, int issueID)
Evaluator
getEvaluation
in interface Evaluator
uspace
- preference profilebid
- in which the value is contained.issueID
- unique ID of the issue in the bid for which we want an
evaluation.public java.lang.Integer getValue(ValueDiscrete value)
value
- of which the evaluation is requested. ALways returns rounded
values, to be compatible with the old version of PN where
values could be only integers.public java.lang.Double getDoubleValue(ValueDiscrete value)
value
- public java.lang.Double getEvaluation(ValueDiscrete value) throws java.lang.Exception
value
- of the issue.java.lang.Exception
- if value is null.public java.lang.Integer getEvaluationNotNormalized(Bid bid, int ID) throws java.lang.Exception
bid
- ID
- of the issue of which we are interested in the valuejava.lang.Exception
- if bid or value is null.public java.lang.Integer getEvaluationNotNormalized(ValueDiscrete value) throws java.lang.Exception
value
- of the issue.getValue(ValueDiscrete)
.java.lang.Exception
- if value is null.public java.lang.Double normalize(double EvalValueL)
public EVALUATORTYPE getType()
public void setEvaluation(Value val, int evaluation)
val
. If this value doesn't
exist yet in this Evaluator, adds it as well.val
- The value to add or have its evaluation modified.evaluation
- The new evaluation. only POSITIVE integer values acceptable as
evaluationpublic void setEvaluationDouble(ValueDiscrete val, double evaluation)
setEvaluation(Value, int)
but accepts double.val
- The value to add or have its evaluation modified.evaluation
- The new evaluation. only POSITIVE integer values acceptable as
evaluation valuepublic void clear()
public SimpleElement setXML(SimpleElement evalObj)
evalObj
- The object of which to set the evaluation properties.public void addEvaluation(ValueDiscrete value, java.lang.Integer evaluation)
setEvaluation(Value, int)
. To set Double values, use
setEvaluationDouble(ValueDiscrete, double)
.value
- to be added to the issue.evaluation
- of the value.public Value getMaxValue()
public void normalizeAll()
public void scaleAllValuesFrom0To1()
public Value getMinValue()
public java.util.Set<ValueDiscrete> getValues()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public double getEvalMax()