Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 private void CollectResults(PeaResult result)
 {
     MergeToResults(result.BestSolutions);
     ResultsWaitForCount--;
     if (ResultsWaitForCount == 0)
     {
         var finalResult = new PeaResult(result.StopReasons, Result);
         _starter.Tell(finalResult);
     }
 }
Ejemplo n.º 3
0
        private void MergeResults(PeaResult result)
        {
            foreach (var island in Islands)
            {
                if (island != Sender)
                {
                    island.Tell(End.Instance);
                }
            }

            Context.Parent.Tell(result);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }