Commit bedf795e authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

insert reference values

parent dd5a5f45
......@@ -12,14 +12,14 @@
"expectedResult" : "SUCCESS",
"optimizationMetricProcessorId" : 2,
"testEvacuationProcessorId" : 3,
"maxMeanPointDistance" : 0.0,
"maxMeanDifferenceFuncValue" : 0.0,
"maxMeanPointDistance" : 0.11587864045699435,
"maxMeanDifferenceFuncValue" : 0.04361768439961036,
"infoMinPointDistanceL2" : 0.0,
"infoMaxPointDistanceL2" : 0.0,
"infoMinFuncDifference" : 0.0,
"infoMaxFuncDifference" : 0.0,
"infoStddevPointDistance" : 0.0,
"infoStddevDifferenceFuncValue" : 0.0
"infoMaxPointDistanceL2" : 1.3811487909016231,
"infoMinFuncDifference" : -5.75750936526731E-6,
"infoMaxFuncDifference" : 0.6140615296568299,
"infoStddevPointDistance" : 0.13855327312344268,
"infoStddevDifferenceFuncValue" : 0.05671472149876091
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianMetricOptimizationProcessor",
......
......@@ -12,14 +12,14 @@
"expectedResult" : "SUCCESS",
"optimizationMetricProcessorId" : 2,
"testEvacuationProcessorId" : 3,
"maxMeanPointDistance" : 0.0,
"maxMeanDifferenceFuncValue" : 0.0,
"maxMeanPointDistance" : 0.10747320917296704,
"maxMeanDifferenceFuncValue" : 0.06089881379635064,
"infoMinPointDistanceL2" : 0.0,
"infoMaxPointDistanceL2" : 0.0,
"infoMinFuncDifference" : 0.0,
"infoMaxFuncDifference" : 0.0,
"infoStddevPointDistance" : 0.0,
"infoStddevDifferenceFuncValue" : 0.0
"infoMaxPointDistanceL2" : 1.050866878969745,
"infoMinFuncDifference" : -9.391696791638537E-5,
"infoMaxFuncDifference" : 1.2287247872104103,
"infoStddevPointDistance" : 0.1585299970292929,
"infoStddevDifferenceFuncValue" : 0.07793837122135712
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianMetricOptimizationProcessor",
......@@ -31,7 +31,7 @@
"attributes" : {
"expectedResult" : "SUCCESS",
"evacuationTimeProcessorId" : 4,
"maximalEvacuationTime" : 300.0,
"maximalEvacuationTime" : 200.0,
"minimalEvacuationTime" : 0.0
}
}, {
......@@ -78,7 +78,7 @@
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 1,
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : false,
......
......@@ -12,14 +12,14 @@
"expectedResult" : "SUCCESS",
"optimizationMetricProcessorId" : 2,
"testEvacuationProcessorId" : 3,
"maxMeanPointDistance" : 0.0,
"maxMeanDifferenceFuncValue" : 0.0,
"maxMeanPointDistance" : 0.10320735815457976,
"maxMeanDifferenceFuncValue" : 0.06573000624569796,
"infoMinPointDistanceL2" : 0.0,
"infoMaxPointDistanceL2" : 0.0,
"infoMinFuncDifference" : 0.0,
"infoMaxFuncDifference" : 0.0,
"infoStddevPointDistance" : 0.0,
"infoStddevDifferenceFuncValue" : 0.0
"infoMaxPointDistanceL2" : 1.4137730000637334,
"infoMinFuncDifference" : -0.0061021424381255684,
"infoMaxFuncDifference" : 3.1035982147173797,
"infoStddevPointDistance" : 0.1390008307897397,
"infoStddevDifferenceFuncValue" : 0.1659699405499854
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianMetricOptimizationProcessor",
......@@ -61,7 +61,7 @@
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"optimizationType" : "NELDER_MEAD_CIRCLE",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
......
......@@ -12,14 +12,14 @@
"expectedResult" : "SUCCESS",
"optimizationMetricProcessorId" : 2,
"testEvacuationProcessorId" : 3,
"maxMeanPointDistance" : 0.0,
"maxMeanDifferenceFuncValue" : 0.0,
"infoMinPointDistanceL2" : 0.0,
"infoMaxPointDistanceL2" : 0.0,
"infoMinFuncDifference" : 0.0,
"infoMaxFuncDifference" : 0.0,
"infoStddevPointDistance" : 0.0,
"infoStddevDifferenceFuncValue" : 0.0
"maxMeanPointDistance" : 0.10022407400619819,
"maxMeanDifferenceFuncValue" : 0.0290377478254851,
"infoMinPointDistanceL2" : 0.0013923666721278889,
"infoMaxPointDistanceL2" : 0.8023722950469786,
"infoMinFuncDifference" : 5.782711474324742E-4,
"infoMaxFuncDifference" : 0.25073794045603925,
"infoStddevPointDistance" : 0.06922123874051399,
"infoStddevDifferenceFuncValue" : 0.02692125553243474
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianMetricOptimizationProcessor",
......
......@@ -24,6 +24,8 @@ public class OptimizationMetric {
private VPoint foundPoint;
private double foundFuncValue;
private final double tolerance;
public OptimizationMetric(int pedId, double simTime, final VPoint optimalPoint, double optimalFuncValue,
final VPoint foundPoint, final double foundFuncValue){
......@@ -36,14 +38,14 @@ public class OptimizationMetric {
this.foundPoint = foundPoint;
this.foundFuncValue = foundFuncValue;
// TODO: insert tolerance
if(optimalFuncValue > foundFuncValue){
tolerance = 1E-2;
if( optimalFuncValue - foundFuncValue > tolerance ){
Logger.getLogger(TestOptimizationMetricNelderMeadProcessor.class).warn(
"Found optimal value is better than brute force. This can indicate that the " +
"brute force is not fine grained enough. BRUTE FORCE: " + optimalFuncValue +
" OPTIMIZER: " + foundFuncValue);
}
}
public double getSimTime() {
......
......@@ -52,14 +52,26 @@ public class StepCircleOptimizerCircleNelderMead extends StepCircleOptimizer {
double twoDimResult = ped.getPotential(point2D);
double currentPotential = ped.getPotential(ped.getPosition());
VPoint resultPoint;
double minFuncValue;
if(oneDimResult < twoDimResult && oneDimResult < currentPotential) {
return point1D;
minFuncValue = oneDimResult;
resultPoint = point1D;
} else if(twoDimResult < currentPotential) {
return point2D;
minFuncValue = oneDimResult;
resultPoint = point2D;
} else {
return ped.getPosition();
minFuncValue = currentPotential;
resultPoint = ped.getPosition();
}
if(getIsComputeMetric()){
// See merge request !65
this.computeAndAddBruteForceSolutionMetric(ped, new SolutionPair(resultPoint.clone(), minFuncValue));
}
//return point2D;
return resultPoint;
}
private List<Pair<Double, Double>> generate1DSimplexes(@NotNull final PedestrianOSM ped, @NotNull final VCircle stepCircle) {
......
......@@ -2,6 +2,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.Simulation;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.simulator.models.osm.optimization.OptimizationMetric;
......@@ -24,8 +25,11 @@ import java.util.Collection;
@DataProcessorClass()
public class PedestrianMetricOptimizationProcessor extends DataProcessor<EventtimePedestrianIdKey, OptimizationMetric>{
private boolean receivedValues;
public PedestrianMetricOptimizationProcessor() {
super("optX", "optY", "optFunc", "foundX", "foundY", "foundFunc");
receivedValues = false;
}
@Override
......@@ -40,6 +44,7 @@ public class PedestrianMetricOptimizationProcessor extends DataProcessor<Eventti
throw new RuntimeException("Pedestrian OptimizationMetric is null. This means that there the " +
"configuration is not to measure the quality is not active.");
}else if (!pedestrianMetrics.isEmpty()) {
receivedValues = true;
for (OptimizationMetric singleMetric : pedestrianMetrics) {
putValue(new EventtimePedestrianIdKey(singleMetric.getSimTime(), singleMetric.getPedId()), singleMetric);
}
......@@ -48,6 +53,15 @@ public class PedestrianMetricOptimizationProcessor extends DataProcessor<Eventti
}
}
@Override
public void postLoop(final SimulationState state){
if(!this.receivedValues){
throw new RuntimeException("PedestrianMetricOptimizationProcessor received no values. This can be because" +
"Vadere is not configured to compare to the brute force solution or the selected optimizer does " +
"not support it. (See file StepCircleOptimizer)");
}
}
@Override
public void init(final ProcessorManager manager) {
super.init(manager);
......
......@@ -95,7 +95,13 @@ public class TestOptimizationMetricNelderMeadProcessor extends TestProcessor {
pointDistanceL2Values.add(singleMetric.getOptimalPoint().distance(singleMetric.getFoundPoint()));
// Insert all values for difference in the function values.
differenceFuncValues.add(singleMetric.getOptimalFuncValue() - singleMetric.getFoundFuncValue());
differenceFuncValues.add(singleMetric.getFoundFuncValue() - singleMetric.getOptimalFuncValue());
}
if(pointDistanceL2Values.isEmpty() || differenceFuncValues.isEmpty()){
throw new NullPointerException("No values to compare. Reasons can be that i) there are no agents in the " +
"scenario, ii) the option to compare with the brute force is turned off or iii) or the optimizer " +
"does not support setting the OptimizationMetric. ");
}
var metricStatistics = computeStatistics(pointDistanceL2Values, differenceFuncValues);
......@@ -125,7 +131,7 @@ public class TestOptimizationMetricNelderMeadProcessor extends TestProcessor {
msg = "NEGATIVE -- The statistics '" + valueName + "' increased by " + diff +
" (BEFORE:" + referenceValue + " NOW: " + newValue + ")";
}else{
msg = "NEUTRAL -- The statistics '" + valueName + "' is equal to the reference value.";
msg = "NEUTRAL -- The statistics '" + valueName + "' is equal to the reference value. Value = " + newValue;
}
return msg;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment