public void Search() { Thread thread = new Thread(() => { while (true) { var idea = _currentNeighbourhood.Nearby(); var fitness = _model.Fitness(idea); if (AbandonSite(idea, fitness)) { Console.WriteLine($"Abandoning {_currentNeighbourhood.Output().Fitness:0.0} {idea}"); continue; } _dance(fitness, idea, _id); if (_cancellationToken.IsCancellationRequested) { break; } } }); thread.Start(); }
public Scout(FirstModel model, int id, Action <double, Idea, int> dance, Action <Idea, double> report, CancellationToken cancellationToken) { _model = model; _id = id; _dance = dance; _report = report; _cancellationToken = cancellationToken; var newIdea = Idea.NewIdea(); _currentNeighbourhood = new Neighbourhood(newIdea, _model.Fitness(newIdea)); }
public void Search() { var thread = new Thread(() => { while (true) { if (_cancellationToken.IsCancellationRequested) { break; } var neighbourhood = _neighbourhoodFunc(); if (neighbourhood == null) { continue; } var idea = neighbourhood.Nearby(); neighbourhood.RegisterSearch(idea, _model.Fitness(idea)); } }); thread.Start(); }