From: Stefan F. <ste...@us...> - 2010-05-02 17:33:10
|
Update of /cvsroot/rails/18xx/rails/algorithms In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv10835/rails/algorithms Modified Files: RevenueCalculator.java Log Message: Fixed problem with ignoreMinor vertexValues Index: RevenueCalculator.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/algorithms/RevenueCalculator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RevenueCalculator.java 1 May 2010 16:07:05 -0000 1.9 --- RevenueCalculator.java 2 May 2010 17:33:00 -0000 1.10 *************** *** 140,148 **** for (int j=0; j < nbVertexes; j++) { ! if (vertexMajor[id]) { vertexValueByTrain[j][id] = vertexValueByTrain[j][id] * multiplyMajors; ! } ! if (vertexMinor[id]) { ! vertexValueByTrain[j][id] = vertexValueByTrain[j][id] * multiplyMinors; } } --- 140,151 ---- for (int j=0; j < nbVertexes; j++) { ! if (vertexMajor[j]) { vertexValueByTrain[j][id] = vertexValueByTrain[j][id] * multiplyMajors; ! } else if (vertexMinor[j]) { ! if (ignoreMinors) { ! vertexValueByTrain[j][id] = 0; ! } else { ! vertexValueByTrain[j][id] = vertexValueByTrain[j][id] * multiplyMinors; ! } } } *************** *** 160,163 **** --- 163,175 ---- } + String getStatistics() { + StringBuffer statistics = new StringBuffer(); + statistics.append(nbEvaluations + " evaluations"); + if (useRevenuePrediction) + statistics.append(", " + nbPredictions + " predictions"); + statistics.append(" and " + nbEdges + " edges travelled."); + return statistics.toString(); + } + private void notifyRevenueAdapter(final int revenue, final boolean finalResult) { String modifier; *************** *** 166,175 **** else modifier = "new best"; ! StringBuffer statistics = new StringBuffer(); ! statistics.append(nbEvaluations + " evaluations"); ! if (useRevenuePrediction) ! statistics.append(", " + nbPredictions + " predictions"); ! statistics.append(" and " + nbEdges + " edges travelled."); ! log.info("Report " + modifier + " result of " + revenue + " after " + statistics.toString()); revenueAdapter.notifyRevenueListener(revenue, finalResult); } --- 178,182 ---- else modifier = "new best"; ! log.info("Report " + modifier + " result of " + revenue + " after " + getStatistics()); revenueAdapter.notifyRevenueListener(revenue, finalResult); } *************** *** 215,218 **** --- 222,227 ---- if (startTrain > finalTrain) return; + + nbEvaluations = 0; nbPredictions = 0; nbEdges = 0; useRevenuePrediction = true; *************** *** 233,237 **** currentBestValue = 0; runTrain(j); ! log.info("RC: Best prediction run of train number " + j + " value = " + currentBestValue); maxSingleTrainRevenues[j] = currentBestValue; cumulatedRevenues += currentBestValue; --- 242,247 ---- currentBestValue = 0; runTrain(j); ! log.info("RC: Best prediction run of train number " + j + " value = " + currentBestValue + ! " after " + getStatistics()); maxSingleTrainRevenues[j] = currentBestValue; cumulatedRevenues += currentBestValue; *************** *** 247,251 **** currentBestValue = 0; runTrain(j); ! log.info("RC: Best prediction run until train nb. " + j + " value = " + currentBestValue); maxCumulatedTrainRevenues[j] = currentBestValue; maxCumulatedTrainRevenues[j-1] = currentBestValue + maxSingleTrainRevenues[j-1]; --- 257,262 ---- currentBestValue = 0; runTrain(j); ! log.info("RC: Best prediction run until train nb. " + j + " value = " + currentBestValue + ! " after " + getStatistics()); maxCumulatedTrainRevenues[j] = currentBestValue; maxCumulatedTrainRevenues[j-1] = currentBestValue + maxSingleTrainRevenues[j-1]; *************** *** 255,260 **** int calculateRevenue(int startTrain, int finalTrain) { log.info("RC: calculateRevenue trains from " + startTrain + " to " + finalTrain); - - nbEvaluations = 0; nbPredictions = 0; nbEdges = 0; this.startTrain = startTrain; --- 266,269 ---- |