Java Reference
In-Depth Information
try {
double maxGap # 0.0;
Attribute maxGapAttribute # null ;
// search the attribute with the highest gap between
// the ranking of the value proposed by the
// counterpart and the last proposed value
Iterator it # counterProposal.attributes.values().
iterator();
while (it.hasNext()){
Attribute attr # (Attribute)it.next();
AttributeMap ranking # preference.attribute
(attr.name);
if (ranking! # null ){ // i.e. attribute is relevant
Attribute rec # received.get(attr.name);
if (rec! # null ){ // i.e. it does matter for the
// other too
double gap # preference.rank(attr)-preference.
rank(rec);
if (gap > maxGap){
maxGap # gap;
maxGapAttribute # attr;
}
}
}
}
if (maxGapAttribute! # null ){
// decrease the value for the attribute with the
// highest gap
counterProposal #
preference.decrease(maxGapAttribute,
counterProposal);
}
} catch (Exception e){ e.printStackTrace(); }
try {
if (preference.evaluate(counterProposal)>threshold){
lastProposal # counterProposal;
return counterProposal;
}
} catch (Exception e){ e.printStackTrace(); }
return lastProposal;
}
public Proposal finalProposal() {
return finalProposal;
}
public void completed( boolean success){
if (success){
Search WWH ::




Custom Search