예제 #1
0
void AnalyseFlight(DebugReplay &replay,
                   const BrokenDateTime &takeoff_time,
                   const BrokenDateTime &scoring_start_time,
                   const BrokenDateTime &scoring_end_time,
                   const BrokenDateTime &landing_time,
                   ContestStatistics &olc_plus,
                   ContestStatistics &dmst,
                   PhaseList &phase_list,
                   PhaseTotals &phase_totals,
                   WindList &wind_list,
                   const unsigned full_points,
                   const unsigned triangle_points,
                   const unsigned sprint_points,
                   const unsigned max_iterations,
                   const unsigned max_tree_size)
{
    Trace full_trace(0, Trace::null_time, full_points);
    Trace triangle_trace(0, Trace::null_time, triangle_points);
    Trace sprint_trace(0, 9000, sprint_points);
    FlightPhaseDetector flight_phase_detector;

    Run(replay, flight_phase_detector, wind_list,
        takeoff_time, scoring_start_time, scoring_end_time, landing_time,
        full_trace, triangle_trace, sprint_trace);

    olc_plus = SolveContest(Contest::OLC_PLUS,
                            full_trace, triangle_trace, sprint_trace,
                            max_iterations, max_tree_size);
    dmst = SolveContest(Contest::DMST,
                        full_trace, triangle_trace, sprint_trace,
                        max_iterations, max_tree_size);

    phase_list = flight_phase_detector.GetPhases();
    phase_totals = flight_phase_detector.GetTotals();
}
예제 #2
0
int main(int argc, char **argv)
{
  Args args(argc, argv, "DRIVER FILE");
  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  Result result;
  Run(*replay, result);
  delete replay;

  const ContestStatistics olc_plus = SolveContest(Contest::OLC_PLUS);
  const ContestStatistics dmst = SolveContest(Contest::DMST);

  TextWriter writer("/dev/stdout", true);

  {
    JSON::ObjectWriter root(writer);

    WriteResult(root, result);
    root.WriteElement("phases", WritePhaseList,
                      flight_phase_detector.GetPhases());
    root.WriteElement("performance", WritePerformanceStats,
                      flight_phase_detector.GetTotals());
    root.WriteElement("contests", WriteContests, olc_plus, dmst);
  }
}
예제 #3
0
int main(int argc, char **argv)
{
  unsigned full_max_points = 512,
           triangle_max_points = 1024,
           sprint_max_points = 64;

  Args args(argc, argv,
            "[options] DRIVER FILE\n"
            "Options:\n"
            "  --full-points=512        Maximum number of full trace points (default = 512)\n"
            "  --triangle-points=1024   Maximum number of triangle trace points (default = 1024)\n"
            "  --sprint-points=64       Maximum number of sprint trace points (default = 64)");

  const char *arg;
  while ((arg = args.PeekNext()) != nullptr && *arg == '-') {
    args.Skip();

    const char *value;
    if ((value = StringAfterPrefix(arg, "--full-points=")) != nullptr) {
      unsigned _points = strtol(value, NULL, 10);
      if (_points > 0)
        full_max_points = _points;
      else {
        fputs("The start parameter could not be parsed correctly.\n", stderr);
        args.UsageError();
      }

    } else if ((value = StringAfterPrefix(arg, "--triangle-points=")) != nullptr) {
      unsigned _points = strtol(value, NULL, 10);
      if (_points > 0)
        triangle_max_points = _points;
      else {
        fputs("The start parameter could not be parsed correctly.\n", stderr);
        args.UsageError();
      }

    } else if ((value = StringAfterPrefix(arg, "--sprint-points=")) != nullptr) {
      unsigned _points = strtol(value, NULL, 10);
      if (_points > 0)
        sprint_max_points = _points;
      else {
        fputs("The start parameter could not be parsed correctly.\n", stderr);
        args.UsageError();
      }

    } else {
      args.UsageError();
    }
  }

  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  static Trace full_trace(0, Trace::null_time, full_max_points);
  static Trace triangle_trace(0, Trace::null_time, triangle_max_points);
  static Trace sprint_trace(0, 9000, sprint_max_points);

  Result result;
  Run(*replay, result, full_trace, triangle_trace, sprint_trace);
  delete replay;

  const ContestStatistics olc_plus = SolveContest(Contest::OLC_PLUS, full_trace, triangle_trace, sprint_trace);
  const ContestStatistics dmst = SolveContest(Contest::DMST, full_trace, triangle_trace, sprint_trace);

  TextWriter writer("/dev/stdout", true);

  {
    JSON::ObjectWriter root(writer);

    WriteResult(root, result);
    root.WriteElement("phases", WritePhaseList,
                      flight_phase_detector.GetPhases());
    root.WriteElement("performance", WritePerformanceStats,
                      flight_phase_detector.GetTotals());
    root.WriteElement("contests", WriteContests, olc_plus, dmst);
  }
}