Ejemplo n.º 1
0
void
ContestDijkstra::UpdateTrace(bool force)
{
  if (append_serial == trace_master.GetAppendSerial())
    /* unmodified */
    return;

  if (IsMasterUpdated()) {
    UpdateTraceFull();

    trace_dirty = true;
    finished = false;

    first_finish_candidate = incremental ? n_points - 1 : 0;
  } else if (finished) {
    const unsigned old_size = n_points;
    if (UpdateTraceTail())
      /* new data from the master trace, start incremental solver */
      AddIncrementalEdges(old_size);
  } else if (force) {
    if (UpdateTraceTail()) {
      /* new data from the master trace, restart the non-incremental
         solver */
      trace_dirty = true;
      first_finish_candidate = incremental ? n_points - 1 : 0;
    }
  }
}
Ejemplo n.º 2
0
void
OLCTriangle::UpdateTrace(bool force)
{
  if (IsMasterAppended()) return; /* unmodified */

  if (force || IsMasterUpdated(false)) {
    UpdateTraceFull();

    is_complete = false;

    best_d = 0;

    closing_pairs.Clear();
    is_closed = FindClosingPairs(0);

   } else if (is_complete && incremental) {
    const unsigned old_size = n_points;
    if (UpdateTraceTail()) {
      is_complete = false;
      is_closed = FindClosingPairs(old_size);
    }
  }

  /**
   * Update tick_iterations to a sensible value. Statistical analysis
   * revealed that the branch and bound algorithm worst running time
   * is around O(n_points^2.2), it's best can be better than O(n_points).
   * Using n_points^2 / 8 as number of iterations per tick should allow
   * the algorithm to finish in about 10 to 15 ticks in most cases.
   */
  tick_iterations = n_points * n_points / 8;
}