mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 13:45:42 +00:00
do not show 1-turners on reaching legs; skip superfluous steps in finishing 1-turner;
This commit is contained in:
+49
-21
@@ -424,11 +424,15 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
executor.execute(taskOmniscient);
|
||||
}
|
||||
|
||||
// schedule 1-turner tasks
|
||||
FutureTask<Path> task1TurnerLeft = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_LEFT));
|
||||
FutureTask<Path> task1TurnerRight = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_RIGHT));
|
||||
executor.execute(task1TurnerLeft);
|
||||
executor.execute(task1TurnerRight);
|
||||
FutureTask<Path> task1TurnerLeft = null;
|
||||
FutureTask<Path> task1TurnerRight = null;
|
||||
if (simulationParameters.getLegType() != LegType.REACHING) {
|
||||
// schedule 1-turner tasks
|
||||
task1TurnerLeft = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_LEFT));
|
||||
task1TurnerRight = new FutureTask<Path>(() -> simulator.getPath(PathType.ONE_TURNER_RIGHT));
|
||||
executor.execute(task1TurnerLeft);
|
||||
executor.execute(task1TurnerRight);
|
||||
}
|
||||
|
||||
FutureTask<Path> taskOpportunistLeft = null;
|
||||
FutureTask<Path> taskOpportunistRight = null;
|
||||
@@ -440,22 +444,32 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
executor.execute(taskOpportunistRight);
|
||||
}
|
||||
|
||||
// collect 1-turner results
|
||||
Path path1TurnerLeft = task1TurnerLeft.get();
|
||||
result.put(PathType.ONE_TURNER_LEFT, path1TurnerLeft);
|
||||
Path path1TurnerRight = task1TurnerRight.get();
|
||||
result.put(PathType.ONE_TURNER_RIGHT, path1TurnerRight);
|
||||
|
||||
Path path1TurnerLeft = null;
|
||||
Path path1TurnerRight = null;
|
||||
if (simulationParameters.getLegType() != LegType.REACHING) {
|
||||
// collect 1-turner results
|
||||
path1TurnerLeft = task1TurnerLeft.get();
|
||||
result.put(PathType.ONE_TURNER_LEFT, path1TurnerLeft);
|
||||
path1TurnerRight = task1TurnerRight.get();
|
||||
result.put(PathType.ONE_TURNER_RIGHT, path1TurnerRight);
|
||||
}
|
||||
|
||||
Path pathOpportunistLeft = null;
|
||||
Path pathOpportunistRight = null;
|
||||
if (simulationParameters.showOpportunist()) {
|
||||
// collect opportunist results
|
||||
Path pathOpportunistLeft = taskOpportunistLeft.get();
|
||||
if (!path1TurnerLeft.getAlgorithmTimedOut() && (pathOpportunistLeft.getTurnCount() == 1)) {
|
||||
pathOpportunistLeft = path1TurnerLeft;
|
||||
pathOpportunistLeft = taskOpportunistLeft.get();
|
||||
if (path1TurnerLeft != null) {
|
||||
if (!path1TurnerLeft.getAlgorithmTimedOut() && (pathOpportunistLeft.getTurnCount() == 1)) {
|
||||
pathOpportunistLeft = path1TurnerLeft;
|
||||
}
|
||||
}
|
||||
result.put(PathType.OPPORTUNIST_LEFT, pathOpportunistLeft);
|
||||
Path pathOpportunistRight = taskOpportunistRight.get();
|
||||
if (!path1TurnerRight.getAlgorithmTimedOut() && (pathOpportunistRight.getTurnCount() == 1)) {
|
||||
pathOpportunistRight = path1TurnerRight;
|
||||
pathOpportunistRight = taskOpportunistRight.get();
|
||||
if (path1TurnerRight != null) {
|
||||
if (!path1TurnerRight.getAlgorithmTimedOut() && (pathOpportunistRight.getTurnCount() == 1)) {
|
||||
pathOpportunistRight = path1TurnerRight;
|
||||
}
|
||||
}
|
||||
result.put(PathType.OPPORTUNIST_RIGHT, pathOpportunistRight);
|
||||
}
|
||||
@@ -463,11 +477,25 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
if (simulationParameters.showOmniscient()) {
|
||||
// collect omniscient result (last, since usually slowest calculation)
|
||||
Path pathOmniscient = taskOmniscient.get();
|
||||
if (!path1TurnerLeft.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(path1TurnerLeft.getFinalTime()))) {
|
||||
pathOmniscient = path1TurnerLeft;
|
||||
if (path1TurnerLeft != null) {
|
||||
if (!path1TurnerLeft.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(path1TurnerLeft.getFinalTime()))) {
|
||||
pathOmniscient = path1TurnerLeft;
|
||||
}
|
||||
}
|
||||
if (!path1TurnerRight.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(path1TurnerRight.getFinalTime()))) {
|
||||
pathOmniscient = path1TurnerRight;
|
||||
if (path1TurnerRight != null) {
|
||||
if (!path1TurnerRight.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(path1TurnerRight.getFinalTime()))) {
|
||||
pathOmniscient = path1TurnerRight;
|
||||
}
|
||||
}
|
||||
if (pathOpportunistLeft != null) {
|
||||
if (!pathOpportunistLeft.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(pathOpportunistLeft.getFinalTime()))) {
|
||||
pathOmniscient = pathOpportunistLeft;
|
||||
}
|
||||
}
|
||||
if (pathOpportunistRight != null) {
|
||||
if (!pathOpportunistRight.getAlgorithmTimedOut() && (pathOmniscient.getFinalTime().after(pathOpportunistRight.getFinalTime()))) {
|
||||
pathOmniscient = pathOpportunistRight;
|
||||
}
|
||||
}
|
||||
result.put(PathType.OMNISCIENT, pathOmniscient);
|
||||
}
|
||||
|
||||
+10
-2
@@ -109,6 +109,7 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
stepMax = this.evalStepMax;
|
||||
}
|
||||
boolean targetFound;
|
||||
boolean skipRemainingSteps;
|
||||
long timeStep;
|
||||
if (this.evalTimeStep == 0) {
|
||||
timeStep = windField.getTimeStep().asMillis() / 3;
|
||||
@@ -128,6 +129,7 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
currentPosition = posStart;
|
||||
currentTime = startTime;
|
||||
targetFound = false;
|
||||
skipRemainingSteps = false;
|
||||
minimumDistance = courseLength.getMeters();
|
||||
path = new LinkedList<TimedPositionWithSpeed>();
|
||||
path.addLast(new TimedPositionWithSpeedImpl(currentTime, currentPosition, null));
|
||||
@@ -138,7 +140,7 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
|
||||
int stepLeft = 0;
|
||||
PointOfSail prevPointOfSail = PointOfSail.TACKING;
|
||||
while ((stepLeft < step) && (!targetFound) && (!this.isTimedOut())) {
|
||||
while ((stepLeft < step) && (!targetFound) && (!this.isTimedOut()) && (!skipRemainingSteps)) {
|
||||
// get bearing to target
|
||||
Bearing bearTarget = currentPosition.getBearingGreatCircle(posEnd);
|
||||
// set wind at current position
|
||||
@@ -212,6 +214,9 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
minimumTime = currentTime;
|
||||
allminpath = path;
|
||||
}
|
||||
if (posStart.getDistance(currentPosition).getMeters() > 1.1*posStart.getDistance(posEnd).getMeters()) {
|
||||
skipRemainingSteps = true;
|
||||
}
|
||||
stepLeft++;
|
||||
}
|
||||
|
||||
@@ -220,7 +225,7 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
}
|
||||
|
||||
int stepRight = 0;
|
||||
while ((stepRight < (stepMax - step)) && (!targetFound) && (!this.isTimedOut())) {
|
||||
while ((stepRight < (stepMax - step)) && (!targetFound) && (!this.isTimedOut()) && (!skipRemainingSteps)) {
|
||||
// get bearing to target
|
||||
Bearing bearTarget = currentPosition.getBearingGreatCircle(posEnd);
|
||||
// set wind at current position
|
||||
@@ -271,6 +276,9 @@ public class PathGenerator1Turner360 extends PathGeneratorBase {
|
||||
minimumTime = currentTime;
|
||||
allminpath = new LinkedList<TimedPositionWithSpeed>(path);
|
||||
}
|
||||
if (posStart.getDistance(currentPosition).getMeters() > 1.1*posStart.getDistance(posEnd).getMeters()) {
|
||||
skipRemainingSteps = true;
|
||||
}
|
||||
stepRight++;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -47,7 +47,10 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
}
|
||||
|
||||
public boolean isSameBaseDirection(BoatDirection direction1, BoatDirection direction2) {
|
||||
return (isBaseDirectionLeft(direction1)&&isBaseDirectionLeft(direction2))||(isBaseDirectionRight(direction1)&&isBaseDirectionRight(direction2));
|
||||
boolean result = isBaseDirectionLeft(direction1)&&isBaseDirectionLeft(direction2);
|
||||
result |= isBaseDirectionRight(direction1)&&isBaseDirectionRight(direction2);
|
||||
result |= (direction1 == BoatDirection.NONE) || (direction2 == BoatDirection.NONE);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isBaseDirectionLeft(BoatDirection direction) {
|
||||
@@ -339,11 +342,11 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
}
|
||||
|
||||
long finishTimeStep = Math.max(500, timeStep / 10);
|
||||
int finishStepsLeft = (int) Math.round(1.5*(path.get(path.size()-1).getTimePoint().asMillis() - path.get(0).getTimePoint().asMillis()) / (1-fracFinishPhase) * fracFinishPhase / finishTimeStep);
|
||||
int finishStepsLeft = (int) Math.round(5*(path.get(path.size()-1).getTimePoint().asMillis() - path.get(0).getTimePoint().asMillis()) / (1-fracFinishPhase) * fracFinishPhase / finishTimeStep);
|
||||
generator1Turner.setEvaluationParameters(true, currentPosition, endPos, leftTurningTime, finishTimeStep, finishStepsLeft, 0.2, this.upwindLeg);
|
||||
Path leftPath = generator1Turner.getPath();
|
||||
|
||||
int finishStepsRight = (int) Math.round(1.5*(path.get(path.size()-1).getTimePoint().asMillis() - path.get(0).getTimePoint().asMillis()) / (1-fracFinishPhase) * fracFinishPhase / finishTimeStep);
|
||||
int finishStepsRight = (int) Math.round(5*(path.get(path.size()-1).getTimePoint().asMillis() - path.get(0).getTimePoint().asMillis()) / (1-fracFinishPhase) * fracFinishPhase / finishTimeStep);
|
||||
generator1Turner.setEvaluationParameters(false, currentPosition, endPos, rightTurningTime, finishTimeStep, finishStepsRight, 0.2, this.upwindLeg);
|
||||
Path rightPath = generator1Turner.getPath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user