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);
        }
Ejemplo n.º 2
0
        public JArray ValidGenomes([FromUri] int generation)
        {
            var array = BpmAnalytics.Instance().ValidGenomes();

            array = array.GetLast(generation);

            return(new JArray(array));
        }
        public JObject GetNumberOfEvolvedGenerations()
        {
            var evo = new JObject();

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

            return(evo);
        }
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
0
 public IEnumerable <BpmSolution> TopSolutions()
 {
     return(BpmAnalytics.Instance().GetTopSolutions(10));
 }
Ejemplo n.º 8
0
 public IEnumerable <BpmSolution> All()
 {
     return(BpmAnalytics.Instance().GetAll());
 }