TripWeightedRouteSorter
package com.tegl.commercial.trade.marketagent.routes.sorters;
import com.tegl.commercial.trade.marketagent.entities.AbstractRoute;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*
*/
public class TripWeightedRouteSorter extends WeightedRouteSorter {
private Log log = LogFactory.getLog(this.getClass());
protected int sort(AbstractRoute r1, AbstractRoute r2) {
float one_score = calculateScore(r1);
float two_score = calculateScore(r2);
return cmpr(one_score, two_score);
}
/**
* For distance > 0, generates a score somewhere between <code>profit</code> (if SF = 0.0) and
* <code>profit/jump</code> (if SF = 1.0).<br>
* For distance = 0, returns <code>profit / 0.3</code>
* Uses Trip Distance for distance
*
* @param route
* @return the score
*/
public float calculateScore(AbstractRoute route) {
log.trace("calculateScore()");
float profit = route.getProfit();
int j = route.getTripDistance();
float score = weightedScore(profit, j);
log.debug("score = " + score);
return score;
}
}