コード例 #1
0
        private AlpsGeneticAlgorithm CreateAlpsGaSymRegSample()
        {
            AlpsGeneticAlgorithm alpsGa = new AlpsGeneticAlgorithm();

            #region Problem Configuration
            var provider       = new VladislavlevaInstanceProvider();
            var instance       = provider.GetDataDescriptors().Single(x => x.Name.StartsWith("Vladislavleva-5 F5"));
            var symbRegProblem = new SymbolicRegressionSingleObjectiveProblem();
            symbRegProblem.Load(provider.LoadData(instance));

            symbRegProblem.MaximumSymbolicExpressionTreeDepth.Value  = 35;
            symbRegProblem.MaximumSymbolicExpressionTreeLength.Value = 35;

            var grammar = (TypeCoherentExpressionGrammar)symbRegProblem.SymbolicExpressionTreeGrammar;
            grammar.Symbols.OfType <Exponential>().Single().Enabled = false;
            grammar.Symbols.OfType <Logarithm>().Single().Enabled   = false;

            #endregion
            #region Algorithm Configuration
            alpsGa.Name        = "ALPS Genetic Programming - Symbolic Regression";
            alpsGa.Description = "An ALPS-GP to solve a symbolic regression problem (Vladislavleva-5 dataset)";
            alpsGa.Problem     = symbRegProblem;
            SamplesUtils.ConfigureAlpsGeneticAlgorithmParameters <GeneralizedRankSelector, SubtreeCrossover, MultiSymbolicExpressionTreeManipulator>(alpsGa,
                                                                                                                                                     numberOfLayers: 1000,
                                                                                                                                                     popSize: 100,
                                                                                                                                                     mutationRate: 0.25,
                                                                                                                                                     elites: 1,
                                                                                                                                                     plusSelection: false,
                                                                                                                                                     agingScheme: AgingScheme.Polynomial,
                                                                                                                                                     ageGap: 15,
                                                                                                                                                     ageInheritance: 1.0,
                                                                                                                                                     maxGens: 500);
            #endregion
            return(alpsGa);
        }
コード例 #2
0
        public void GetVladislavlevaInstanceTest()
        {
            var           target             = new VladislavlevaInstanceProvider();
            StringBuilder erroneousInstances = new StringBuilder();
            int           count = 0;

            foreach (var id in target.GetDataDescriptors())
            {
                try {
                    target.LoadData(id);
                } catch (Exception ex) {
                    erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
                }
                count++;
            }
            Assert.IsTrue(count > 0, "No problem instances were found.");
            Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
        }
コード例 #3
0
 public void GetVladislavlevaInstanceTest() {
   var target = new VladislavlevaInstanceProvider();
   StringBuilder erroneousInstances = new StringBuilder();
   int count = 0;
   foreach (var id in target.GetDataDescriptors()) {
     try {
       target.LoadData(id);
     } catch (Exception ex) {
       erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     }
     count++;
   }
   Assert.IsTrue(count > 0, "No problem instances were found.");
   Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
 }