コード例 #1
0
        public Status UpdateAlgorithmSettings([FromBody] SettingsAlgorithmModel settings)
        {
            if (GeneticAlgorithm.Instance().Status.Running ||
                GeneticAlgorithm.Instance().Status.StopRequested)
            {
                return(GeneticAlgorithm.Instance().Status);
            }

            // basic algorithm settings
            var model = new GePrModel.Builder()
                        .SetAdditionalAnalytics(BpmAnalytics.Instance())
                        .SetEnableAnalytics(true)
                        .SetFitness(typeof(BpmnFitness))
                        .SetGenerationEvolver(new BpmnGenerationEvolver())
                        .SetSolutionType(typeof(BpmSolution))
                        .SetUseParalell(true)
                        .SetCrossoverProbability(settings.CrossoverProbability)
                        .SetInitialGenome(settings.ToIGenome())
                        .SetMaximumNumberOfGenerations(settings.MaximumNumberOfGenerations)
                        .SetMutationProbability(settings.MutationProbability)
                        .SetPopulationSize(settings.PopulationSize)
                        .SetSeed(settings.Seed)
                        .SetTermination(new IterationTermination(settings.MaximumNumberOfGenerations))
                        .SetTournamentSize(settings.TournamentSize)
                        .Build();

            ModelHelper.SetGePrModel(model);

            GeneticAlgorithm.Instance().SetModel(model);

            return(GeneticAlgorithm.Instance().Status);
        }
コード例 #2
0
        public JArray ValidGenomes([FromUri] int generation)
        {
            var array = BpmAnalytics.Instance().ValidGenomes();

            array = array.GetLast(generation);

            return(new JArray(array));
        }
コード例 #3
0
        public JObject GetNumberOfEvolvedGenerations()
        {
            var evo = new JObject();

            evo.Add("max", ModelHelper.GetGePrModel().GetMaximumNumberOfGenerations());
            evo.Add("current", BpmAnalytics.Instance().GetNumberOfEvolvedGenerations());

            return(evo);
        }
コード例 #4
0
        public Status Start()
        {
            if ((GeneticAlgorithm.Instance().Status.Ready || GeneticAlgorithm.Instance().Status.Stopped) &&
                DataHelper.ActivityHelper.Instance().Models.Count > 0)
            {
                BpmAnalytics.Instance().Clear();
                ModelHelper.GetGePrModel().GetTermination().Reset();
                GeneticAlgorithm.Instance().Reset(ModelHelper.GetGePrModel());

                GeneticAlgorithm.StartInNewTask();

                return(GeneticAlgorithm.Instance().Status);
            }

            return(GeneticAlgorithm.Instance().Status);
        }
コード例 #5
0
        public JObject Fitness([FromUri] int generation)
        {
            var minArray = BpmAnalytics.Instance().MinFitness();

            minArray = minArray.GetLast(generation);

            var avgArray = BpmAnalytics.Instance().AvgFitness();

            avgArray = avgArray.GetLast(generation);

            var maxArray = BpmAnalytics.Instance().MaxFitness();

            maxArray = maxArray.GetLast(generation);

            var jObject = new JObject();

            jObject.Add("min", new JArray(minArray));
            jObject.Add("avg", new JArray(avgArray));
            jObject.Add("max", new JArray(maxArray));

            return(jObject);
        }
コード例 #6
0
        public HttpResponseMessage GetBestSolution()
        {
            var bestSolution = BpmAnalytics.Instance().BestSolution();

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            var accept = Request.Headers
                         .GetValues("Accept")
                         .FirstOrDefault();


            if (!string.IsNullOrEmpty(accept) &&
                accept.ToLower().Contains("application/xml") &&
                bestSolution != null)
            {
                response.Content = new StringContent(
                    XmlHelper.BpmnToXml(bestSolution.Process.ParseBpmGenome()).OuterXml, Encoding.UTF8,
                    "application/xml");
                return(response);
            }
            return(Request.CreateResponse(HttpStatusCode.OK,
                                          bestSolution));
        }
コード例 #7
0
 public IEnumerable <BpmSolution> TopSolutions()
 {
     return(BpmAnalytics.Instance().GetTopSolutions(10));
 }
コード例 #8
0
 public IEnumerable <BpmSolution> All()
 {
     return(BpmAnalytics.Instance().GetAll());
 }