Ejemplo n.º 1
0
bool
OLCDijkstra::solve()
{
  if (m_dijkstra.empty()) {
    set_weightings();
    n_points = olc.get_trace_points(m_full_trace).size();
  }

  if (n_points < num_stages)
    return false;

  if (m_dijkstra.empty()) {
    m_dijkstra.reset(ScanTaskPoint(0, 0));
    add_start_edges();
    if (m_dijkstra.empty())
      // no processing to perform!
      // @todo
      // problem with this is it will immediately ask
      // OnlineContest for new data, which will be expensive
      // instead, new data should arrive only when preconditions
      // are satisfied (significant difference and valid)
      return true;
  }

  return solve_inner();
}
Ejemplo n.º 2
0
bool
ContestDijkstra::Solve(bool exhaustive)
{
  if (dijkstra.empty()) {
    set_weightings();
    dijkstra.reserve(CONTEST_QUEUE_SIZE);
  }

  assert(num_stages <= MAX_STAGES);

  if (dijkstra.empty()) {

    update_trace();
    if (n_points < num_stages)
      return true;

    // don't re-start search unless we have had new data appear
    if (!trace_dirty) {
      return true;
    }
  } else if (exhaustive) {
    update_trace();
    if (n_points < num_stages)
      return true;
  } else if (n_points < num_stages) {
    update_trace();
    return true;
  }

  if (trace_dirty) {
    trace_dirty = false;

    dijkstra.restart(ScanTaskPoint(0, 0));
    start_search();
    add_start_edges();
    if (dijkstra.empty()) {
      return true;
    }
  }

#ifdef INSTRUMENT_TASK
  count_olc_solve++;
  count_olc_size = max(count_olc_size, dijkstra.queue_size());
#endif

  if (distance_general(exhaustive ? 0 - 1 : 25)) {
    SaveSolution();
    update_trace();
    return true;
  }

  return !dijkstra.empty();
}