mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 23:00:59 +00:00
handle sparse-simulation-data-exception; further improvement for finish-phase of opportunist-360;
This commit is contained in:
1 parent
43f1c7eeb9
commit
bbebd762d6
3 files changed
+61
-30
No files matched your search
+1
-1
@@ -11,7 +11,7 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
public class PathGeneratorBase implements PathGenerator {
|
||||
|
||||
protected SimulationParameters parameters;
|
||||
protected final Duration algorithmMaxDuration = new MillisecondsDurationImpl(2*60*1000); // 2 minutes maximum duration of one path generation
|
||||
protected final Duration algorithmMaxDuration = new MillisecondsDurationImpl(20000); // 20 seconds maximum duration of one path generation
|
||||
protected TimePoint algorithmStartTime;
|
||||
protected boolean algorithmTimedOut = false;
|
||||
|
||||
|
||||
+26
-3
@@ -78,6 +78,7 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
double currentHeight = startPos.getDistance(endPos).getMeters();
|
||||
|
||||
BoatDirection prevDirection = BoatDirection.NONE;
|
||||
BoatDirection prevPrevDirection = BoatDirection.NONE;
|
||||
long turnLoss = polarDiagram.getTurnLoss(); // time lost when doing a turn
|
||||
double fracFinishPhase = 0.05;
|
||||
|
||||
@@ -199,9 +200,10 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
Distance targetDistanceRight = nextBoatPositionRight.getDistance(endPos);
|
||||
double targetDistanceMetersLeft = Math.round(targetDistanceLeft.getMeters() * 1000.) / 1000.;
|
||||
double targetDistanceMetersRight = Math.round(targetDistanceRight.getMeters() * 1000.) / 1000.;
|
||||
|
||||
prevPrevDirection = prevDirection;
|
||||
|
||||
if (prevDirection == BoatDirection.NONE) {
|
||||
|
||||
|
||||
if (startLeft) {
|
||||
if (pointOfSail == PointOfSail.TACKING) {
|
||||
path.add(new TimedPositionWithSpeedImpl(nextTime, nextBoatPositionLeft, currentWind));
|
||||
@@ -287,6 +289,7 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
turns++;
|
||||
}
|
||||
|
||||
prevPrevDirection = prevDirection;
|
||||
prevDirection = reachingSide;
|
||||
if (reachingSide == BoatDirection.REACH_LEFT) {
|
||||
pathStr += "D";
|
||||
@@ -299,7 +302,27 @@ public class PathGeneratorOpportunistEuclidian360 extends PathGeneratorBase {
|
||||
Position posHeight = currentPosition.projectToLineThrough(startPos, bearStart);
|
||||
currentHeight = startPos.getDistance(endPos).getMeters() - posHeight.getDistance(startPos).getMeters();
|
||||
}
|
||||
|
||||
|
||||
// remove last position, if already too close to target for finish-phase
|
||||
if (currentHeight < startPos.getDistance(endPos).getMeters()*fracFinishPhase/2) {
|
||||
path.remove(path.size()-1);
|
||||
currentTime = path.get(path.size()-1).getTimePoint();
|
||||
currentPosition = path.get(path.size()-1).getPosition();
|
||||
prevDirection = prevPrevDirection;
|
||||
} else {
|
||||
// get bearing to target
|
||||
Bearing nextBearTarget = currentPosition.getBearingGreatCircle(endPos);
|
||||
// get point-of-sail and reaching-side
|
||||
Pair<PointOfSail, BoatDirection> nextPointOfSailAndReachingSide = polarDiagram.getPointOfSail(nextBearTarget);
|
||||
PointOfSail nextPointOfSail = nextPointOfSailAndReachingSide.getA();
|
||||
if (nextPointOfSail == PointOfSail.REACHING) {
|
||||
path.remove(path.size()-1);
|
||||
currentTime = path.get(path.size()-1).getTimePoint();
|
||||
currentPosition = path.get(path.size()-1).getPosition();
|
||||
prevDirection = prevPrevDirection;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isTimedOut()) {
|
||||
//
|
||||
// FinishPhase: get 1-turners to finalize course
|
||||
|
||||
+34
-26
@@ -10,6 +10,7 @@ import com.sap.sailing.simulator.RaceProperties;
|
||||
import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.Simulator;
|
||||
import com.sap.sailing.simulator.SimulatorUISelection;
|
||||
import com.sap.sailing.simulator.TimedPositionWithSpeed;
|
||||
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
|
||||
|
||||
public class SimulatorImpl implements Simulator {
|
||||
@@ -44,32 +45,39 @@ public class SimulatorImpl implements Simulator {
|
||||
PathGeneratorTreeGrow360 genTreeGrow;
|
||||
PathGeneratorOpportunistEuclidian360 genOpportunistic;
|
||||
Path path = null;
|
||||
switch (pathType) {
|
||||
case OMNISCIENT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters(null, 0, null); // allow for arbitrary many turns
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_LEFT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("L", 1, null); // start left and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_RIGHT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("R", 1, null); // start right and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_LEFT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian360(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(true); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_RIGHT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian360(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(false); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
try {
|
||||
switch (pathType) {
|
||||
case OMNISCIENT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters(null, 0, null); // allow for arbitrary many turns
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_LEFT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("L", 1, null); // start left and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case ONE_TURNER_RIGHT:
|
||||
genTreeGrow = new PathGeneratorTreeGrow360(this.simulationParameters); // instantiate heuristic searcher
|
||||
genTreeGrow.setEvaluationParameters("R", 1, null); // start right and limit to one turn
|
||||
path = genTreeGrow.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_LEFT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian360(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(true); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
case OPPORTUNIST_RIGHT:
|
||||
genOpportunistic = new PathGeneratorOpportunistEuclidian360(this.simulationParameters); // instantiate greedy searcher
|
||||
genOpportunistic.setEvaluationParameters(false); // use maxTurnTimes of 1-turners to avoid passing of lay lines
|
||||
path = genOpportunistic.getPath();
|
||||
break;
|
||||
}
|
||||
} catch (SparseSimulationDataException e) {
|
||||
LOGGER.warning(e.getMessage() + "(PathType: " + pathType.getTxtId() + ")");
|
||||
List<TimedPositionWithSpeed> points = new ArrayList<TimedPositionWithSpeed>();
|
||||
points.add(new TimedPositionWithSpeedImpl(this.simulationParameters.getWindField().getStartTime(), this.simulationParameters.getCourse().get(0), null));
|
||||
path = new PathImpl(points, null, 0, true, false);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user