示例#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);
        }
示例#2
0
 public override void Init(IEvaluationInitData initData)
 {
     InitData = (VSInitData)initData;
     InitData.Build();
     ConflictDetector = new VSConflictDetector();
     ConflictDetector.Init(initData);
 }
示例#3
0
 private void InitEntityCreators(IEvaluationInitData initData)
 {
     foreach (var creator in EntityCreators)
     {
         creator.Init(initData);
     }
 }
示例#4
0
 public void Init(IEvaluationInitData initData)
 {
     initData.Build();
     InitConflictDetectors(initData);
     InitEntityCreators(initData);
     Algorithm.InitPopulation();
 }
示例#5
0
 public void InitConflictDetectors(IEvaluationInitData initData)
 {
     foreach (var key in ConflictDetectors.Keys)
     {
         foreach (var detector in ConflictDetectors[key])
         {
             detector.Init(initData);
         }
     }
 }
示例#6
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);
        }
示例#7
0
        public PeaResult Run(PeaSettings settings, IEvaluationInitData initData, LaunchTravelersDelegate launchTravelers = null)
        {
            string[] keys = new string[settings.SubProblemList.Count];
            for (int i = 0; i < settings.SubProblemList.Count; i++)
            {
                keys[i] = settings.SubProblemList[i].Encoding.Key;
            }
            Key = new MultiKey(keys);

            var islandEngine = IslandEngineFactory.Create(Key, settings, settings.Seed);

            AddCallbackEvents(islandEngine, settings.NewEntityMergedToBest);

            Evaluator = (EvaluationBase)TypeLoader.CreateInstance(settings.Evaluation, settings.ParameterSet);
            Evaluator.Init(initData);

            islandEngine.Algorithm.SetEvaluationCallback(Evaluate);
            islandEngine.Init(initData);
            if (launchTravelers != null)
            {
                islandEngine.LaunchTravelers += launchTravelers;
            }

            var          c = 0;
            StopDecision stopDecision;

            while (true)
            {
                islandEngine.Algorithm.RunOnce();
                stopDecision = islandEngine.StopCriteria.MakeDecision(islandEngine, islandEngine.Algorithm.Population);
                if (stopDecision.MustStop)
                {
                    Debug.WriteLine(stopDecision.Reasons[0]);
                    break;
                }
                c++;
            }

            return(new PeaResult(stopDecision.Reasons, islandEngine.Algorithm.Population.Bests));
        }
示例#8
0
 public override void Init(IEvaluationInitData initData)
 {
     TSPPoints = ((TSPInitData)initData).TSPPoints;
 }
示例#9
0
 private void Init(IEvaluationInitData initData)
 {
     EvaluationData = initData;
     Evaluation.Init(initData);
 }
示例#10
0
 public void Init(IEvaluationInitData initData)
 {
     Count = ((TSPInitData)initData).TSPPoints.Count;
 }
示例#11
0
 public abstract void Init(IEvaluationInitData initData);
示例#12
0
 public virtual void Init(IEvaluationInitData initData)
 {
 }
示例#13
0
 public void Init(IEvaluationInitData initData)
 {
     InitData = (VSInitData)initData;
     InitData.Build();
 }
 public void Init(IEvaluationInitData initData)
 {
 }
示例#15
0
 public InitEvaluator(IEvaluationInitData initdata)
 {
     InitData = initdata;
 }
示例#16
0
 public override void Init(IEvaluationInitData initData)
 {
     throw new System.NotImplementedException();
 }