mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 06:18:12 +00:00
Added interpolation between centers of angle clusters
This commit is contained in:
1 parent
d0c00bf515
commit
fb56f225b3
3 files changed
+21
-12
No files matched your search
+1
-1
@@ -60,7 +60,7 @@ public class AngleAndSpeedRegression {
|
||||
}
|
||||
if (angleFound) {
|
||||
result.add(new SpeedWithBearingWithConfidenceImpl<Void>(new KnotSpeedWithBearingImpl(
|
||||
windSpeedCandidateInKnots, new DegreeBearingImpl(angle)), 0.00001, null));
|
||||
windSpeedCandidateInKnots, new DegreeBearingImpl(angle)), 0.5 /*FIXME*/, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +183,10 @@ public class PolarDataMiner {
|
||||
private Set<SpeedWithBearingWithConfidence<Void>> getAverageTrueWindSpeedAndAngleCandidatesWithFallbackFunction(BoatClass boatClass,
|
||||
Speed speedOverGround, LegType legType, Tack tack) {
|
||||
|
||||
// The following is an estimation function. It only serves as a stub. It's the same for all boatclasses and returns
|
||||
// default maneuver angles. This is NOT final.
|
||||
// The following is an estimation function. It only serves as a fallback. It's the same for all boatclasses and returns
|
||||
// default maneuver angles.
|
||||
// The function is able to return boat speed values for windspeed alues between 5kn and 25kn , which are some kind of realistic
|
||||
// for sailing boats. They are taken from the 505 polars we gathered in the races until now.
|
||||
// TODO keep a cache of sampling points over which to fit a function for every boat class and then return the
|
||||
// corresponding angle
|
||||
|
||||
Set<SpeedWithBearingWithConfidence<Void>> resultSet = new HashSet<>();
|
||||
final int tackFactor = (tack.equals(Tack.PORT)) ? -1 : 1;
|
||||
|
||||
+18
-7
@@ -9,6 +9,7 @@ import com.sap.sailing.domain.base.SpeedWithConfidence;
|
||||
import com.sap.sailing.domain.base.impl.SpeedWithConfidenceImpl;
|
||||
import com.sap.sailing.domain.common.Bearing;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedImpl;
|
||||
import com.sap.sailing.polars.regression.IncrementalLeastSquares;
|
||||
import com.sap.sailing.polars.regression.NotEnoughDataHasBeenAddedException;
|
||||
@@ -48,15 +49,25 @@ private static final Logger logger = Logger.getLogger(CubicRegressionPerCoursePr
|
||||
regression.addData(fix.getWindSpeed().getObject().getKnots(), fix.getBoatSpeed().getObject().getKnots());
|
||||
}
|
||||
|
||||
/**
|
||||
* There are angle clusters (size defined in the data mining pipeline construction), which each have their own
|
||||
* regression for boatspeed over windspeed.
|
||||
* We don't know the thresholds or centers of the angle clusters here, so we roughly interpolate by taking 10
|
||||
* values from angle-5 deg to angle+5 deg and average the speeds.
|
||||
*/
|
||||
public SpeedWithConfidence<Void> estimateBoatSpeed(BoatClass boatClass, Speed windSpeed, Bearing trueWindAngle) throws NotEnoughDataHasBeenAddedException {
|
||||
GroupKey key = createGroupKey(boatClass, trueWindAngle);
|
||||
double estimatedSpeed;
|
||||
if (regressions.containsKey(key)) {
|
||||
estimatedSpeed = regressions.get(key).getOrCreatePolynomialFunction().value(windSpeed.getKnots());
|
||||
} else {
|
||||
throw new NotEnoughDataHasBeenAddedException("Not enough data has been added to Per Course Regressions");
|
||||
double speedSum = 0;
|
||||
double numberOfSpeeds = 0;
|
||||
for (int i = -5; i <= 5; i++) {
|
||||
GroupKey key = createGroupKey(boatClass, new DegreeBearingImpl(trueWindAngle.getDegrees() + i));
|
||||
if (regressions.containsKey(key)) {
|
||||
speedSum += regressions.get(key).getOrCreatePolynomialFunction().value(windSpeed.getKnots());
|
||||
numberOfSpeeds++;
|
||||
} else {
|
||||
throw new NotEnoughDataHasBeenAddedException("Not enough data has been added to Per Course Regressions");
|
||||
}
|
||||
}
|
||||
Speed speed = new KnotSpeedImpl(estimatedSpeed);
|
||||
Speed speed = new KnotSpeedImpl(speedSum / numberOfSpeeds);
|
||||
return new SpeedWithConfidenceImpl<Void>(speed, /*FIXME*/ 0.5, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user