public RandomPathAlgorithm(int steps, IEdgeFinder edgeFinder) : base(steps, edgeFinder) { _randomGenerator = new Random(); }
protected AlgorithmBase(int steps, IEdgeFinder edgeFinder) { _steps = steps; _edgeFinder = edgeFinder; }
public GreedyCycleAlgorithm(int steps, IEdgeFinder edgeFinder) : base(steps, edgeFinder) { }
public BoxGetter(IEdgeFinder c, IEdgeFinder r) { ef_col = c; ef_row = r; }
protected static void calc_visible( double range_begin, double range_length, IDimension rc, out int first, out int last, out IEdgeFinder ef ) { if (range_length <= 0) { first = -1; last = -1; ef = null; } // we could do wraparound in here (with a fixed number), but then we // could end up needing to return two first/last pairs if the range // straddles the boundary. probably better to handle wraparound // entirely in the caller. it should just adjust the range to be // positive and then de-adjust afterward. bool variable = rc.variable_sizes; Func <int, double> get_dist = rc.func_size; if (!variable) { double w = get_dist(-1); first = (int)(range_begin / w); if (first < 0) { // we don't support negative row/column numbers first = 0; } last = (int)((range_begin + range_length) / w); if (rc.number.HasValue) { int num = rc.number.Value; if (last > (num - 1)) { last = num - 1; } } ef = new FixedEdgeFinder(w); } else { var edges = new Dictionary <int, double> (); var lengths = new Dictionary <int, double> (); double cur_begin = 0; int i = 0; do { // assert that cur_begin cannot be > range_begin here // TODO but it happened, and the loop goes forever, // so we changed the check below to use >= instead of == double cur_length = get_dist(i); if ( (cur_begin >= range_begin) || ((cur_begin < range_begin) && ((cur_begin + cur_length) > range_begin)) ) { // column i is going to be first. add it to the results. edges[i] = cur_begin; lengths[i] = cur_length; // advance the cur_begin edge, but leave i alone for now so it // can be assigned after the loop. cur_begin += cur_length; break; } // TODO don't overrun num cur_begin += cur_length; i++; } while (true); first = i++; // TODO first cannot be <0 here, right? // cur_begin/i should now be together again, pointing at the first column // after first. which might not exist. double range_end = range_begin + range_length; if ((edges [first] + lengths [first]) >= range_end) { // if width of first is wider than the range, we're done last = first; } else if ( (rc.number.HasValue) && (i > (rc.number.Value - 1)) ) { // if there actually is nothing beyond first, we're done last = first; } else { do { // assert that left < right here double w = get_dist(i); // add the current column edges [i] = cur_begin; lengths [i] = w; if ((cur_begin + w) >= range_end) { // column is going to be last. break; } if (rc.number.HasValue) { int num = rc.number.Value; if ((i + 1) > (num - 1)) { // there are no more columns. so this one is last. break; } } cur_begin += w; i++; } while (true); last = i; } ef = new VariableEdgeFinder(edges, lengths); } }
public NearestNeighborAlgorithm(int steps, IEdgeFinder edgeFinder) : base(steps, edgeFinder) { }
public LocalSearchAlgorithm(int steps, IEdgeFinder edgeFinder) : base(steps, edgeFinder) { }