public PeaResult Start(PeaSettings settings, IEvaluationInitData initData) { var inbox = Inbox.Create(System); PeaResult result = null; try { inbox.Send(SystemActor, new CreateSystem(settings)); var response = inbox.Receive(TimeSpan.FromSeconds(30)); if (response is CreatedSuccessfully) { inbox.Send(SystemActor, new InitEvaluator(initData)); result = (PeaResult)inbox.Receive(TimeSpan.FromMinutes(30)); } } catch (Exception e) { result = new PeaResult(new List <string>() { e.ToString() }, new List <IEntity>()); } //var response = await SystemActor.Ask(new CreateSystem(settings)); //if (response is CreatedSuccessfully) //{ //result = await SystemActor.Ask(new InitEvaluator(initData)); //} return(result); }
private void CollectResults(PeaResult result) { MergeToResults(result.BestSolutions); ResultsWaitForCount--; if (ResultsWaitForCount == 0) { var finalResult = new PeaResult(result.StopReasons, Result); _starter.Tell(finalResult); } }
private void MergeResults(PeaResult result) { foreach (var island in Islands) { if (island != Sender) { island.Tell(End.Instance); } } Context.Parent.Tell(result); }
public PeaResult Run(IEvaluationInitData initData) //async Task<PeaResult> { var settings = Settings.Build(); var islandsCount = settings.ParameterSet.FindLast(p => p.Name == ParameterNames.IslandsCount).Value; //TODO: clarify this PeaResult result = null; if (islandsCount < 2) { var localRunner = new IslandLocalRunner(); result = localRunner.Run(settings, initData); } else { result = _provider.Start(settings, initData); //await } return(result); }
public void RunOneStep() { StopDecision stop = null; var algorithmCycleCount = Engine.Parameters.GetInt(Algorithm.ParameterNames.SubCycleRunCount) + 1; for (int i = 0; i < algorithmCycleCount; i++) { stop = Engine.RunOnce(); if (stop.MustStop) { var result = new PeaResult(stop.Reasons, Engine.Algorithm.Population.Bests); Starter.Tell(result); Self.Tell(PoisonPill.Instance); break; } } Engine.Reduct(); if (!stop.MustStop) { Self.Tell(Continue.Instance); } }