Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 5467f56c authored by Tomofumi Yuki's avatar Tomofumi Yuki
Browse files

fixed bias calculation (it was an older version than the final one in

stable-clean)
parent 167fbd6e
No related branches found
No related tags found
1 merge request!4Develop
......@@ -244,23 +244,34 @@ public class TabuExploration extends AbstractExplorationAlgorithm {
List<Integer> lastModifiedWLs = nextSolutionCandidates.stream()
.map(e -> e.getCurrentW(e.lastModifiedSymbol))
.collect(toList());
List<Double> accuracyValues = nextSolutionCandidates.stream()
.map(e -> getAccuracy(e.getLastCreatedSolution()).get())
.collect(toList());
ValuesNormalizer accuracyNormalizer = new ValuesNormalizer(accuracyValues);
.map(e -> getAccuracy(e.getLastCreatedSolution()).get())
.collect(toList());
List<Double> costValues = nextSolutionCandidates.stream()
.map(e -> getCost(e.getLastCreatedSolution()).get())
.collect(toList());
ValuesNormalizer costNormalizer = new ValuesNormalizer(costValues);
ValuesNormalizer accuracyNormalizer = new ValuesNormalizer(accuracyValues);
ValuesNormalizer costNormalizer = new ValuesNormalizer(costValues);
//FIXME these values are currently arbitrary
{
//max must be obtained before setting min or range, since it is computed from min and range
final double accMax = accuracyNormalizer.getMax();
final double costMax = costNormalizer.getMax();
accuracyNormalizer.setRange(Math.max(accuracyMetric.getNormalizationRangeLB(), accuracyNormalizer.getRange()));
accuracyNormalizer.setMin(accMax-accuracyNormalizer.getRange());
costNormalizer.setRange(Math.max(costMetric.getNormalizationRangeLB(), costNormalizer.getRange()));
costNormalizer.setMin(costMax-costNormalizer.getRange());
}
Double normalizedCurrentAccuray = getAccuracy(currentSolution).map(accuracyNormalizer::normalize).orElse(null);
Double normalizedCurrentCost = getCost(currentSolution).map(costNormalizer::normalize).orElse(null);
List<Double> normalizedAccuracyValues = accuracyNormalizer.normalize(accuracyValues);
List<Double> normalizedCostValues = costNormalizer.normalize(costValues);
List<Double> criteria = new LinkedList<>();
for (int i = 0; i < nextSolutionCandidates.size(); i++) {
Integer lastModifiedWL = lastModifiedWLs.get(i);
......@@ -269,15 +280,23 @@ public class TabuExploration extends AbstractExplorationAlgorithm {
Double ratio = (1 + computeImprovement(normalizedCurrentAccuray, normalizedAccuracyValue, accuracyMetric.isHigherBetter())) /
(1 + computeDegradation(normalizedCurrentCost, normalizedCostValue, costMetric.isHigherBetter()));
Double WLbias = lastModifiedWL.doubleValue() / (10000);
//FIXME bias strength is currently not well thought out
Double WLbias = Math.pow(lastModifiedWL.doubleValue(), 1.2) / (350); //TODO try 250
final Double criterion;
if (directionUp)
criterion = ratio - WLbias;
else
criterion = ratio + WLbias;
logger.warning(String.format("TabuSearchMetric: %f -> %f", ratio, criterion));
WordLengthsExplorer candidate = nextSolutionCandidates.get(i);
logger.info(String.format("TabuSearchMetric (%s; WL:%d, Acc:%f, Cost:%f, NormAcc:%f, NormCost:%f): %f -> %f",
candidate.getLastModifiedSymbol().getName(), lastModifiedWL.intValue(),
accuracyValues.get(i), costValues.get(i),
normalizedAccuracyValue, normalizedCostValue,
ratio, criterion));
criteria.add(criterion);
nextSolutionCandidates.get(i).currentSolution.setNote("gradient", criterion+"");
nextSolutionCandidates.get(i).currentSolution.setNote("selected", "F");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment