Java Reference
In-Depth Information
AttributeMap attribute
#
new
AttributeMap
(attrSpec.name,0.0);
attributes.put(attribute.name,attribute);
}
}
// set the weight for an attribute
public void
setWeight(String name, double weight){
AttributeMap attribute
#
(AttributeMap)
attributes.get(name);
attribute.weight
#
weight;
}
// define the rank for a value of an attribute
public void
add(String name, Value value, double rank){
AttributeMap attribute
#
(AttributeMap)
attributes.get(name);
attribute.add(value,rank);
}
// get the details of the preferences for an attribute
public
AttributeMap attribute(String name){
return
(AttributeMap)attributes.get(name);
}
// evaluate a proposal
public double
evaluate(Proposal proposal){
double
value
#
0.0;
Iterator it
#
attributes.values().iterator();
while
(it.hasNext()){
AttributeMap attribute
#
(AttributeMap)it.next();
value
!#
attribute.eval(proposal);
}
return
value;
}
// evaluate a single attribute of a proposal
public
double evaluate(Attribute attribute){
AttributeMap map
#
(AttributeMap)
attributes.get(attribute.name);
if
(map
##
null
)
return
0.0;
return
map.eval(attribute);
}
// returns the rank of the value of an attribute
public double
rank(Attribute attribute){
return
rank(attribute.name,attribute.value);
}
public double
rank(String name, Value value){
AttributeMap map
#
(AttributeMap)attributes.get(name);
if
(map
##
null
)
return
0.0;
return
map.rank(value);
}