Changeset 13280 for stable/HeuristicLab.Tests/HeuristicLab-3.3/Samples
- Timestamp:
- 11/19/15 11:42:02 (9 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12921,12936-12938,12940,12947,13055-13058,13163,13267,13269
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Tests merged: 13056-13058,13163
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPArtificialAntSampleTest.cs
r12009 r13280 25 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 26 using HeuristicLab.Persistence.Default.Xml; 27 using HeuristicLab.Problems. ArtificialAnt;27 using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt; 28 28 using HeuristicLab.Selection; 29 29 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 60 60 61 61 #region Problem Configuration 62 ArtificialAntProblem antProblem = new ArtificialAntProblem();63 antProblem.BestKnownQuality .Value= 89;64 antProblem. MaxExpressionDepth.Value= 10;65 antProblem. MaxExpressionLength.Value= 100;66 antProblem. MaxFunctionArguments.Value= 3;67 antProblem. MaxFunctionDefinitions.Value= 3;62 Problem antProblem = new Problem(); 63 antProblem.BestKnownQuality = 89; 64 antProblem.Encoding.TreeDepth = 10; 65 antProblem.Encoding.TreeLength = 100; 66 antProblem.Encoding.FunctionDefinitions = 3; 67 antProblem.Encoding.FunctionArguments = 3; 68 68 antProblem.MaxTimeSteps.Value = 600; 69 69 #endregion -
stable/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPLawnMowerSampleTest.cs
r12009 r13280 36 36 ga.SetSeedRandomly.Value = false; 37 37 SamplesUtils.RunAlgorithm(ga); 38 Assert.AreEqual(55, SamplesUtils.GetDoubleResult(ga, "BestQuality")); 39 Assert.AreEqual(49.266, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality")); 40 Assert.AreEqual(1, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality")); 41 Assert.AreEqual(50950, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions")); 38 42 } 39 43 … … 43 47 #region Problem Configuration 44 48 45 var problem = new HeuristicLab.Problems.LawnMower.Problem();49 var problem = new Problems.GeneticProgramming.LawnMower.Problem(); 46 50 47 51 #endregion -
stable/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPMultiplexerSampleTest.cs
r12009 r13280 24 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 25 25 using HeuristicLab.Persistence.Default.Xml; 26 using HeuristicLab.Problems.DataAnalysis.Symbolic;27 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;28 using HeuristicLab.Problems.Instances.DataAnalysis;29 26 using HeuristicLab.Selection; 30 27 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 51 48 SamplesUtils.RunAlgorithm(osga); 52 49 53 Assert.AreEqual( 0.125, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8);54 Assert.AreEqual( 0.237275390625, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8);55 Assert.AreEqual(1 .181640625, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8);56 Assert.AreEqual( 105500, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"));50 Assert.AreEqual(1856, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8); 51 Assert.AreEqual(1784.76, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8); 52 Assert.AreEqual(1536, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8); 53 Assert.AreEqual(66900, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions")); 57 54 } 58 55 59 56 public static OffspringSelectionGeneticAlgorithm CreateGpMultiplexerSample() { 60 var instanceProvider = new RegressionCSVInstanceProvider(); 61 var regressionImportType = new RegressionImportType(); 62 regressionImportType.TargetVariable = "output"; 63 regressionImportType.TrainingPercentage = 100; 64 var dataAnalysisCSVFormat = new DataAnalysisCSVFormat(); 65 dataAnalysisCSVFormat.Separator = ','; 66 dataAnalysisCSVFormat.VariableNamesAvailable = true; 67 68 var problemData = instanceProvider.ImportData(@"Test Resources\Multiplexer11.csv", regressionImportType, dataAnalysisCSVFormat); 69 problemData.Name = "11-Multiplexer"; 70 71 var problem = new SymbolicRegressionSingleObjectiveProblem(); 57 var problem = new HeuristicLab.Problems.GeneticProgramming.Boolean.MultiplexerProblem(); 72 58 problem.Name = "11-Multiplexer Problem"; 73 problem.ProblemData = problemData; 74 problem.MaximumSymbolicExpressionTreeLength.Value = 50; 75 problem.MaximumSymbolicExpressionTreeDepth.Value = 50; 76 problem.EvaluatorParameter.Value = new SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator(); 77 problem.ApplyLinearScaling.Value = false; 78 79 80 var grammar = new FullFunctionalExpressionGrammar(); 81 problem.SymbolicExpressionTreeGrammar = grammar; 82 foreach (var symbol in grammar.Symbols) { 83 if (symbol is ProgramRootSymbol) symbol.Enabled = true; 84 else if (symbol is StartSymbol) symbol.Enabled = true; 85 else if (symbol is IfThenElse) symbol.Enabled = true; 86 else if (symbol is And) symbol.Enabled = true; 87 else if (symbol is Or) symbol.Enabled = true; 88 else if (symbol is Xor) symbol.Enabled = true; 89 else if (symbol.GetType() == typeof(Variable)) { 90 //necessary as there are multiple classes derived from Variable (e.g., VariableCondition) 91 symbol.Enabled = true; 92 var variableSymbol = (Variable)symbol; 93 variableSymbol.MultiplicativeWeightManipulatorSigma = 0.0; 94 variableSymbol.WeightManipulatorSigma = 0.0; 95 variableSymbol.WeightSigma = 0.0; 96 } else symbol.Enabled = false; 97 } 59 problem.Encoding.TreeLength = 50; 60 problem.Encoding.TreeDepth = 50; 98 61 99 62 var osga = new OffspringSelectionGeneticAlgorithm();
Note: See TracChangeset
for help on using the changeset viewer.