Edited JavaDoc.

This commit is contained in:
Nick Klose
2014-02-10 15:31:38 +01:00
parent 2b0fb022e9
commit 4a059ca753
5 changed files with 49 additions and 47 deletions
@@ -44,15 +44,14 @@ public abstract class AbstractMarkPassingTest extends OnlineTracTracBasedTest {
protected AbstractMarkPassingTest() throws MalformedURLException, URISyntaxException {
super();
className = getClass().getName();
fileName = getFileName();
eventName = getExpectedEventName();
simpleName = getClass().getSimpleName();
}
protected abstract String getFileName();
protected static String fileName;
protected static String className;
protected static String eventName;
protected static String simpleName;
private static List<Double> accuracys = new ArrayList<>();
@@ -265,14 +264,15 @@ public abstract class AbstractMarkPassingTest extends OnlineTracTracBasedTest {
}
@AfterClass
public static void createXML() {
public static void createXML() throws IOException {
double result = 0;
for(Double d : accuracys){
result += d;
}
result /= accuracys.size();
MeasurementXMLFile performanceReport = new MeasurementXMLFile("TEST-"+fileName+"Test.xml", "MarkPassingTest", className);
MeasurementCase performanceReportCase = performanceReport.addCase(eventName+" accuracy");
performanceReportCase.addMeasurement(new Measurement(eventName+" accuracy", result));
MeasurementXMLFile performanceReport = new MeasurementXMLFile("TEST-"+simpleName+".xml", simpleName, className);
MeasurementCase performanceReportCase = performanceReport.addCase(simpleName+" accuracy");
performanceReportCase.addMeasurement(new Measurement(simpleName+" accuracy", result));
performanceReport.write();
}
}
@@ -9,8 +9,8 @@ import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.tracking.MarkPassing;
/**
* Takes the CandidateDeltas from a {@link AbstractCandidateFinder} and calculates the most likely sequence of
* MarkPassings. The race should then be notified about these new MarkPassings.
* Takes the {@link Candidate}s from an {@link AbstractCandidateFinder} and calculates any new {@link MarkPassing}s. The
* race should then be notified about these new MarkPassings.
*
* @author Nicolas Klose
*
@@ -10,11 +10,11 @@ import com.sap.sailing.domain.tracking.GPSFix;
/**
* A CandidateFinder converts the incoming GPSFixes of competitors and marks into {@link Candidate}s for each
* competitor. With new Fixes of an Object one can call the
* {@link #calculateFixesAffectedByNewCompetitorFixes(Competitor, List)} or the
* {@link #calculateFixesAffectedByNewMarkFixes(Mark, List)} methods. This determines those fixes that may have changed
* their status as a {@link Candidate}. {@link #getCandidateDeltas(Competitor)} then returns the actual changes to the
* list of Candidates as a Pair of Lists, one of the new Candidates and one of the Candidates that should be removed.
* competitor. {@link #calculateFixesAffectedByNewMarkFixes(Mark, List)} determines the fixes that may have changed
* their status as {@link Candidate} after new fixes for a mark arrive. This determines those fixes that may have
* changed their status as a {@link Candidate}. {@link #getCandidateDeltas(Competitor, Iterable)} then returns the
* actual changes to the list of Candidates as a Pair of Lists, one of the new Candidates and one of the Candidates that
* should be removed.
*
* @author Nicolas Klose
*
@@ -33,7 +33,6 @@ public interface AbstractCandidateFinder {
*/
Pair<List<Candidate>, List<Candidate>> getCandidateDeltas(Competitor c, Iterable<GPSFix> fixes);
/**
* When initializing the calculator, the whole race until now is evaluated. For that purpose all of the Candidates
* are needed instead of just the deltas.
@@ -23,11 +23,10 @@ import com.sap.sailing.domain.tracking.TrackedLeg;
import com.sap.sailing.domain.tracking.impl.MarkPassingImpl;
/**
* The standard implementation of {@link AbstractCandidateChooser}. First two proxy-candidates are created, It makes
* creates {@link Edge}s out of the {@link Candidate}s for each competitor, creating a DAG. The shortest path from A
* shortest path-algorithm is then used to find the most likely sequence of {@link MarkPassing}s. An estimation of the
* time between two {@link Candidate}s and the distance between their {@link Waypoint}s is used to further increase the
* edges correctness.
* The standard implementation of {@link AbstractCandidateChooser}. A graph is created, with each {@link Candidate} as a
* vertices between two proxy Candidates, <code>start</code> and <code>end</code>. The probability of an {@link Edge} is
* equal to the probability of the two Candidates plus and estimation of the distance traveled between the them. A
* shortest path-algorithm is then used to find the most likely sequence of {@link MarkPassing}s.
*
* @author Nicolas Klose
*
@@ -44,7 +43,7 @@ public class CandidateChooser implements AbstractCandidateChooser {
private Candidate end;
private final DynamicTrackedRace race;
private final double penaltyForSkipping = 1 - Edge.getPenaltyForSkipping();
private static double strictness = 1000;
private static double strictness = 1000; // Lower = stricter
public CandidateChooser(DynamicTrackedRace race) {
logger.setLevel(Level.INFO);
@@ -13,7 +13,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.Leg;
import com.sap.sailing.domain.base.Mark;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.common.Bearing;
@@ -27,9 +26,10 @@ import com.sap.sailing.domain.tracking.GPSFix;
import com.sap.sailing.domain.tracking.LineDetails;
/**
* The standard implemantation of {@link AbstractCandidateFinder}. The fixes are evaluated for their distance to each
* Waypoint. Every local minimum is a Candidate, and its probability depends on its ratio to the average lengths of the
* {@link Leg}s before and after it.
* The standard implemantation of {@link AbstractCandidateFinder}. There are two ways {@link Candidate}s can be created.
* First of all, all local distance minima to a waypoint are a candidate. Secondly, every time a competitor passes the
* crossing Bearing of a Waypoint a Candidate is created through linear interpolation. The probability of a Candidate
* depends on its distance to the waypoint, whether it is on the right side and if it passes in the right direction.
*
* @author Nicolas Klose
*
@@ -52,6 +52,8 @@ public class CandidateFinder implements AbstractCandidateFinder {
}
};
private double strictness = 20; // Higher = stricter
// TODO Identical Waypoints (ControlPoint and PassingInstruction) are calculated twice.
// => Distance to Mark instead of Waypoint?
@@ -65,30 +67,32 @@ public class CandidateFinder implements AbstractCandidateFinder {
for (Waypoint w : race.getRace().getCourse().getWaypoints()) {
cteCandidates.get(c).put(w, new LinkedHashMap<List<GPSFix>, Candidate>());
distanceCandidates.get(c).put(w, new LinkedHashMap<GPSFix, Candidate>());
PassingInstruction instruction = w.getPassingInstructions();
if (instruction == PassingInstruction.None || instruction == null) {
if (w.equals(race.getRace().getCourse().getFirstWaypoint()) || w.equals(race.getRace().getCourse().getLastWaypoint())) {
instruction = PassingInstruction.Line;
}
}
for (Waypoint w : race.getRace().getCourse().getWaypoints()) {
PassingInstruction instruction = w.getPassingInstructions();
if (instruction == PassingInstruction.None || instruction == null) {
if (w.equals(race.getRace().getCourse().getFirstWaypoint()) || w.equals(race.getRace().getCourse().getLastWaypoint())) {
instruction = PassingInstruction.Line;
} else {
int numberofMarks = 0;
Iterator<Mark> it = w.getMarks().iterator();
while (it.hasNext()) {
it.next();
numberofMarks++;
}
if (numberofMarks == 2) {
instruction = PassingInstruction.Gate;
} else if (numberofMarks == 1) {
instruction = PassingInstruction.Port;
} else {
int numberofMarks = 0;
Iterator<Mark> it = w.getMarks().iterator();
while (it.hasNext()) {
it.next();
numberofMarks++;
}
if (numberofMarks == 2) {
instruction = PassingInstruction.Gate;
} else if (numberofMarks == 1) {
instruction = PassingInstruction.Port;
} else {
instruction = PassingInstruction.None;
}
instruction = PassingInstruction.None;
}
}
passingInstructions.put(w, instruction);
}
Edge.setNumberOfWayoints(passingInstructions.keySet().size());
passingInstructions.put(w, instruction);
}
Edge.setNumberOfWayoints(passingInstructions.keySet().size());
}
@Override
@@ -387,7 +391,7 @@ public class CandidateFinder implements AbstractCandidateFinder {
private double getDistanceLikelyhood(Waypoint w, Position p, TimePoint t) {
double distance = calculateDistance(p, w, t);
double legLength = getLegLength(t, w);
double result = 1 / (20 * Math.abs(distance / legLength) + 1);
double result = 1 / (strictness * Math.abs(distance / legLength) + 1);
// Auch NormalVerteilung??!
return result;
}
@@ -408,7 +412,7 @@ public class CandidateFinder implements AbstractCandidateFinder {
ArrayList<Position> positions = new ArrayList<>();
if (instruction == PassingInstruction.Line) {
boolean isStart = (race.getRace().getCourse().getFirstWaypoint() == w);
LineDetails line = isStart? race.getStartLine(t) : race.getFinishLine(t);
LineDetails line = isStart ? race.getStartLine(t) : race.getFinishLine(t);
positions.add(0, race.getOrCreateTrack(line.getPortMarkWhileApproachingLine()).getEstimatedPosition(t, true));
positions.add(1, race.getOrCreateTrack(line.getStarboardMarkWhileApproachingLine()).getEstimatedPosition(t, true));
} else {