mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
trying to make MarkPassingCalculator serializable as a first patch for bug 3604; consistent serialization will be a problem
Change-Id: I9051b67e6d15833cec622cca026816dbf65e22f0
This commit is contained in:
1 parent
4286c9a924
commit
7e7b79f10a
12 files changed
+30
-12
No files matched your search
+2
@@ -21,6 +21,8 @@ import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
|
||||
public class CandidateFinderImplWhiteBoxTest {
|
||||
private static class CandidateFinderWithPublicGetProbabilityOfStartBasedOnOtherCompetitorsStartLineDistances extends CandidateFinderImpl {
|
||||
private static final long serialVersionUID = 5472855431045667537L;
|
||||
|
||||
public CandidateFinderWithPublicGetProbabilityOfStartBasedOnOtherCompetitorsStartLineDistances(
|
||||
DynamicTrackedRace race) {
|
||||
super(race);
|
||||
|
||||
+5
-2
@@ -1,9 +1,12 @@
|
||||
package com.sap.sailing.domain.markpassingcalculation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sailing.domain.markpassingcalculation.impl.CandidateChooserImpl;
|
||||
import com.sap.sailing.domain.markpassingcalculation.impl.CandidateImpl;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
/**
|
||||
* Represent the possible {@link MarkPassing} of a {@link Waypoint}. It contains the {@link Waypoint} it might be passing, a
|
||||
@@ -15,7 +18,7 @@ import com.sap.sailing.domain.markpassingcalculation.impl.CandidateImpl;
|
||||
* @author Nicolas Klose
|
||||
*
|
||||
*/
|
||||
public interface Candidate extends Comparable<CandidateImpl> {
|
||||
public interface Candidate extends Comparable<CandidateImpl>, Serializable {
|
||||
|
||||
Waypoint getWaypoint();
|
||||
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.domain.markpassingcalculation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.markpassingcalculation.impl.CandidateImpl;
|
||||
@@ -7,7 +9,7 @@ import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public interface CandidateChooser {
|
||||
public interface CandidateChooser extends Serializable {
|
||||
/**
|
||||
* Calculates any new {@link MarkPassing}s and notifies the {@link DynamicTrackedRace}.
|
||||
*
|
||||
|
||||
+2
-7
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.markpassingcalculation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,10 +15,7 @@ import com.sap.sse.common.Util;
|
||||
*
|
||||
* @author Nicolas Klose
|
||||
*/
|
||||
public interface CandidateFinder {
|
||||
|
||||
|
||||
|
||||
public interface CandidateFinder extends Serializable {
|
||||
/**
|
||||
* @param fixes
|
||||
* Either new fixes or fixes that may have changed their status, e.g. as a result of new mark
|
||||
@@ -26,8 +24,6 @@ public interface CandidateFinder {
|
||||
*/
|
||||
Util.Pair<Iterable<Candidate>, Iterable<Candidate>> getCandidateDeltas(Competitor c, Iterable<GPSFix> fixes);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* When initializing or refreshing the calculator, the whole race until now is evaluated. For that purpose all of the
|
||||
* {@link Candidate}s are needed instead of just the deltas.
|
||||
@@ -41,5 +37,4 @@ public interface CandidateFinder {
|
||||
* mark fixes..
|
||||
*/
|
||||
Map<Competitor, List<GPSFix>> calculateFixesAffectedByNewMarkFixes(Map<Mark, List<GPSFix>> newMarkFixes);
|
||||
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.markpassingcalculation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -44,7 +45,8 @@ import com.sap.sse.util.impl.ThreadFactoryWithPriority;
|
||||
* @author Nicolas Klose
|
||||
*
|
||||
*/
|
||||
public class MarkPassingCalculator {
|
||||
public class MarkPassingCalculator implements Serializable {
|
||||
private static final long serialVersionUID = 3591923238312601323L;
|
||||
private final DynamicTrackedRace race;
|
||||
private CandidateFinder finder;
|
||||
private CandidateChooser chooser;
|
||||
|
||||
+4
@@ -48,6 +48,8 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
*
|
||||
*/
|
||||
public class CandidateChooserImpl implements CandidateChooser {
|
||||
private static final long serialVersionUID = -7320365019575417771L;
|
||||
|
||||
/**
|
||||
* Earlier finish mark passings are to be preferred over later ones if they otherwise seem equally likely. While the
|
||||
* {@link #getProbabilityOfActualDistanceGivenGreatCircleDistance(Distance, Distance, double)} method should usually
|
||||
@@ -562,6 +564,7 @@ public class CandidateChooserImpl implements CandidateChooser {
|
||||
}
|
||||
|
||||
private class CandidateWithSettableTime extends CandidateImpl {
|
||||
private static final long serialVersionUID = -1792983349299883266L;
|
||||
private TimePoint variableTimePoint;
|
||||
|
||||
public CandidateWithSettableTime(int oneBasedIndexOfWaypoint, TimePoint p, double distanceProbability, Waypoint w) {
|
||||
@@ -580,6 +583,7 @@ public class CandidateChooserImpl implements CandidateChooser {
|
||||
}
|
||||
|
||||
private class CandidateWithSettableWaypointIndex extends CandidateImpl {
|
||||
private static final long serialVersionUID = 5868551535609781722L;
|
||||
private int variableOneBasedWaypointIndex;
|
||||
|
||||
public CandidateWithSettableWaypointIndex(int oneBasedIndexOfWaypoint, TimePoint p, double distanceProbability, Waypoint w) {
|
||||
|
||||
+6
-1
@@ -49,6 +49,7 @@ import com.sap.sse.common.Util.Pair;
|
||||
*
|
||||
*/
|
||||
public class CandidateFinderImpl implements CandidateFinder {
|
||||
private static final long serialVersionUID = -9010874944932370189L;
|
||||
|
||||
// The higher this is, the closer the fixes have to be to waypoint to become a Candidate
|
||||
private final int STRICTNESS_OF_DISTANCE_BASED_PROBABILITY = 7;
|
||||
@@ -960,7 +961,11 @@ public class CandidateFinderImpl implements CandidateFinder {
|
||||
result = 1;
|
||||
} else {
|
||||
//TODO There should be a constant (either the 1.5 or the -0.2) which controls how strict the the curve is.
|
||||
result = (1-PENALTY_FOR_WRONG_SIDE) * Math.pow(1.5, -0.2 * onWrongSide.getMeters()) + PENALTY_FOR_WRONG_SIDE;
|
||||
result = Math.min(1.0, (1-PENALTY_FOR_WRONG_SIDE) *
|
||||
// consider the possibility that both, mark and boat could have been GPSFix.TYPICAL_HDOP off and
|
||||
// only start penalizing beyond this distance
|
||||
Math.pow(1.5, -0.2 * onWrongSide.add(GPSFix.TYPICAL_HDOP.scale(-2.0)).getMeters())
|
||||
+ PENALTY_FOR_WRONG_SIDE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import com.sap.sailing.domain.markpassingcalculation.Candidate;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public class CandidateImpl implements Candidate {
|
||||
private static final long serialVersionUID = -4626280455738918911L;
|
||||
private final Waypoint w;
|
||||
private final TimePoint p;
|
||||
private final double probability;
|
||||
|
||||
+1
@@ -4,6 +4,7 @@ import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public abstract class CandidateWithSide extends CandidateImpl {
|
||||
private static final long serialVersionUID = -1670977291984975178L;
|
||||
private final double onCorrectSideOfWaypoint;
|
||||
private final Double startProbabilityBasedOnOtherCompetitors;
|
||||
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public class DistanceCandidateImpl extends CandidateWithSide {
|
||||
private static final long serialVersionUID = -9125694086262205898L;
|
||||
private final Distance distance;
|
||||
|
||||
public DistanceCandidateImpl(int oneBasedIndexOfWaypoint, TimePoint p, double probability, Double startProbabilityBasedOnOtherCompetitors,
|
||||
|
||||
+1
@@ -4,6 +4,7 @@ import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public class XTECandidateImpl extends CandidateWithSide {
|
||||
private static final long serialVersionUID = 700807010904741849L;
|
||||
private final Double passesInTheRightDirectionProbability;
|
||||
|
||||
public XTECandidateImpl(int oneBasedIndexOfWaypoint, TimePoint p, double probability,
|
||||
|
||||
@@ -18,6 +18,7 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
||||
# Overwrite the log leves for specific loggers here
|
||||
com.sap.sailing.level = FINE
|
||||
com.sap.sse.level = FINE
|
||||
com.sap.sailing.domain.markpassingcalculation.level = FINEST
|
||||
# log at level FINEST for TransientCompetitorStoreIMpl
|
||||
#com.sap.sailing.domain.base.impl.TransientCompetitorStoreImpl.level = FINEST
|
||||
#com.sap.sailing.domain.base.impl.SharedDomainFactoryImpl.level = FINEST
|
||||
|
||||
Reference in new issue
Block a user