Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/15 20:30:44 (10 years ago)
Author:
gkronber
Message:

#2283: solution reorganization

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

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj

    r11850 r11851  
    4747      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    4848    </Reference>
    49     <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     49    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5050      <SpecificVersion>False</SpecificVersion>
    51       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
    52     </Reference>
    53     <Reference Include="HeuristicLab.Problems.Instances-3.3">
    54       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
    55     </Reference>
    56     <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3">
    57       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
     51      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
    5852    </Reference>
    5953    <Reference Include="System" />
     
    8680      <Project>{24408f7d-ee0f-4886-a08b-ec324d662e47}</Project>
    8781      <Name>HeuristicLab.Algorithms.Bandits</Name>
     82    </ProjectReference>
     83    <ProjectReference Include="..\HeuristicLab.Algorithms.GeneticProgramming\HeuristicLab.Algorithms.GeneticProgramming.csproj">
     84      <Project>{14BEC23F-63FD-4954-B8AE-E2F4962E9B57}</Project>
     85      <Name>HeuristicLab.Algorithms.GeneticProgramming</Name>
    8886    </ProjectReference>
    8987    <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj">
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSolvers.cs

    r11730 r11851  
    11using System;
     2using HeuristicLab.Algorithms.GeneticProgramming;
    23using HeuristicLab.Algorithms.GrammaticalOptimization;
    34using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    128129    }
    129130
     131    [TestMethod]
     132    public void TestStandardGP() {
     133      var prob = new SymbolicRegressionPoly10Problem();
     134      var rand = new Random(31415);
     135      var sgp = new StandardGP(prob, rand);
     136      sgp.PopulationSize = 10000;
     137      sgp.MaxSolutionSize = 50;
     138      sgp.MaxSolutionDepth = 20;
     139
     140      string bestSentence = string.Empty;
     141      double bestQuality = double.NegativeInfinity;
     142
     143      sgp.FoundNewBestSolution += (sentence, quality) => {
     144        Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence));
     145        bestSentence = sentence;
     146        bestQuality = quality;
     147      };
     148
     149      sgp.Run(100000);
     150
     151      Assert.AreEqual(1.0, bestQuality, 1E-6);
     152      Assert.AreEqual("", bestSentence);
     153    }
     154
     155    [TestMethod]
     156    public void TestOSGP() {
     157      var prob = new SymbolicRegressionPoly10Problem();
     158      var rand = new Random(31415);
     159      var osgp = new OffspringSelectionGP(prob, rand);
     160      osgp.PopulationSize = 1000;
     161      osgp.MaxSolutionSize = 50;
     162      osgp.MaxSolutionDepth = 20;
     163
     164      string bestSentence = string.Empty;
     165      double bestQuality = double.NegativeInfinity;
     166
     167      osgp.FoundNewBestSolution += (sentence, quality) => {
     168        Assert.Inconclusive(string.Format("{0:N3} {1}", quality, sentence));
     169        bestSentence = sentence;
     170        bestQuality = quality;
     171      };
     172
     173      osgp.Run(100000);
     174
     175      Assert.AreEqual(1.0, bestQuality, 1E-6);
     176      Assert.AreEqual("", bestSentence);
     177    }
    130178  }
    131179}
Note: See TracChangeset for help on using the changeset viewer.