Changeset 18132 for trunk/HeuristicLab.Tests
- Timestamp:
- 12/15/21 11:50:57 (3 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol (added) merged: 18091,18093,18100,18112-18121,18123-18131
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Tests
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol/HeuristicLab.Tests (added) merged: 18119-18120,18123,18126-18127,18131
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicClassificationSampleTest.cs
r17180 r18132 109 109 varSymbol.WeightManipulatorSigma = 0.05; 110 110 varSymbol.MultiplicativeWeightManipulatorSigma = 0.03; 111 var constSymbol = grammar.Symbols.OfType<Constant>().Single();112 constSymbol.MaxValue = 20;113 constSymbol.MinValue = -20;114 constSymbol.ManipulatorMu = 0.0;115 constSymbol.ManipulatorSigma = 1;116 constSymbol.MultiplicativeManipulatorSigma = 0.03;111 var numSymbol = grammar.Symbols.OfType<Number>().Single(); 112 numSymbol.MaxValue = 20; 113 numSymbol.MinValue = -20; 114 numSymbol.ManipulatorMu = 0.0; 115 numSymbol.ManipulatorSigma = 1; 116 numSymbol.MultiplicativeManipulatorSigma = 0.03; 117 117 symbClassProblem.SymbolicExpressionTreeGrammar = grammar; 118 118 -
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleTest.cs
r17180 r18132 110 110 varSymbol.WeightManipulatorSigma = 0.05; 111 111 varSymbol.MultiplicativeWeightManipulatorSigma = 0.03; 112 var constSymbol = grammar.Symbols.OfType<Constant>().Single();113 constSymbol.MaxValue = 20;114 constSymbol.MinValue = -20;115 constSymbol.ManipulatorMu = 0.0;116 constSymbol.ManipulatorSigma = 1;117 constSymbol.MultiplicativeManipulatorSigma = 0.03;112 var numSymbol = grammar.Symbols.OfType<Number>().Single(); 113 numSymbol.MaxValue = 20; 114 numSymbol.MinValue = -20; 115 numSymbol.ManipulatorMu = 0.0; 116 numSymbol.ManipulatorSigma = 1; 117 numSymbol.MultiplicativeManipulatorSigma = 0.03; 118 118 symbRegProblem.SymbolicExpressionTreeGrammar = grammar; 119 119 -
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleWithOSTest.cs
r17948 r18132 66 66 // Unfortunately, running the same test on a different machine results in different values 67 67 // For x86 environments the results below match but on x64 there is a difference 68 // We tracked down the ConstantOptimizationEvaluator as a possible cause but have not68 // We tracked down the ParameterOptimizationEvaluator as a possible cause but have not 69 69 // been able to identify the real cause. Presumably, execution on a Xeon and a Core i7 processor 70 70 // leads to different results. … … 184 184 problem.MaximumFunctionArguments.Value = 0; 185 185 186 var evaluator = new SymbolicRegression ConstantOptimizationEvaluator();187 evaluator. ConstantOptimizationIterations.Value = 5;186 var evaluator = new SymbolicRegressionParameterOptimizationEvaluator(); 187 evaluator.ParameterOptimizationIterations.Value = 5; 188 188 problem.EvaluatorParameter.Value = evaluator; 189 189 problem.RelativeNumberOfEvaluatedSamplesParameter.Hidden = true; -
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GeSymbolicRegressionSampleTest.cs
r17180 r18132 113 113 problem.SymbolicExpressionTreeGrammar.RemoveSymbol(c); 114 114 } 115 var numbers = problem.SymbolicExpressionTreeGrammar.AllowedSymbols.OfType<Number>().ToList(); 116 foreach (var n in numbers) { 117 problem.SymbolicExpressionTreeGrammar.RemoveSymbol(n); 118 } 115 119 116 120 SamplesUtils.ConfigureOsGeneticAlgorithmParameters<GenderSpecificSelector, Encodings.IntegerVectorEncoding.SinglePointCrossover, Encodings.IntegerVectorEncoding.UniformOnePositionManipulator>( -
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/ShapeConstrainedRegressionSampleTest.cs
r17968 r18132 35 35 [TestClass] 36 36 public class ShapeConstrainedRegressionSampleTest { 37 private const string SampleFileName = "G A_Shape_Constrained_Regression";37 private const string SampleFileName = "GP_Shape_Constrained_Regression"; 38 38 private static readonly ProtoBufSerializer serializer = new ProtoBufSerializer(); 39 39 … … 47 47 48 48 if (Environment.Is64BitProcess) { 49 Assert.AreEqual(0. 355347729912352, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-8);50 Assert.AreEqual(2 7.6606834433137, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"), 1E-8);51 Assert.AreEqual(3 359.91748220025, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"), 1E-8);49 Assert.AreEqual(0.035536903914644882, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-8); 50 Assert.AreEqual(26.707437555596698, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"), 1E-8); 51 Assert.AreEqual(3294.1754151628993, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"), 1E-8); 52 52 Assert.AreEqual(150200, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions")); 53 53 } else { … … 57 57 Assert.AreEqual(150200, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions")); 58 58 } 59 } 60 61 [TestMethod] 62 [TestCategory("Samples.Create")] 63 [TestProperty("Time", "medium")] 64 public void CreateShapeConstrainedRegressionSampleTest() { 65 var ga = CreateShapeConstrainedRegressionSample(); 66 string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension); 67 serializer.Serialize(ga, path); 59 68 } 60 69 … … 82 91 83 92 #region Algorithm Configuration 84 alg.Name = "Genetic Programming - Shape 93 alg.Name = "Genetic Programming - Shape-constrained Regression"; 85 94 alg.Description = "A standard genetic programming algorithm to solve a shape constrained regression problem (Radiated gravitational wave power - Feynman instance)"; 86 95 alg.Problem = problem; … … 93 102 94 103 alg.Engine = new ParallelEngine.ParallelEngine(); 104 95 105 return alg; 96 106 } -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
r17180 r18132 35 35 var formatter = new InfixExpressionFormatter(); 36 36 var parser = new InfixExpressionParser(); 37 Assert.AreEqual("0", Derive(" 3", "x"));37 Assert.AreEqual("0", Derive("<num=3>", "x")); 38 38 Assert.AreEqual("1", Derive("x", "x")); 39 Assert.AreEqual("10", Derive(" 10*x", "x"));40 Assert.AreEqual("10", Derive("x* 10", "x"));39 Assert.AreEqual("10", Derive("<num=10>*x", "x")); 40 Assert.AreEqual("10", Derive("x*<num=10>", "x")); 41 41 Assert.AreEqual("(2*'x')", Derive("x*x", "x")); 42 42 Assert.AreEqual("((('x' * 'x') * 2) + ('x' * 'x'))", Derive("x*x*x", "x")); // simplifier does not merge (x*x)*2 + x*x to 3*x*x 43 Assert.AreEqual("0", Derive(" 10*x", "y"));44 Assert.AreEqual("20", Derive(" 10*x+20*y", "y"));45 Assert.AreEqual("6", Derive(" 2*3*x", "x"));46 Assert.AreEqual("(10*'y')", Derive(" 10*x*y+20*y", "x"));43 Assert.AreEqual("0", Derive("<num=10>*x", "y")); 44 Assert.AreEqual("20", Derive("<num=10>*x+<num=20>*y", "y")); 45 Assert.AreEqual("6", Derive("<num=2>*<num=3>*x", "x")); 46 Assert.AreEqual("(10*'y')", Derive("<num=10>*x*y+<num=20>*y", "x")); 47 47 Assert.AreEqual("(1 / (SQR('x') * (-1)))", Derive("1/x", "x")); 48 48 Assert.AreEqual("('y' / (SQR('x') * (-1)))", Derive("y/x", "x")); … … 51 51 Assert.AreEqual("((((-2*'x') + (-1)) * ('a' + 'b')) / SQR(('x' + SQR('x'))))", Derive("(a+b)/(x+SQR(x))", "x")); 52 52 Assert.AreEqual("EXP('x')", Derive("exp(x)", "x")); 53 Assert.AreEqual("(EXP((3*'x')) * 3)", Derive("exp( 3*x)", "x"));53 Assert.AreEqual("(EXP((3*'x')) * 3)", Derive("exp(<num=3>*x)", "x")); 54 54 Assert.AreEqual("(1 / 'x')", Derive("log(x)", "x")); 55 Assert.AreEqual("(1 / 'x')", Derive("log( 3*x)", "x")); // 3 * 1/(3*x)56 Assert.AreEqual("(1 / ('x' + (0.333333333333333*'y')))", Derive("log( 3*x+y)", "x")); // simplifier does not try to keep fractions57 Assert.AreEqual("(1 / (SQRT(((3*'x') + 'y')) * 0.666666666666667))", Derive("sqrt( 3*x+y)", "x")); // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y))58 Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin( 3*x)", "x"));59 Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos( 3*x)", "x"));60 Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan( 3*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator55 Assert.AreEqual("(1 / 'x')", Derive("log(<num=3>*x)", "x")); // 3 * 1/(3*x) 56 Assert.AreEqual("(1 / ('x' + (0.333333333333333*'y')))", Derive("log(<num=3>*x+y)", "x")); // simplifier does not try to keep fractions 57 Assert.AreEqual("(1 / (SQRT(((3*'x') + 'y')) * 0.666666666666667))", Derive("sqrt(<num=3>*x+y)", "x")); // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y)) 58 Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin(<num=3>*x)", "x")); 59 Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos(<num=3>*x)", "x")); 60 Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan(<num=3>*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator 61 61 62 Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs( 3*x)", "x"));62 Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs(<num=3>*x)", "x")); 63 63 Assert.AreEqual("(SQR('x') * 3)", Derive("cube(x)", "x")); 64 64 Assert.AreEqual("(1 / (SQR(CUBEROOT('x')) * 3))", Derive("cuberoot(x)", "x")); -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionCrossoverTest.cs
r17180 r18132 110 110 grammar.MinimumFunctionDefinitions = 0; 111 111 112 var trees = Util.CreateRandomTrees(twister, dataset, grammar, PopulationSize, 1, MaxTreeLength, 0, 0);112 var trees = Util.CreateRandomTrees(twister, dataset, grammar, PopulationSize, MaxTreeLength); 113 113 foreach (ISymbolicExpressionTree tree in trees) { 114 114 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r17950 r18132 141 141 grammar.ConfigureAsDefaultRegressionGrammar(); 142 142 143 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);143 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 144 144 foreach (ISymbolicExpressionTree tree in randomTrees) { 145 145 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 155 155 156 156 var grammar = new FullFunctionalExpressionGrammar(); 157 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);157 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 158 158 foreach (ISymbolicExpressionTree tree in randomTrees) { 159 159 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 169 169 170 170 var grammar = new ArithmeticExpressionGrammar(); 171 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);171 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 172 172 foreach (SymbolicExpressionTree tree in randomTrees) { 173 173 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 249 249 250 250 var rows = Enumerable.Range(0, numRows).ToList(); 251 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 10, 0,0);251 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 10); 252 252 foreach (ISymbolicExpressionTree tree in randomTrees) { 253 253 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 299 299 grammar.Symbols.First(x => x is Power).Enabled = false; 300 300 301 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 10, 0,0);301 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 10); 302 302 foreach (ISymbolicExpressionTree tree in randomTrees) { 303 303 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r17820 r18132 230 230 231 231 #region abs 232 AssertEqualAfterSimplification("(abs 2.0)", "2.0");233 AssertEqualAfterSimplification("(abs -2.0)", "2.0"); // constant folding232 AssertEqualAfterSimplification("(abs <num=2.0>)", "2.0"); 233 AssertEqualAfterSimplification("(abs <num=-2.0>)", "2.0"); // constant folding 234 234 AssertEqualAfterSimplification("(abs (exp (variable 2.0 x)))", "(exp (variable 2.0 x)))"); // exp is always positive 235 235 AssertEqualAfterSimplification("(abs (exp (variable 2.0 x)))", "(exp (variable 2.0 x)))"); // exp is always positive … … 238 238 AssertEqualAfterSimplification("(abs (cuberoot (variable 2.0 a)))", "(cuberoot (variable 2.0 a))"); // cuberoot is always positive (for our cases) 239 239 240 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) 2.0)", "(abs (variable 4.0 x))"); // can multiply positive constants into abs241 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) -2.0)", "(* (abs (variable 4.0 x)) -1.0)"); // for negative constants keep the sign240 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) <num=2.0>)", "(abs (variable 4.0 x))"); // can multiply positive constants into abs 241 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) <num=-2.0>)", "(* (abs (variable 4.0 x)) -1.0)"); // for negative constants keep the sign 242 242 243 243 AssertEqualAfterSimplification("(abs (* (variable 1.0 a) (variable 2.0 b)))", "(* (abs (variable 1.0 a)) (abs (variable 1.0 b)) 2.0))"); … … 265 265 266 266 #region AQ 267 AssertEqualAfterSimplification("(* (aq (variable 1.0 x) (variable 1.0 y)) 2.0)", "(aq (variable 2.0 x) (variable 1.0 y))");268 AssertEqualAfterSimplification("(/ (aq (variable 1.0 x) (variable 1.0 y)) 2.0)", "(aq (variable 0.5 x) (variable 1.0 y))");267 AssertEqualAfterSimplification("(* (aq (variable 1.0 x) (variable 1.0 y)) <num=2.0>)", "(aq (variable 2.0 x) (variable 1.0 y))"); 268 AssertEqualAfterSimplification("(/ (aq (variable 1.0 x) (variable 1.0 y)) <num=2.0>)", "(aq (variable 0.5 x) (variable 1.0 y))"); 269 269 270 270 #endregion 271 271 272 272 #region do not drop subtrees with small weights 273 AssertEqualAfterSimplification("(* 1e-14(variable 1.0 a))", "(variable 1e-14 a)");274 AssertEqualAfterSimplification("(+ (variable 1.0 a) 1e-14)",275 "(+ (variable 1.0 a) 1e-14)");273 AssertEqualAfterSimplification("(* <num=1e-14> (variable 1.0 a))", "(variable 1e-14 a)"); 274 AssertEqualAfterSimplification("(+ (variable 1.0 a) <num=1e-14>)", 275 "(+ (variable 1.0 a) <num=1e-14>)"); 276 276 // a scenario where a term with small weight can have large effect 277 AssertEqualAfterSimplification("(+ (* (pow (variable 1.0 a) 10) 1e-14) 1.0)",278 "(+ (* (pow (variable 1.0 a) 10) 1e-14) 1.0)");277 AssertEqualAfterSimplification("(+ (* (pow (variable 1.0 a) <num=10>) <num=1e-14>) 1.0)", 278 "(+ (* (pow (variable 1.0 a) <num=10>) <num=1e-14>) 1.0)"); 279 279 // a test case (from ticket #2985) 280 AssertEqualAfterSimplification("(+ (* (exp (variable 3.5861E+001 a)) 5.5606E-016) 5.9323E-002)",281 "(+ (* (exp (variable 3.5861E+001 a)) 5.5606E-016) 5.9323E-002)");280 AssertEqualAfterSimplification("(+ (* (exp (variable 3.5861E+001 a)) <num=5.5606E-016>) <num=5.9323E-002>)", 281 "(+ (* (exp (variable 3.5861E+001 a)) <num=5.5606E-016>) <num=5.9323E-002>)"); 282 282 #endregion 283 283 } -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs
r16869 r18132 77 77 var twister = new MersenneTwister(31415); 78 78 var ds = Util.CreateRandomDataset(twister, Rows, Columns); 79 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 1 , 100, 0,0);79 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 100); 80 80 81 81 double s = 0; 82 82 var sw = new Stopwatch(); 83 83 84 var similarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchVariableWeights = false, Match ConstantValues = false };84 var similarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchVariableWeights = false, MatchParameterValues = false }; 85 85 86 86 sw.Start(); … … 115 115 var twister = new MersenneTwister(31415); 116 116 var ds = Util.CreateRandomDataset(twister, Rows, Columns); 117 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 1 , 100, 0,0);117 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 100); 118 118 119 var similarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { Match ConstantValues = strict, MatchVariableWeights = strict };119 var similarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchParameterValues = strict, MatchVariableWeights = strict }; 120 120 var bottomUpSimilarity = 0d; 121 121 for (int i = 0; i < trees.Length - 1; ++i) { -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest.cs
r11916 r18132 53 53 var twister = new MersenneTwister(31415); 54 54 var ds = Util.CreateRandomDataset(twister, Rows, Columns); 55 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 1 , 100, 0,0);55 var trees = Util.CreateRandomTrees(twister, ds, grammar, N, 100); 56 56 57 57 double s = 0; -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/Util.cs
r17180 r18132 35 35 varNode.Weight = twister.NextDouble() * 20.0 - 10.0; 36 36 varNode.VariableName = varNames[twister.Next(varNames.Count)]; 37 } else if (node is ConstantTreeNode) {38 var constantNode = node as ConstantTreeNode;39 constantNode.Value = twister.NextDouble() * 20.0 - 10.0;37 } else if (node is NumberTreeNode) { 38 var numNode = node as NumberTreeNode; 39 numNode.Value = twister.NextDouble() * 20.0 - 10.0; 40 40 } 41 41 } … … 44 44 45 45 public static ISymbolicExpressionTree[] CreateRandomTrees(MersenneTwister twister, Dataset dataset, ISymbolicExpressionGrammar grammar, int popSize) { 46 return CreateRandomTrees(twister, dataset, grammar, popSize, 1, 200, 3, 3);46 return CreateRandomTrees(twister, dataset, grammar, popSize, 200); 47 47 } 48 48 49 49 public static ISymbolicExpressionTree[] CreateRandomTrees(MersenneTwister twister, Dataset dataset, ISymbolicExpressionGrammar grammar, 50 int popSize, int minSize, int maxSize, 51 int maxFunctionDefinitions, int maxFunctionArguments) { 50 int popSize, int maxSize) { 52 51 foreach (Variable variableSymbol in grammar.Symbols.OfType<Variable>()) { 53 52 variableSymbol.VariableNames = dataset.VariableNames.Skip(1); -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r17180 r18132 66 66 grammar.MinimumFunctionArguments = 0; 67 67 grammar.MinimumFunctionDefinitions = 0; 68 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);68 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 69 69 foreach (ISymbolicExpressionTree tree in randomTrees) { 70 70 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 83 83 grammar.MinimumFunctionArguments = 0; 84 84 grammar.MinimumFunctionDefinitions = 0; 85 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);85 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 86 86 foreach (ISymbolicExpressionTree tree in randomTrees) { 87 87 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); … … 100 100 grammar.MinimumFunctionArguments = 0; 101 101 grammar.MinimumFunctionDefinitions = 0; 102 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1 , 100, 0,0);102 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 100); 103 103 foreach (SymbolicExpressionTree tree in randomTrees) { 104 104 Util.InitTree(tree, twister, new List<string>(dataset.VariableNames)); -
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4/Util.cs
r17180 r18132 35 35 varNode.Weight = twister.NextDouble() * 20.0 - 10.0; 36 36 varNode.VariableName = varNames[twister.Next(varNames.Count)]; 37 } else if (node is ConstantTreeNode) {38 var constantNode = node as ConstantTreeNode;39 constantNode.Value = twister.NextDouble() * 20.0 - 10.0;37 } else if (node is NumberTreeNode) { 38 var numNode = node as NumberTreeNode; 39 numNode.Value = twister.NextDouble() * 20.0 - 10.0; 40 40 } 41 41 } … … 44 44 45 45 public static ISymbolicExpressionTree[] CreateRandomTrees(MersenneTwister twister, Dataset dataset, ISymbolicExpressionGrammar grammar, int popSize) { 46 return CreateRandomTrees(twister, dataset, grammar, popSize, 1, 200, 3, 3);46 return CreateRandomTrees(twister, dataset, grammar, popSize, 200); 47 47 } 48 48 49 49 public static ISymbolicExpressionTree[] CreateRandomTrees(MersenneTwister twister, Dataset dataset, ISymbolicExpressionGrammar grammar, 50 int popSize, int minSize, int maxSize, 51 int maxFunctionDefinitions, int maxFunctionArguments) { 50 int popSize, int maxSize) { 52 51 foreach (Variable variableSymbol in grammar.Symbols.OfType<Variable>()) { 53 52 variableSymbol.VariableNames = dataset.VariableNames.Skip(1);
Note: See TracChangeset
for help on using the changeset viewer.