void OLCSprint::UpdateTrace(bool force) { /* since this is online, all solutions must have start to end of trace satisfy the finish altitude requirements. otherwise there is no point even retrieving the full trace or starting a search. */ /* assuming a bounded ceiling and very long flight, this would be expected to reduce the number of trace acquisitions and solution starts by 50%. In practice the number will be lower than this but the fewer wasted cpu cycles the better. */ if (trace_master.size() < 2) { ClearTrace(); return; } const TracePoint &first = trace_master.front(); const TracePoint &last = trace_master.back(); if (!IsFinishAltitudeValid(first, last)) { ClearTrace(); return; } ContestDijkstra::UpdateTrace(force); }
bool ContestDijkstra::admit_candidate(const ScanTaskPoint &candidate) const { if (!is_final(candidate)) return true; else return IsFinishAltitudeValid(solution[0], GetPointFast(candidate)); }
SolverResult OLCLeague::Solve(bool exhaustive) { if (trace.size() < 2) return SolverResult::FAILED; const TracePoint &first = trace.front(); const TracePoint &last = trace.back(); if (!IsFinishAltitudeValid(first, last)) return SolverResult::FAILED; // solution found, so set start/finish points solution[0] = first; solution[4] = last; // scan through classic solution to find points there to add unsigned index_fill = 1; for (unsigned index_classic = 1; index_classic + 1 < solution_classic.size(); ++index_classic) { if (solution_classic[index_classic].IsNewerThan(solution[index_fill - 1]) && solution_classic[index_classic].IsOlderThan(last)) { solution[index_fill] = solution_classic[index_classic]; index_fill++; if (index_fill == 4) break; } } // if insufficient points found, add repeats of previous points for (; index_fill < 4; ++index_fill) solution[index_fill] = solution[index_fill - 1]; SaveSolution(); return SolverResult::VALID; }