Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11981


Ignore:
Timestamp:
02/11/15 20:11:35 (10 years ago)
Author:
gkronber
Message:

#2283: cleanup and included HeuristicLab.dlls to create a self-contained branch

Location:
branches/HeuristicLab.Problems.GrammaticalOptimization
Files:
38 added
5 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/GrammaticalOptimization.sln

    r11865 r11981  
    2121EndProject
    2222Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{8B4C199E-C08B-479E-9B82-6AE5B113459E}"
     23EndProject
     24Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HeuristicLab", "HeuristicLab", "{FE0B0799-C3D4-407C-9DD2-899BCDA7AB9A}"
     25  ProjectSection(SolutionItems) = preProject
     26    HeuristicLab\ALGLIB-3.7.0.dll = HeuristicLab\ALGLIB-3.7.0.dll
     27    HeuristicLab\AutoDiff-1.0.dll = HeuristicLab\AutoDiff-1.0.dll
     28    HeuristicLab\HeuristicLab.Algorithms.Bandits.dll = HeuristicLab\HeuristicLab.Algorithms.Bandits.dll
     29    HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll = HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll
     30    HeuristicLab\HeuristicLab.Algorithms.GeneticProgramming.dll = HeuristicLab\HeuristicLab.Algorithms.GeneticProgramming.dll
     31    HeuristicLab\HeuristicLab.Algorithms.GrammaticalOptimization.dll = HeuristicLab\HeuristicLab.Algorithms.GrammaticalOptimization.dll
     32    HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll = HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll
     33    HeuristicLab\HeuristicLab.Analysis-3.3.dll = HeuristicLab\HeuristicLab.Analysis-3.3.dll
     34    HeuristicLab\HeuristicLab.Collections-3.3.dll = HeuristicLab\HeuristicLab.Collections-3.3.dll
     35    HeuristicLab\HeuristicLab.Common-3.3.dll = HeuristicLab\HeuristicLab.Common-3.3.dll
     36    HeuristicLab\HeuristicLab.Common.dll = HeuristicLab\HeuristicLab.Common.dll
     37    HeuristicLab\HeuristicLab.Common.Resources-3.3.dll = HeuristicLab\HeuristicLab.Common.Resources-3.3.dll
     38    HeuristicLab\HeuristicLab.Core-3.3.dll = HeuristicLab\HeuristicLab.Core-3.3.dll
     39    HeuristicLab\HeuristicLab.Data-3.3.dll = HeuristicLab\HeuristicLab.Data-3.3.dll
     40    HeuristicLab\HeuristicLab.Distributions.dll = HeuristicLab\HeuristicLab.Distributions.dll
     41    HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll = HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll
     42    HeuristicLab\HeuristicLab.Operators-3.3.dll = HeuristicLab\HeuristicLab.Operators-3.3.dll
     43    HeuristicLab\HeuristicLab.Operators.Programmable-3.3.dll = HeuristicLab\HeuristicLab.Operators.Programmable-3.3.dll
     44    HeuristicLab\HeuristicLab.Optimization-3.3.dll = HeuristicLab\HeuristicLab.Optimization-3.3.dll
     45    HeuristicLab\HeuristicLab.Optimization.Operators-3.3.dll = HeuristicLab\HeuristicLab.Optimization.Operators-3.3.dll
     46    HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll = HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll
     47    HeuristicLab\HeuristicLab.Parameters-3.3.dll = HeuristicLab\HeuristicLab.Parameters-3.3.dll
     48    HeuristicLab\HeuristicLab.Persistence-3.3.dll = HeuristicLab\HeuristicLab.Persistence-3.3.dll
     49    HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll = HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll
     50    HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll = HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll
     51    HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.dll = HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.dll
     52    HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.dll = HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.dll
     53    HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll = HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll
     54    HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll = HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll
     55    HeuristicLab\HeuristicLab.Random-3.3.dll = HeuristicLab\HeuristicLab.Random-3.3.dll
     56    HeuristicLab\HeuristicLab.Selection-3.3.dll = HeuristicLab\HeuristicLab.Selection-3.3.dll
     57    HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll = HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll
     58    HeuristicLab\HeuristicLab.Tracing-3.3.dll = HeuristicLab\HeuristicLab.Tracing-3.3.dll
     59  EndProjectSection
    2360EndProject
    2461Global
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/UCTPolicy.cs

    r11806 r11981  
    1919    public int SelectAction(Random random, IEnumerable<IBanditPolicyActionInfo> actionInfos) {
    2020      var myActionInfos = actionInfos.OfType<DefaultPolicyActionInfo>();
    21       int bestAction = -1;
    2221      double bestQ = double.NegativeInfinity;
    2322      int totalTries = myActionInfos.Sum(a => a.Tries);
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj

    r11896 r11981  
    3131  </PropertyGroup>
    3232  <ItemGroup>
    33     <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3">
    34       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
     33    <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     34      <SpecificVersion>False</SpecificVersion>
     35      <HintPath>..\HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
    3536    </Reference>
    36     <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3">
    37       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
     37    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     38      <SpecificVersion>False</SpecificVersion>
     39      <HintPath>..\HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
    3840    </Reference>
    3941    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4042      <SpecificVersion>False</SpecificVersion>
    41       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     43      <HintPath>..\HeuristicLab\HeuristicLab.Analysis-3.3.dll</HintPath>
    4244    </Reference>
    43     <Reference Include="HeuristicLab.Collections-3.3">
    44       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     45    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     46      <SpecificVersion>False</SpecificVersion>
     47      <HintPath>..\HeuristicLab\HeuristicLab.Collections-3.3.dll</HintPath>
    4548    </Reference>
    46     <Reference Include="HeuristicLab.Common-3.3">
    47       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     49    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     50      <SpecificVersion>False</SpecificVersion>
     51      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
    4852    </Reference>
    49     <Reference Include="HeuristicLab.Core-3.3">
    50       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     53    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     54      <SpecificVersion>False</SpecificVersion>
     55      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
    5156    </Reference>
    52     <Reference Include="HeuristicLab.Data-3.3">
    53       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     57    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     58      <SpecificVersion>False</SpecificVersion>
     59      <HintPath>..\HeuristicLab\HeuristicLab.Data-3.3.dll</HintPath>
    5460    </Reference>
    55     <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
    56       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     61    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     62      <SpecificVersion>False</SpecificVersion>
     63      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
    5764    </Reference>
    58     <Reference Include="HeuristicLab.Operators-3.3">
    59       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     65    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     66      <SpecificVersion>False</SpecificVersion>
     67      <HintPath>..\HeuristicLab\HeuristicLab.Operators-3.3.dll</HintPath>
    6068    </Reference>
    61     <Reference Include="HeuristicLab.Optimization-3.3">
    62       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     69    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     70      <SpecificVersion>False</SpecificVersion>
     71      <HintPath>..\HeuristicLab\HeuristicLab.Optimization-3.3.dll</HintPath>
    6372    </Reference>
    64     <Reference Include="HeuristicLab.ParallelEngine-3.3">
    65       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.ParallelEngine-3.3.dll</HintPath>
     73    <Reference Include="HeuristicLab.ParallelEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     74      <SpecificVersion>False</SpecificVersion>
     75      <HintPath>..\HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll</HintPath>
    6676    </Reference>
    67     <Reference Include="HeuristicLab.Parameters-3.3">
    68       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     77    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     78      <SpecificVersion>False</SpecificVersion>
     79      <HintPath>..\HeuristicLab\HeuristicLab.Parameters-3.3.dll</HintPath>
    6980    </Reference>
    7081    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    7182      <SpecificVersion>False</SpecificVersion>
    72       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     83      <HintPath>..\HeuristicLab\HeuristicLab.Persistence-3.3.dll</HintPath>
    7384    </Reference>
    7485    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    7586      <SpecificVersion>False</SpecificVersion>
    76       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     87      <HintPath>..\HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    7788    </Reference>
    78     <Reference Include="HeuristicLab.Selection-3.3">
    79       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
     89    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     90      <SpecificVersion>False</SpecificVersion>
     91      <HintPath>..\HeuristicLab\HeuristicLab.Selection-3.3.dll</HintPath>
    8092    </Reference>
    81     <Reference Include="HeuristicLab.SequentialEngine-3.3">
    82       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
     93    <Reference Include="HeuristicLab.SequentialEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     94      <SpecificVersion>False</SpecificVersion>
     95      <HintPath>..\HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
    8396    </Reference>
    8497    <Reference Include="System" />
     
    98111  <ItemGroup>
    99112    <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj">
    100       <Project>{eea07488-1a51-412a-a52c-53b754a628b3}</Project>
     113      <Project>{EEA07488-1A51-412A-A52C-53B754A628B3}</Project>
    101114      <Name>HeuristicLab.Algorithms.GrammaticalOptimization</Name>
    102115    </ProjectReference>
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization.csproj

    r11850 r11981  
    3939  <ItemGroup>
    4040    <Compile Include="ISequentialDecisionPolicy.cs" />
    41     <Compile Include="SequentialDecisionPolicies\GenericContextualGrammarPolicy.cs" />
    4241    <Compile Include="SequentialDecisionPolicies\GenericFunctionApproximationGrammarPolicy.cs" />
    4342    <Compile Include="SequentialDecisionPolicies\GenericGrammarPolicy.cs" />
    44     <Compile Include="SequentialDecisionPolicies\GenericTDPolicy.cs" />
    4543    <Compile Include="SequentialDecisionPolicies\GrammarPolicy.cs" />
    4644    <Compile Include="SequentialDecisionPolicies\IGrammarPolicy.cs" />
    4745    <Compile Include="SequentialDecisionPolicies\RandomPolicy.cs" />
    48     <Compile Include="SequentialDecisionPolicies\TDPolicy.cs" />
    4946    <Compile Include="SolverBase.cs" />
    5047    <Compile Include="ISolver.cs" />
    5148    <Compile Include="Properties\AssemblyInfo.cs" />
    52     <Compile Include="Solvers\AlternativesContextSampler.cs" />
    53     <Compile Include="Solvers\AlternativesSampler.cs" />
    5449    <Compile Include="Solvers\ExhaustiveBreadthFirstSearch.cs" />
    5550    <Compile Include="Solvers\ExhaustiveDepthFirstSearch.cs" />
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericFunctionApproximationGrammarPolicy.cs

    r11980 r11981  
    6060        originalIdx++;
    6161      }
    62 
    63      
    64       /*
    65       const double beta = 10;
    66       var w = from idx in Enumerable.Range(0, maxIdx)
    67               let afterStateQ = activeAfterStates[idx]
    68               select Math.Exp(beta * afterStateQ);
    69 
    70       var bestAction = Enumerable.Range(0, maxIdx).SampleProportional(random, w);
    71       selectedStateIdx = actionIndexMap[bestAction];
    72       Debug.Assert(selectedStateIdx >= 0);
    73       */
    7462     
    7563     
    76       if (random.NextDouble() < 0.5) {
     64      // TODO: policy should be a parameter of the function approximation policy
     65      if (random.NextDouble() < 0.2) {
    7766        selectedStateIdx = actionIndexMap[random.Next(maxIdx)];
    7867      } else {
     
    139128    private void UpdateWeights(string state, double reward) {
    140129      double delta = reward - GetValue(state);
    141       // delta /= problem.GetFeatures(state).Count();
    142       //const double alpha = 0.001;
    143130      foreach (var feature in problem.GetFeatures(state)) {
    144131        featureTries[feature.Id] = GetFeatureTries(feature.Id) + 1;
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ConsoleEx.cs

    r11806 r11981  
    1010namespace HeuristicLab.Common {
    1111  // for controlling console colors
     12  // see output of Solvers (PrintStats)
    1213  // http://stackoverflow.com/questions/25274019/strange-setconsolescreenbufferinfoex-behavior
    1314  public class ConsoleEx {
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ExpressionExtender.cs

    r11972 r11981  
    1111namespace HeuristicLab.Algorithms.Bandits {
    1212  // helper to create canonical forms of expressions
     13  // NOTE: Not implemented yet (see unit test for divisions)
    1314  // TODO: change symbolicregressionpoly10problem to use this class
    1415  // this does not support expressions with constants (in transformations we assume constant opt is used)
     
    3031
    3132    public string CanonicalRepresentation(string phrase) {
     33      throw new NotImplementedException();
    3234      InitLex(phrase);
    3335      var e = CanonicalExpr();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/HeuristicLab.Distributions.csproj

    r11851 r11981  
    3131  </PropertyGroup>
    3232  <ItemGroup>
    33     <Reference Include="ALGLIB-3.7.0">
    34       <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
     33    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     34      <SpecificVersion>False</SpecificVersion>
     35      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
    3536    </Reference>
    3637    <Reference Include="System" />
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj

    r11851 r11981  
    3131  </PropertyGroup>
    3232  <ItemGroup>
    33     <Reference Include="ALGLIB-3.7.0">
    34       <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
     33    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     34      <SpecificVersion>False</SpecificVersion>
     35      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
    3536    </Reference>
    3637    <Reference Include="System" />
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj

    r11895 r11981  
    3333    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    3434      <SpecificVersion>False</SpecificVersion>
    35       <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
     35      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
    3636    </Reference>
    37     <Reference Include="AutoDiff-1.0">
    38       <HintPath>..\..\..\trunk\sources\bin\AutoDiff-1.0.dll</HintPath>
     37    <Reference Include="AutoDiff-1.0, Version=1.0.0.14388, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     38      <SpecificVersion>False</SpecificVersion>
     39      <HintPath>..\HeuristicLab\AutoDiff-1.0.dll</HintPath>
    3940    </Reference>
    40     <Reference Include="HeuristicLab.Common-3.3">
    41       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     41    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     42      <SpecificVersion>False</SpecificVersion>
     43      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
    4244    </Reference>
    43     <Reference Include="HeuristicLab.Core-3.3">
    44       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     45    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     46      <SpecificVersion>False</SpecificVersion>
     47      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
    4548    </Reference>
    4649    <Reference Include="HeuristicLab.Data-3.3">
    47       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     50      <HintPath>..\HeuristicLab\HeuristicLab.Data-3.3.dll</HintPath>
    4851    </Reference>
    4952    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5053      <SpecificVersion>False</SpecificVersion>
    51       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     54      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
    5255    </Reference>
    53     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
    54       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
     56    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     57      <SpecificVersion>False</SpecificVersion>
     58      <HintPath>..\HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
    5559    </Reference>
    56     <Reference Include="HeuristicLab.Problems.Instances-3.3">
    57       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     60    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     61      <SpecificVersion>False</SpecificVersion>
     62      <HintPath>..\HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
    5863    </Reference>
    59     <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3">
    60       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
     64    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     65      <SpecificVersion>False</SpecificVersion>
     66      <HintPath>..\HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
    6167    </Reference>
    6268    <Reference Include="System" />
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs

    r11972 r11981  
    158158    public double OptimizeConstantsAndEvaluate(string sentence) {
    159159      AutoDiff.Term func;
    160       int pos = 0;
    161160      int n = x.GetLength(0);
    162161      int m = x.GetLength(1);
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/ExpressionInterpreter.cs

    r11895 r11981  
    8080        } else {
    8181          NewSy();
    82           throw new NotImplementedException();
    83           // var e = Expr(d, erc);
    84           // r = Not(r) * e + r * Not(e); // xor = (!x AND y) OR (x AND !y)
     82          var e = Expr(d, erc);
     83          r = Not(r) * e + r * Not(e); // xor = (!x AND y) OR (x AND !y)
    8584        }
    8685        curSy = CurSy();
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj

    r11972 r11981  
    3434  </PropertyGroup>
    3535  <ItemGroup>
    36     <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     36    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    3737      <SpecificVersion>False</SpecificVersion>
    38       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     38      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
    3939    </Reference>
    40     <Reference Include="HeuristicLab.Common-3.3">
    41       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     40    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     41      <SpecificVersion>False</SpecificVersion>
     42      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
    4243    </Reference>
    43     <Reference Include="HeuristicLab.Core-3.3">
    44       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    45     </Reference>
    46     <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     44    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4745      <SpecificVersion>False</SpecificVersion>
    48       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
    49     </Reference>
    50     <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
    51       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
    52     </Reference>
    53     <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    54       <SpecificVersion>False</SpecificVersion>
    55       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
    56     </Reference>
    57     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    58       <SpecificVersion>False</SpecificVersion>
    59       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
    60     </Reference>
    61     <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    62       <SpecificVersion>False</SpecificVersion>
    63       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
    64     </Reference>
    65     <Reference Include="HeuristicLab.Persistence-3.3">
    66       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
    67     </Reference>
    68     <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    69       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     46      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
    7047    </Reference>
    7148    <Reference Include="System" />
    7249    <Reference Include="System.Core" />
    73     <Reference Include="System.Drawing" />
    7450  </ItemGroup>
    7551  <ItemGroup>
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs

    r11980 r11981  
    140140      var isTerminal = grammar.IsTerminal(phrase);
    141141
    142 
    143142      yield return new Feature(isTerminal + ToString(), 1.0);
    144       //if (phrase.Length > 0) {
    145       //  var ant = new Ant(recordTrail: true);
    146       //  int pos = 0;
    147       //  Run(ant, phrase, ref pos, true);
    148       //  //yield return new Feature("food", ant.FoodEaten);
    149       //  yield return new Feature(ant.Trail, 1.0);
    150       //}
    151       //yield return new Feature(isTerminal + "const", 0.0);
    152       //yield return new Feature(isTerminal.ToString() + phrase.Length, 1.0);
    153       //int ntIdx;
    154       //for (ntIdx = 0; ntIdx < phrase.Length; ntIdx++) if (grammar.IsNonTerminal(phrase[ntIdx])) break;
    155       //for (int l = ntIdx-2; l >= 0; l--) {
    156       //  yield return new Feature(phrase.Substring(l, ntIdx-l-1), 1.0);
    157       //}
    158       //
     143     
    159144      yield return new Feature("$" + (phrase.Length > 0 ? phrase[0] : ' '), 1.0);
    160145      if (!isTerminal) {
     
    166151        }
    167152      }
    168       // var d = 0;
    169       // var ls = 0;
    170       // var rs = 0;
    171       // var qs = 0;
    172       // foreach (var ch in phrase) if (ch == 'l') { d--; ls++; } else if (ch == 'r') { d++; rs++; } else if (ch == '?') qs++;
    173       // yield return new Feature(isTerminal + "D" + Math.Abs(d), 1.0);
    174       // yield return new Feature(isTerminal + "R" + rs, 1.0);
    175       // yield return new Feature(isTerminal + "L" + ls, 1.0);
    176       // yield return new Feature(isTerminal + "?" + qs, 1.0);
    177 
     153   
    178154      yield return new Feature(phrase, 1.0);
    179       //for (int i = 0; i < phrase.Length; i++)
    180       //  yield return new Feature(i.ToString() + phrase[i].ToString(), 1.0);
    181       // yield return new Feature("Length", phrase.Length); //
    182       // foreach (var pair in phrase.Zip(phrase.Skip(1), Tuple.Create)) {
    183       //   yield return new Feature(pair.Item1.ToString() + pair.Item2, 1.0);
    184       // }
    185       // number of occurances for each symbol
    186155    }
    187156
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Main.csproj

    r11977 r11981  
    4848      <Name>HeuristicLab.Algorithms.Bandits</Name>
    4949    </ProjectReference>
    50     <ProjectReference Include="..\HeuristicLab.Algorithms.GeneticProgramming\HeuristicLab.Algorithms.GeneticProgramming.csproj">
    51       <Project>{14BEC23F-63FD-4954-B8AE-E2F4962E9B57}</Project>
    52       <Name>HeuristicLab.Algorithms.GeneticProgramming</Name>
    53     </ProjectReference>
    5450    <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj">
    5551      <Project>{eea07488-1a51-412a-a52c-53b754a628b3}</Project>
    5652      <Name>HeuristicLab.Algorithms.GrammaticalOptimization</Name>
    57     </ProjectReference>
    58     <ProjectReference Include="..\HeuristicLab.Common\HeuristicLab.Common.csproj">
    59       <Project>{3A2FBBCB-F9DF-4970-87F3-F13337D941AD}</Project>
    60       <Name>HeuristicLab.Common</Name>
    61     </ProjectReference>
    62     <ProjectReference Include="..\HeuristicLab.Distributions\HeuristicLab.Distributions.csproj">
    63       <Project>{31171165-E16F-4A1A-A8AB-25C6AB3A71B9}</Project>
    64       <Name>HeuristicLab.Distributions</Name>
    65     </ProjectReference>
    66     <ProjectReference Include="..\HeuristicLab.Problems.GrammaticalOptimization.SymbReg\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj">
    67       <Project>{17A7A380-86CE-482D-8D22-CBD70CC97F0D}</Project>
    68       <Name>HeuristicLab.Problems.GrammaticalOptimization.SymbReg</Name>
    6953    </ProjectReference>
    7054    <ProjectReference Include="..\HeuristicLab.Problems.GrammaticalOptimization\HeuristicLab.Problems.GrammaticalOptimization.csproj">
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs

    r11980 r11981  
    11using System;
    2 using System.Collections.Generic;
    32using System.Diagnostics;
    43using System.Globalization;
    5 using System.Runtime.Remoting.Messaging;
    6 using System.Text;
    7 using System.Threading;
    8 using System.Threading.Tasks;
    9 using HeuristicLab.Algorithms.Bandits;
    104using HeuristicLab.Algorithms.Bandits.BanditPolicies;
    11 using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
    12 using HeuristicLab.Algorithms.Bandits.Models;
    13 using HeuristicLab.Algorithms.GeneticProgramming;
    145using HeuristicLab.Algorithms.GrammaticalOptimization;
    15 using HeuristicLab.Common;
    166using HeuristicLab.Problems.GrammaticalOptimization;
    17 using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
    18 using BoltzmannExplorationPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.BoltzmannExplorationPolicy;
    19 using EpsGreedyPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.EpsGreedyPolicy;
    20 using IProblem = HeuristicLab.Problems.GrammaticalOptimization.IProblem;
    21 using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy;
    22 using UCTPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.UCTPolicy;
     7
     8// NOTES: gkronber
     9// TODO: feature extraction for full symbolic expressions and experiment for all benchmark problems
     10// TODO: why does GaussianThompsonSampling work so well with MCTS for the artificial ant problem?
     11// TODO: research thompson sampling for max bandit?
     12// TODO: verify TA implementation using example from the original paper     
     13// TODO: implement thompson sampling for gaussian mixture models
     14// TODO: gleichzeitige modellierung von transformierter zielvariable (y, 1/y, log(y), exp(y), sqrt(y), ...)
     15// TODO: vergleich bei complete-randomly möglichst kurze sÀtze generieren vs. einfach zufÀllig alternativen wÀhlen
     16// TODO: reward discounting (fÃŒr verÀnderliche reward distributions ÃŒber zeit). speziellen unit-test dafÃŒr erstellen
     17// TODO: constant optimization
     18
    2319
    2420namespace Main {
     
    2723      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
    2824
    29       //RunDemo();
    30       //RunGpDemo();
    31       // RunGridTest();
    32       //RunGpGridTest();
    33       RunFunApproxTest();
     25      RunDemo();
    3426    }
    3527
    36     private static void RunGridTest() {
    37       int maxIterations = 200000; // for poly-10 with 50000 evaluations no successful try with hl yet
    38       //var globalRandom = new Random(31415);
    39       var localRandSeed = new Random().Next();
    40       var reps = 20;
    41 
    42       var policyFactories = new Func<IBanditPolicy>[]
    43         {
    44          //() => new RandomPolicy(),
    45          // () => new ActiveLearningPolicy(), 
    46          //() => new EpsGreedyPolicy(0.01, (aInfo)=> aInfo.MaxReward, "max"),
    47          //() => new EpsGreedyPolicy(0.05, (aInfo)=> aInfo.MaxReward, "max"),
    48          //() => new EpsGreedyPolicy(0.1, (aInfo)=> aInfo.MaxReward, "max"),
    49          //() => new EpsGreedyPolicy(0.2, (aInfo)=> aInfo.MaxReward, "max"),
    50          ////() => new GaussianThompsonSamplingPolicy(),
    51          //() => new GaussianThompsonSamplingPolicy(true),
    52          //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1)),
    53          //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1, 1)),
    54          ////() => new BernoulliThompsonSamplingPolicy(),
    55          //() => new GenericThompsonSamplingPolicy(new BernoulliModel(1, 1)),
    56          //() => new EpsGreedyPolicy(0.01),
    57          //() => new EpsGreedyPolicy(0.05),
    58          //() => new EpsGreedyPolicy(0.1),
    59          //() => new EpsGreedyPolicy(0.2),
    60          //() => new EpsGreedyPolicy(0.5),
    61          //() => new UCTPolicy(0.01),
    62          //() => new UCTPolicy(0.05),
    63          //() => new UCTPolicy(0.1),
    64          //() => new UCTPolicy(0.5),
    65          //() => new UCTPolicy(1),
    66          //() => new UCTPolicy(2),
    67          //() => new UCTPolicy( 5),
    68          //() => new UCTPolicy( 10),
    69          //() => new ModifiedUCTPolicy(0.01),
    70          //() => new ModifiedUCTPolicy(0.05),
    71          //() => new ModifiedUCTPolicy(0.1),
    72          //() => new ModifiedUCTPolicy(0.5),
    73          //() => new ModifiedUCTPolicy(1),
    74          //() => new ModifiedUCTPolicy(2),
    75          //() => new ModifiedUCTPolicy( 5),
    76          //() => new ModifiedUCTPolicy( 10),
    77          //() => new UCB1Policy(),
    78          //() => new UCB1TunedPolicy(),
    79          //() => new UCBNormalPolicy(),
    80          //() => new BoltzmannExplorationPolicy(1),
    81          //() => new BoltzmannExplorationPolicy(10),
    82          //() => new BoltzmannExplorationPolicy(20),
    83          //() => new BoltzmannExplorationPolicy(100),
    84          //() => new BoltzmannExplorationPolicy(200),
    85          //() => new BoltzmannExplorationPolicy(500),
    86          // () => new ChernoffIntervalEstimationPolicy( 0.01),
    87          // () => new ChernoffIntervalEstimationPolicy( 0.05),
    88          // () => new ChernoffIntervalEstimationPolicy( 0.1),
    89          // () => new ChernoffIntervalEstimationPolicy( 0.2),
    90          //() => new ThresholdAscentPolicy(5, 0.01),
    91          //() => new ThresholdAscentPolicy(5, 0.05),
    92          //() => new ThresholdAscentPolicy(5, 0.1),
    93          //() => new ThresholdAscentPolicy(5, 0.2),
    94          //() => new ThresholdAscentPolicy(10, 0.01),
    95          //() => new ThresholdAscentPolicy(10, 0.05),
    96          //() => new ThresholdAscentPolicy(10, 0.1),
    97          //() => new ThresholdAscentPolicy(10, 0.2),
    98          //() => new ThresholdAscentPolicy(50, 0.01),
    99          //() => new ThresholdAscentPolicy(50, 0.05),
    100          //() => new ThresholdAscentPolicy(50, 0.1),
    101          //() => new ThresholdAscentPolicy(50, 0.2),
    102          //() => new ThresholdAscentPolicy(100, 0.01),
    103          () => new ThresholdAscentPolicy(100, 0.05),
    104          //() => new ThresholdAscentPolicy(100, 0.1),
    105          //() => new ThresholdAscentPolicy(100, 0.2),
    106          //() => new ThresholdAscentPolicy(500, 0.01),
    107          //() => new ThresholdAscentPolicy(500, 0.05),
    108          //() => new ThresholdAscentPolicy(500, 0.1),
    109          //() => new ThresholdAscentPolicy(500, 0.2),
    110          //() => new ThresholdAscentPolicy(5000, 0.01),
    111          //() => new ThresholdAscentPolicy(10000, 0.01),
    112         };
    113 
    114       var instanceFactories = new Func<Random, Tuple<IProblem, int>>[]
    115       {
    116         //(rand) => Tuple.Create((IProblem)new SantaFeAntProblem(), 17),
    117         //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:false ), 15),
    118         //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:true ), 15),
    119         //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:false), 15),
    120         //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:true), 15),
    121         (rand) => Tuple.Create((IProblem)new SymbolicRegressionPoly10Problem(), 23)
    122       };
    123 
    124       foreach (var instanceFactory in instanceFactories) {
    125         foreach (var useCanonical in new bool[] { true /*, false */ }) {
    126           foreach (var randomTries in new int[] { 1 /*, 1, 10 /*, /* 5, 100 /*, 500, 1000 */}) {
    127             foreach (var policyFactory in policyFactories) {
    128               var myRandomTries = randomTries;
    129               var localRand = new Random(localRandSeed);
    130               var options = new ParallelOptions();
    131               options.MaxDegreeOfParallelism = 1;
    132               Parallel.For(0, reps, options, (i) => {
    133                 Random myLocalRand;
    134                 lock (localRand)
    135                   myLocalRand = new Random(localRand.Next());
    136 
    137                 int iterations = 0;
    138                 var globalStatistics = new SentenceSetStatistics();
    139 
    140                 // var problem = new SymbolicRegressionPoly10Problem();
    141                 // var problem = new SantaFeAntProblem();
    142                 //var problem = new PalindromeProblem();
    143                 //var problem = new HardPalindromeProblem();
    144                 //var problem = new RoyalPairProblem();
    145                 //var problem = new EvenParityProblem();
    146                 // var alg = new MctsSampler(problem.Item1, problem.Item2, myLocalRand, myRandomTries, policy());
    147                 var instance = instanceFactory(myLocalRand);
    148                 var problem = instance.Item1;
    149                 var maxLen = instance.Item2;
    150                 var alg = new SequentialSearch(problem, maxLen, myLocalRand, myRandomTries,
    151                   new GenericGrammarPolicy(problem, policyFactory(), useCanonical));
    152                 // var alg = new SequentialSearch(problem, maxLen, myLocalRand,
    153                 //   myRandomTries,
    154                 //   new GenericFunctionApproximationGrammarPolicy(problem,
    155                 //     useCanonical));
    156                 //var alg = new ExhaustiveBreadthFirstSearch(problem, 25);
    157                 //var alg = new AlternativesContextSampler(problem, 25);
    158 
    159                 alg.SolutionEvaluated += (sentence, quality) => {
    160                   iterations++;
    161                   globalStatistics.AddSentence(sentence, quality);
    162                   if (iterations % 1000 == 0) {
    163                     Console.WriteLine("{0,3} {1,5} \"{2,25}\" {3} {4} {5}", i, myRandomTries, policyFactory(), useCanonical, problem.ToString(), globalStatistics);
    164                   }
    165                 };
    166                 alg.FoundNewBestSolution += (sentence, quality) => {
    167                   //Console.WriteLine("{0,5} {1,25} {2} {3}",
    168                   //  myRandomTries, policyFactory(), useCanonical,
    169                   //  globalStatistics);
    170                 };
    171 
    172                 alg.Run(maxIterations);
    173               });
    174             }
    175           }
    176         }
    177       }
    178     }
    17928
    18029    private static void RunDemo() {
    181       // TODO: cleanup nach EuroCAST
    182       // TODO: why does GaussianThompsonSampling work so well with MCTS for the artificial ant problem?
    183       // TODO: research thompson sampling for max bandit?
    184       // TODO: verify TA implementation using example from the original paper     
    185       // TODO: implement thompson sampling for gaussian mixture models
    186       // TODO: gleichzeitige modellierung von transformierter zielvariable (y, 1/y, log(y), exp(y), sqrt(y), ...)
    187       // TODO: vergleich bei complete-randomly möglichst kurze sÀtze generieren vs. einfach zufÀllig alternativen wÀhlen
    188       // TODO: reward discounting (fÃŒr verÀnderliche reward distributions ÃŒber zeit). speziellen unit-test dafÃŒr erstellen
    189       // TODO: constant optimization
    19030
    19131
    192       int maxIterations = 1000000;
     32      int maxIterations = 100000;
    19333      int iterations = 0;
    194       var sw = new Stopwatch();
    19534
    19635      var globalStatistics = new SentenceSetStatistics();
    19736      var random = new Random();
    19837
    199 
    200       //var problem = new RoyalSequenceProblem(random, 10, 30, 2, 1, 0);
    201       // var phraseLen = 3;
    202       // var numPhrases = 5;
    203       // var problem = new RoyalPhraseSequenceProblem(random, 10, numPhrases, phraseLen: phraseLen, numCorrectPhrases: 1, correctReward: 1, incorrectReward: 0.0, phrasesAsSets: false);
    204 
    205       //var phraseLen = 3;
    206       //var numPhrases = 5;
    207       //var problem = new FindPhrasesProblem(random, 10, numPhrases, phraseLen, numOptimalPhrases: numPhrases, numDecoyPhrases: 0, correctReward: 1.0, decoyReward: 0, phrasesAsSets: false);
    208 
    209       // good results for symb-reg
    210       // prev results: e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
    211       // 2015 01 19: grid test with canonical states:
    212       // - EpsGreedyPolicy(0.20,max)
    213       // - GenericThompsonSamplingPolicy("")
    214       // - UCTPolicy(0.10) (5 of 5 runs, 35000 iters avg.), 10 successful runs of 10 with rand-tries 0, bei 40000 iters 9 / 10, bei 30000 1 / 10
    215       // 2015 01 22: symb-reg: grid test on find-phrases problem showed good results for UCB1TunedPolicy and SequentialSearch with canonical states
    216       // - symb-reg: consistent results with UCB1Tuned. finds optimal solution in ~50k iters (new GenericGrammarPolicy(problem, new UCB1TunedPolicy(), true));
    217       // 2015 01 23: grid test with canonical states:
    218       // - UCTPolicy(0.10) und UCBNormalPolicy 10/10 optimale Lösungen bei max. 50k iters, etwas schlechter: generic-thompson with variable sigma und bolzmannexploration (100)
    219 
    220 
    221       // good results for artificial ant:
    222       // prev results:
    223       // - var alg = new MctsSampler(problem, 17, random, 1, (rand, numActions) => new ThresholdAscentPolicy(numActions, 500, 0.01));
    224       // - GaussianModelWithUnknownVariance (and Q= 0.99-quantil) also works well for Ant
    225       // 2015 01 19: grid test with canonical states (non-canonical slightly worse)
    226       // - ant: Threshold Ascent (best 100, 0.01; all variants relatively good)
    227       // - ant: Policies where the variance has a large weight compared to the mean? (Gaussian(compatible), Gaussian with fixed variance, UCT with large c, alle TA)
    228       // - ant: UCB1Tuned with canonical states also works very well for the artificial ant! constistent solutions in less than 10k iters     
    229 
    230       //var problem = new SymbolicRegressionPoly10Problem();
    231       //var problem = new SantaFeAntProblem();
    232       var problem = new SymbolicRegressionProblem(random, "Breiman");
    233       //var problem = new PalindromeProblem();
    234       //var problem = new HardPalindromeProblem();
     38      var problem = new SymbolicRegressionPoly10Problem();
     39      //var problem = new SantaFeAntProblem();             
    23540      //var problem = new RoyalPairProblem();
    23641      //var problem = new EvenParityProblem();
    237       // symbreg length = 11 q = 0.824522210419616
    238       //var alg = new MctsSampler(problem, 23, random, 0, new BoltzmannExplorationPolicy(100));
    239       //var alg = new MctsSampler(problem, 23, random, 0, new EpsGreedyPolicy(0.1));
    240       //var alg = new SequentialSearch(problem, 23, random, 0,
    241       //  new HeuristicLab.Algorithms.Bandits.GrammarPolicies.QLearningGrammarPolicy(problem, new BoltzmannExplorationPolicy(10),
    242       //    1, 1, true));
    243       //var alg = new SequentialSearch(problem, 23, random, 0,
    244       //  new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericContextualGrammarPolicy(problem, new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1, 1)), true));
    245       var alg = new SequentialSearch(problem, 30, random, 0,
    246         new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericFunctionApproximationGrammarPolicy(problem, true));
    247       //var alg = new MctsQLearningSampler(problem, sentenceLen, random, 0, null);
    248       //var alg = new MctsQLearningSampler(problem, 30, random, 0, new EpsGreedyPolicy(0.2));
    249       //var alg = new MctsContextualSampler(problem, 23, random, 0); // must visit each canonical solution only once
    250       //var alg = new TemporalDifferenceTreeSearchSampler(problem, 30, random, 1);
    251       //var alg = new ExhaustiveBreadthFirstSearch(problem, 7);
    252       //var alg = new AlternativesContextSampler(problem, random, 17, 4, (rand, numActions) => new RandomPolicy(rand, numActions));
    253       //var alg = new ExhaustiveDepthFirstSearch(problem, 17);
    254       // var alg = new AlternativesSampler(problem, 17);
    255       // var alg = new RandomSearch(problem, random, 17);
    256       //var alg = new ExhaustiveRandomFirstSearch(problem, random, 17);
     42      var alg = new SequentialSearch(problem, 23, random, 0,
     43       new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericGrammarPolicy(problem, new UCB1TunedPolicy()));
     44
    25745
    25846      alg.FoundNewBestSolution += (sentence, quality) => {
    25947        //Console.WriteLine("{0}", globalStatistics);
    260         //Console.ReadLine();
    26148      };
     49
    26250      alg.SolutionEvaluated += (sentence, quality) => {
    26351        iterations++;
    26452        globalStatistics.AddSentence(sentence, quality);
    26553
    266         //if (iterations % 100 == 0) {
    267         //  if (iterations % 10000 == 0) Console.Clear();
    268         //  Console.SetCursorPosition(0, 0);
    269         //  alg.PrintStats();
    270         //}
     54        // comment this if you don't want to see solver statistics
     55        if (iterations % 100 == 0) {
     56          if (iterations % 10000 == 0) Console.Clear();
     57          Console.SetCursorPosition(0, 0);
     58          alg.PrintStats();
     59        }
    27160
    272         //Console.WriteLine(sentence);
    273 
    274         if (iterations % 100 == 0) {
    275           Console.WriteLine("{0}", globalStatistics);
    276         }
     61        // uncomment this if you want to collect statistics of the generated sentences
     62        // if (iterations % 1000 == 0) {
     63        //   Console.WriteLine("{0}", globalStatistics);
     64        // }
    27765      };
    27866
    279 
     67      var sw = new Stopwatch();
    28068      sw.Start();
    281 
    28269      alg.Run(maxIterations);
    283 
    28470      sw.Stop();
    28571
     
    29278        (double)sw.ElapsedMilliseconds * 1000 / maxIterations);
    29379    }
    294 
    295     public static void RunGpDemo() {
    296       int iterations = 0;
    297       const int seed = 31415;
    298       const int maxIterations = 100000;
    299 
    300       //var prob = new SymbolicRegressionProblem(new Random(31415), "Tower");
    301       var prob = new SymbolicRegressionPoly10Problem();
    302       var sgp = new OffspringSelectionGP(prob, new Random(seed), true);
    303       RunGP(sgp, prob, 200000, 500, 0.15, 50);
    304     }
    305 
    306 
    307     private static void RunFunApproxTest() {
    308       const int nReps = 30;
    309       const int seed = 31415;
    310       //const int maxIters = 50000;
    311       var rand = new Random();
    312       var problemFactories = new Func<Tuple<int, int, ISymbolicExpressionTreeProblem>>[]
    313       {
    314         () => Tuple.Create(100000, 23,  (ISymbolicExpressionTreeProblem)new SymbolicRegressionPoly10Problem()),
    315         //() => Tuple.Create(100000, 17, (ISymbolicExpressionTreeProblem)new SantaFeAntProblem()),
    316         //() => Tuple.Create(50000, 32,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    317         //() => Tuple.Create(50000, 64, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    318         //() => Tuple.Create(50000, 64,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    319         //() => Tuple.Create(50000, 128, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    320         //() => Tuple.Create(50000, 128,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    321         //() => Tuple.Create(50000, 256, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    322         //() => Tuple.Create(50000, 256,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    323         //() => new RoyalPairProblem(),
    324         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, true),
    325         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, false),
    326         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 50, 1, 0.8, false),
    327       };
    328 
    329       // skip experiments that are already done
    330       for (int i = 0; i < nReps; i++) {
    331         foreach (var problemFactory in problemFactories) {
    332           {
    333             var solverSeed = rand.Next();
    334             var tupel = problemFactory();
    335             var maxIters = tupel.Item1;
    336             var maxSize = tupel.Item2;
    337             var prob = tupel.Item3;
    338 
    339             var alg = new SequentialSearch(prob, maxSize, new Random(solverSeed), 0,
    340           new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericFunctionApproximationGrammarPolicy(prob, true));
    341 
    342             int iterations = 0;
    343             double bestQuality = double.NegativeInfinity;
    344             var globalStatistics = new SentenceSetStatistics();
    345             var algName = alg.GetType().Name;
    346             var probName = prob.GetType().Name;
    347             alg.SolutionEvaluated += (sentence, quality) => {
    348               bestQuality = Math.Max(bestQuality, quality);
    349               iterations++;
    350               globalStatistics.AddSentence(sentence, quality);
    351               //if (iterations % 100 == 0) {
    352               //  Console.Clear();
    353               //  Console.SetCursorPosition(0, 0);
    354               //  alg.PrintStats();
    355               //}
    356               //Console.WriteLine("{0:N5} {1}", quality, sentence);
    357               if (iterations % 1000 == 0) {
    358                 Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", algName, maxSize, probName, globalStatistics);
    359                 if (bestQuality.IsAlmost(1.0)) {
    360                   alg.StopRequested = true;
    361                 }
    362               }
    363             };
    364 
    365             alg.Run(maxIters);
    366 
    367 
    368             while (iterations < maxIters) {
    369               iterations++;
    370               globalStatistics.AddSentence("BEST", bestQuality);
    371               if (iterations % 1000 == 0) {
    372                 Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", algName, maxSize, probName, globalStatistics);
    373                 if (bestQuality.IsAlmost(1.0)) {
    374                   alg.StopRequested = true;
    375                 }
    376               }
    377             }
    378           }
    379         }
    380       }
    381     }
    382 
    383     private static void RunGpGridTest() {
    384       const int nReps = 20;
    385       const int seed = 31415;
    386       //const int maxIters = 50000;
    387       var rand = new Random(seed);
    388       var problemFactories = new Func<Tuple<int, int, ISymbolicExpressionTreeProblem>>[]
    389       {
    390         () => Tuple.Create(50000, 32, (ISymbolicExpressionTreeProblem)new PermutationProblem()),
    391         () => Tuple.Create(50000, 32, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    392         () => Tuple.Create(50000, 32,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    393         () => Tuple.Create(50000, 64, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    394         () => Tuple.Create(50000, 64,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    395         () => Tuple.Create(50000, 128, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    396         () => Tuple.Create(50000, 128,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    397         () => Tuple.Create(50000, 256, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()),
    398         () => Tuple.Create(50000, 256,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()),
    399         //() => new RoyalPairProblem(),
    400         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, true),
    401         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, false),
    402         //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 50, 1, 0.8, false),
    403       };
    404 
    405       foreach (var popSize in new int[] { 100 /*, 250, 500, 1000, 2500, 5000, 10000 */ }) {
    406         foreach (var mutationRate in new double[] { /* 0.05, /* 0.10, */ 0.15, /* 0.25, 0.3 */}) {
    407           // skip experiments that are already done
    408           foreach (var problemFactory in problemFactories) {
    409             for (int i = 0; i < nReps; i++) {
    410               {
    411                 var solverSeed = rand.Next();
    412                 var tupel = problemFactory();
    413                 var maxIters = tupel.Item1;
    414                 var maxSize = tupel.Item2;
    415                 var prob = tupel.Item3;
    416                 var sgp = new StandardGP(prob, new Random(solverSeed));
    417                 RunGP(sgp, prob, maxIters, popSize, mutationRate, maxSize);
    418               }
    419               //{
    420               //  var prob = problemFactory();
    421               //  var osgp = new OffspringSelectionGP(prob, new Random(solverSeed));
    422               //  RunGP(osgp, prob, maxIters, popSize, mutationRate, maxSize);
    423               //}
    424             }
    425           }
    426         }
    427 
    428       }
    429     }
    430 
    431     private static void RunGP(IGPSolver gp, ISymbolicExpressionTreeProblem prob, int maxIters, int popSize, double mutationRate, int maxSize) {
    432       int iterations = 0;
    433       var globalStatistics = new SentenceSetStatistics(prob.BestKnownQuality(maxSize));
    434       var gpName = gp.GetType().Name;
    435       var probName = prob.GetType().Name;
    436       gp.SolutionEvaluated += (sentence, quality) => {
    437         iterations++;
    438         globalStatistics.AddSentence(sentence, quality);
    439 
    440         if (iterations % 100 == 0) {
    441           Console.WriteLine("\"{0,25}\" {1} {2:N2} {3} \"{4,25}\" {5}", gpName, popSize, mutationRate, maxSize, probName, globalStatistics);
    442         }
    443       };
    444 
    445       gp.PopulationSize = popSize;
    446       gp.MutationRate = mutationRate;
    447       gp.MaxSolutionSize = maxSize + 2;
    448       gp.MaxSolutionDepth = maxSize + 2;
    449 
    450       gp.Run(maxIters);
    451     }
    45280  }
    45381}
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj

    r11902 r11981  
    3939  </PropertyGroup>
    4040  <ItemGroup>
    41     <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    42       <SpecificVersion>False</SpecificVersion>
    43       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
    44     </Reference>
    45     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    46       <SpecificVersion>False</SpecificVersion>
    47       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    48     </Reference>
    49     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    50       <SpecificVersion>False</SpecificVersion>
    51       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
    52     </Reference>
    5341    <Reference Include="System" />
    5442    <Reference Include="System.Core">
     
    6957  </Choose>
    7058  <ItemGroup>
     59    <Compile Include="RunDemo.cs" />
     60    <Compile Include="RunSequentialSolverFuncApproxExperiments.cs" />
     61    <Compile Include="RunBaselineExperiments.cs" />
     62    <Compile Include="RunGpExperiments.cs" />
    7163    <Compile Include="TestCanonicalExpressions.cs" />
    7264    <Compile Include="TestSymbRegInstances.cs" />
Note: See TracChangeset for help on using the changeset viewer.