public Algorithm( IPoints points, IRectangle rect, StrategyType type = StrategyType.Grid, ILog2 log = null) { _log = log ?? new NoLog(); Rectangle = rect; Points = points.Data; Singles = new List <IP>(); Knn = new NearestNeighbor(); GridContainer = new GridContainer(Rectangle, Points); switch (type) { case StrategyType.Naive: Strategy = new NaiveStrategy(_log); break; case StrategyType.Grid: Strategy = new GridStrategy(_log); break; case StrategyType.KdTree: Strategy = new KdTreeStrategy(Points); break; default: throw new NotImplementedException("Unknown strategy"); } //_log.Info(MethodBase.GetCurrentMethod(), "object init"); }
/// <summary> /// Runs an individual algorithm. /// </summary> /// <param name="algorithmContext">Algorithm context</param> /// <param name="algorithmStrategy">Algorithm to run</param> static int RunIndividualAlgorithm(AlgorithmContext algorithmContext, IAlgorithmStrategy algorithmStrategy) { algorithmContext.AlgorithmStrategy = algorithmStrategy; var missCount = algorithmContext.Execute(); return(missCount); }
public Form1() { InitializeComponent(); tb_disk.SetRange(0, DiskScheduler.diskSize); tb_disk.Value = DiskScheduler.diskSize / 2; cb_algorithm.Items.AddRange(Enum.GetNames(typeof(Algorithm))); disk = new DiskScheduler(); algorithmStrategy = new ScanStrategy(tb_disk.Value, DiskScheduler.diskSize); tb_disk.TickStyle = TickStyle.Both; }
public void SetAlgorithmStrategy(IAlgorithmStrategy algorithmStrategy) { Strategy = algorithmStrategy; }
public void SetStrategy(IAlgorithmStrategy strategy) { AlgorithmStrategy = strategy; }