Java Reference
In-Depth Information
// return the best proposal, that is the one with the
// highest value where every attribute assumes the value
// with the highest rank
public Proposal bestProposal(){
Proposal best # new Proposal();
Iterator it # attributes.values().iterator();
while (it.hasNext()){
AttributeMap attribute # (AttributeMap);
if (attribute.weight>0)
return best;
// fix the values of the attributes of a proposal
// so that each attribute is admissible
public void ensureAdmissible(Proposal proposal){
Iterator it # proposal.getAttributes().iterator();
while (it.hasNext()){
Attribute attribute # (Attribute);
public void ensureAdmissible(Attribute attribute){
// if the current value is admissible there's nothing
// to do
if (attribute.admissibleValues.contains(attribute.value))
return ;
// otherwise find among the admissible values the one
// having the rank closest to that of the current value.
// In case of equal difference of ranks, preference is
// given to values having lower ranks.
double previousRank # rank(attribute);
double newRank # -1;
Value newValue # null ;
Iterator it # attribute.admissibleValues.iterator();
while (it.hasNext()){
Value value # (Value);
double rank # rank(,value);
if (Math.abs(rank - previousRank)
< Math.abs(newRank - previousRank)){
newRank # rank;
newValue # value;
} else
if (Math.abs(rank - newRank)
## Math.abs(rank - previousRank)
Search WWH ::

Custom Search