private void InitializeEngine() { engine = engineBuilder.Build(); var result = engine.Next(); // Create the initial population; geneticResultDisplay.SetResult(result); }
private async void runButton_Click(object sender, EventArgs e) { SetButtonsState(EngineState.Running); lock (shouldPauseLock) shouldPause = false; while (!shouldPause) { var result = await Task.Run(() => engine.Next()); lock (shouldPauseLock) shouldPause = shouldPause || result.IsCompleted; geneticResultDisplay.SetResult(result); } SetButtonsState(EngineState.Puased); }
public static GeneticSearchResult Run(this GeneticSearchEngine engine, RunType runType) { if (runType == RunType.Run) { return(engine.Run()); } GeneticSearchResult result = null; while (result == null || !result.IsCompleted) { result = engine.Next(); } return(result); }
private CommandRunner GetNextCommand(GeneticSearchEngine engine) => new EngineRunner("Next", () => engine.Next());