- Timestamp:
- 02/05/15 07:03:15 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization/Test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSolvers.cs
r11851 r11895 2 2 using HeuristicLab.Algorithms.GeneticProgramming; 3 3 using HeuristicLab.Algorithms.GrammaticalOptimization; 4 using HeuristicLab.Problems.GrammaticalOptimization.SymbReg; 4 5 using Microsoft.VisualStudio.TestTools.UnitTesting; 5 6 … … 154 155 155 156 [TestMethod] 156 public void TestOSGP() { 157 var prob = new SymbolicRegressionPoly10Problem(); 157 public void TestOSGP() 158 { 159 const int seed = 31415; 160 var prob = new SymbolicRegressionProblem(new Random(seed), "Tower"); 158 161 var rand = new Random(31415); 159 162 var osgp = new OffspringSelectionGP(prob, rand); 160 osgp.PopulationSize = 1000;161 osgp.MaxSolutionSize = 50;163 osgp.PopulationSize = 500; 164 osgp.MaxSolutionSize = 100; 162 165 osgp.MaxSolutionDepth = 20; 163 166 … … 166 169 167 170 osgp.FoundNewBestSolution += (sentence, quality) => { 168 Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence));171 // Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence)); 169 172 bestSentence = sentence; 170 173 bestQuality = quality; -
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSymbRegInstances.cs
r11832 r11895 1 1 using System; 2 2 using System.Linq; 3 using HeuristicLab.Algorithms.GeneticProgramming; 3 4 using HeuristicLab.Algorithms.GrammaticalOptimization; 4 5 using HeuristicLab.Problems.GrammaticalOptimization.SymbReg; … … 13 14 14 15 var problem = new SymbolicRegressionProblem(new Random(), "Tower"); 15 16 double r2; 17 Assert.AreEqual(problem.Evaluate("a*b"), problem.OptimizeConstantsAndEvaluate("a*b")); 18 Assert.AreEqual(problem.OptimizeConstantsAndEvaluate("a*b"), problem.Evaluate("a*b")); 19 Assert.AreEqual(problem.OptimizeConstantsAndEvaluate("0*a*b"), problem.Evaluate("a*b"), 1E-6); 20 Assert.AreEqual(problem.OptimizeConstantsAndEvaluate("0*a*b+1"), problem.Evaluate("a*b"), 1E-6); 21 Assert.IsTrue(problem.OptimizeConstantsAndEvaluate("0*a+b") >= problem.Evaluate("a+b")); 22 Assert.AreEqual(problem.OptimizeConstantsAndEvaluate("0*a+0*b"), problem.Evaluate("a+b"), 1E-6); 23 Assert.IsTrue(problem.OptimizeConstantsAndEvaluate("0*a+1*b") >= problem.Evaluate("a+b")); 16 24 } 17 25 }
Note: See TracChangeset
for help on using the changeset viewer.