Commit 7985cf54 authored by BZoennchen's avatar BZoennchen

minor changes to the new NelderMead1D and 2D version: terminate if result is...

minor changes to the new NelderMead1D and 2D version: terminate if result is zero or SOME point of the simplex lies inside an obstacle.
parent 3b554efc
Pipeline #113174 failed with stages
in 101 minutes and 28 seconds
......@@ -87,8 +87,9 @@ public class StepCircleOptimizerCircleNelderMead implements StepCircleOptimizer
double dist = p1.distance(stepCircle.getCenter());
VPoint midPoint = new VLine(p1, p2).midPoint();
VPoint p3;
if(Math.abs(dist-radDist) > GeometryUtils.DOUBLE_EPS) {
VPoint e = midPoint.subtract(ped.getPosition()).setMagnitude(dist-radDist);
double circRadius = ped.getPosition().distance(p1);
if(Math.abs(circRadius-radDist) > GeometryUtils.DOUBLE_EPS) {
VPoint e = midPoint.subtract(ped.getPosition()).setMagnitude(circRadius-radDist);
p3 = ped.getPosition().add(e);
} else {
p3 = ped.getPosition();
......
......@@ -19,6 +19,10 @@ import java.util.stream.Stream;
public class NelderMead1D {
private static final Logger logger = Logger.getLogger(NelderMead1D.class);
static {
logger.setInfo();
}
private final VCircle evalArea;
private final Function<IPoint, Double> eval;
private final double threashold;
......@@ -65,7 +69,7 @@ public class NelderMead1D {
logger.warn("max iteration reached!");
}
logger.info("iterations: " + overallIterations);
logger.debug("iterations: " + overallIterations);
}
......
......@@ -19,6 +19,10 @@ import java.util.stream.Stream;
public class NelderMead2D {
private static final Logger logger = Logger.getLogger(NelderMead2D.class);
static {
logger.setInfo();
}
private final VCircle evalArea;
private final Function<IPoint, Double> eval;
private final double threashold;
......@@ -68,7 +72,7 @@ public class NelderMead2D {
logger.warn("max iteration reached!");
}
//logger.info("iterations: " + overallIterations);
logger.debug("iterations: " + overallIterations);
}
public VPoint getArg() {
......
......@@ -24,6 +24,7 @@ public class Simplex1D {
private double distance;
private static final double TINY = 1.0E-10;
private final VCircle circle;
private final double MAX_VAL = 1000;
public Simplex1D(@NotNull final Function<IPoint,Double> eval, @NotNull final double rad1, final double rad2, @NotNull final VCircle circle) {
......@@ -93,6 +94,11 @@ public class Simplex1D {
}
public boolean hasConverged(final double threashold) {
if(values[0] >= MAX_VAL || values[1] >= MAX_VAL
|| values[0] <= 0){
}
if(changed) {
sqrtMean = sqrtMean();
distance = getDistance();
......
......@@ -105,7 +105,8 @@ public class Simplex2D {
}
public boolean hasConverged(final double threashold) {
if(values[0] >= MAX_VAL && values[1] >= MAX_VAL && values[2] >= MAX_VAL) {
if((values[0] >= MAX_VAL || values[1] >= MAX_VAL || values[2] >= MAX_VAL)
|| values[0] <= 0) {
//logger.warn("illegal initial simplex");
// abort!
return true;
......
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