Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/05/15 07:03:15 (10 years ago)
Author:
gkronber
Message:

#2283: constant opt, expressioncompiler, autodiff, fixes in GP solvers

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization/Test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSolvers.cs

    r11851 r11895  
    22using HeuristicLab.Algorithms.GeneticProgramming;
    33using HeuristicLab.Algorithms.GrammaticalOptimization;
     4using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
    45using Microsoft.VisualStudio.TestTools.UnitTesting;
    56
     
    154155
    155156    [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");
    158161      var rand = new Random(31415);
    159162      var osgp = new OffspringSelectionGP(prob, rand);
    160       osgp.PopulationSize = 1000;
    161       osgp.MaxSolutionSize = 50;
     163      osgp.PopulationSize = 500;
     164      osgp.MaxSolutionSize = 100;
    162165      osgp.MaxSolutionDepth = 20;
    163166
     
    166169
    167170      osgp.FoundNewBestSolution += (sentence, quality) => {
    168         Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence));
     171        // Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence));
    169172        bestSentence = sentence;
    170173        bestQuality = quality;
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSymbRegInstances.cs

    r11832 r11895  
    11using System;
    22using System.Linq;
     3using HeuristicLab.Algorithms.GeneticProgramming;
    34using HeuristicLab.Algorithms.GrammaticalOptimization;
    45using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
     
    1314
    1415      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"));
    1624    }
    1725  }
Note: See TracChangeset for help on using the changeset viewer.