Changeset 11851 for branches/HeuristicLab.Problems.GrammaticalOptimization
- Timestamp:
- 02/01/15 20:30:44 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/GrammaticalOptimization.sln
r11850 r11851 3 3 # Visual Studio 2012 4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GrammaticalOptimization", "HeuristicLab.Problems.GrammaticalOptimization\HeuristicLab.Problems.GrammaticalOptimization.csproj", "{CB9DCCF6-667E-4A13-B82D-DBD6B45A045E}" 5 EndProject6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GrammaticalOptimization.Test", "HeuristicLab.Problems.GrammaticalOptimization.Test\HeuristicLab.Problems.GrammaticalOptimization.Test.csproj", "{3FB49880-7127-40D4-A9D3-A6C30BDDE885}"7 5 EndProject 8 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.GrammaticalOptimization", "HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj", "{EEA07488-1A51-412A-A52C-53B754A628B3}" … … 34 32 {CB9DCCF6-667E-4A13-B82D-DBD6B45A045E}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 33 {CB9DCCF6-667E-4A13-B82D-DBD6B45A045E}.Release|Any CPU.Build.0 = Release|Any CPU 36 {3FB49880-7127-40D4-A9D3-A6C30BDDE885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU37 {3FB49880-7127-40D4-A9D3-A6C30BDDE885}.Debug|Any CPU.Build.0 = Debug|Any CPU38 {3FB49880-7127-40D4-A9D3-A6C30BDDE885}.Release|Any CPU.ActiveCfg = Release|Any CPU39 {3FB49880-7127-40D4-A9D3-A6C30BDDE885}.Release|Any CPU.Build.0 = Release|Any CPU40 34 {EEA07488-1A51-412A-A52C-53B754A628B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 35 {EEA07488-1A51-412A-A52C-53B754A628B3}.Debug|Any CPU.Build.0 = Debug|Any CPU -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/ActionInfos/ModelPolicyActionInfo.cs
r11849 r11851 12 12 public double Value { 13 13 get { 14 return model.Sample ExpectedReward(new Random());14 return model.Sample(new Random()); 15 15 } 16 16 } … … 27 27 28 28 public double SampleExpectedReward(Random random) { 29 return model.Sample ExpectedReward(random);29 return model.Sample(random); 30 30 } 31 31 -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/HeuristicLab.Algorithms.Bandits.csproj
r11850 r11851 31 31 </PropertyGroup> 32 32 <ItemGroup> 33 <Reference Include="ALGLIB-3.7.0">34 <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>35 </Reference>36 33 <Reference Include="System" /> 37 34 <Reference Include="System.Core" /> … … 69 66 <Name>HeuristicLab.Distributions</Name> 70 67 </ProjectReference> 71 <ProjectReference Include="..\HeuristicLab.Problems.GrammaticalOptimization\HeuristicLab.Problems.GrammaticalOptimization.csproj">72 <Project>{cb9dccf6-667e-4a13-b82d-dbd6b45a045e}</Project>73 <Name>HeuristicLab.Problems.GrammaticalOptimization</Name>74 </ProjectReference>75 68 </ItemGroup> 76 69 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj
r11847 r11851 67 67 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath> 68 68 </Reference> 69 <Reference Include="HeuristicLab.SequentialEngine-3.3">70 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>71 </Reference>72 69 <Reference Include="System" /> 73 70 <Reference Include="System.Core" /> 74 <Reference Include="System.Xml.Linq" />75 <Reference Include="System.Data.DataSetExtensions" />76 <Reference Include="Microsoft.CSharp" />77 <Reference Include="System.Data" />78 <Reference Include="System.Xml" />79 71 </ItemGroup> 80 72 <ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/OffspringSelectionGP.cs
r11847 r11851 8 8 using HeuristicLab.Problems.GrammaticalOptimization; 9 9 using HeuristicLab.Selection; 10 using HeuristicLab.SequentialEngine;11 10 using HeuristicLab.Algorithms.GeneticAlgorithm; 12 11 … … 33 32 public override void Run(int maxEvaluations) { 34 33 var hlProblem = new GenericSymbExprProblem(problem); 35 hlProblem.Evaluator.SolutionEvaluated += OnSolutionEvaluated; // raise solution evaluated event for each GP solution, don't scale quality to 0..1 34 var onEvalLocker = new object(); 35 hlProblem.Evaluator.SolutionEvaluated += (sentence, quality) => { 36 // raise solution evaluated event for each GP solution, don't scale quality to 0..1 37 // need to synchronize in case we are using a parallel engine 38 lock (onEvalLocker) { 39 OnSolutionEvaluated(sentence, quality); 40 } 41 }; 36 42 hlProblem.MaximumSymbolicExpressionTreeLength.Value = MaxSolutionSize; 37 43 hlProblem.MaximumSymbolicExpressionTreeDepth.Value = MaxSolutionDepth; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/StandardGP.cs
r11847 r11851 8 8 using HeuristicLab.Problems.GrammaticalOptimization; 9 9 using HeuristicLab.Selection; 10 using HeuristicLab.SequentialEngine;11 10 using HeuristicLab.Algorithms.GeneticAlgorithm; 12 11 … … 35 34 public override void Run(int maxEvaluations) { 36 35 var hlProblem = new GenericSymbExprProblem(problem); 37 hlProblem.Evaluator.SolutionEvaluated += OnSolutionEvaluated; // raise solution evaluated event for each GP solution, don't scale quality to 0..1 36 var onEvalLocker = new object(); 37 hlProblem.Evaluator.SolutionEvaluated += (sentence, quality) => { 38 // raise solution evaluated event for each GP solution, don't scale quality to 0..1 39 // need to synchronize in case we are using a parallel engine 40 lock (onEvalLocker) { 41 OnSolutionEvaluated(sentence, quality); 42 } 43 }; 38 44 hlProblem.MaximumSymbolicExpressionTreeLength.Value = MaxSolutionSize; 39 45 hlProblem.MaximumSymbolicExpressionTreeDepth.Value = MaxSolutionDepth; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions
-
Property
svn:ignore
set to
bin
*.user
obj
-
Property
svn:ignore
set to
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/BernoulliModel.cs
r11849 r11851 22 22 } 23 23 24 public double Sample ExpectedReward(Random random) {24 public double Sample(Random random) { 25 25 // sample bernoulli mean from beta prior 26 26 return Rand.BetaRand(random, success + alpha, failure + beta); … … 41 41 } 42 42 43 public void PrintStats() {44 Console.Write("{0:F2} ", success / (double)failure);45 }46 47 43 public object Clone() { 48 44 return new BernoulliModel() { failure = this.failure, success = this.success }; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/GaussianMixtureModel.cs
r11849 r11851 23 23 24 24 25 public double Sample ExpectedReward(Random random) {25 public double Sample(Random random) { 26 26 var k = Enumerable.Range(0, numComponents).SampleProportional(random, componentProbs); 27 27 return alglib.invnormaldistribution(random.NextDouble()) * Math.Sqrt(componentVars[k]) + componentMeans[k]; … … 96 96 this.componentVars = Enumerable.Range(0, numComponents).Select((_) => 0.01).ToArray(); 97 97 } 98 99 public void PrintStats() {100 throw new NotImplementedException();101 }102 98 } 103 99 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/GaussianModel.cs
r11849 r11851 45 45 46 46 47 public double Sample ExpectedReward(Random random) {47 public double Sample(Random random) { 48 48 if (knownVariance) { 49 49 return SampleExpectedRewardKnownVariance(random); … … 113 113 } 114 114 115 public void PrintStats() {116 Console.Write("{0:F2} ", estimator.Avg);117 }118 119 115 public object Clone() { 120 116 if (knownVariance) -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/HeuristicLab.Distributions.csproj
r11849 r11851 36 36 <Reference Include="System" /> 37 37 <Reference Include="System.Core" /> 38 <Reference Include="System.Xml.Linq" />39 <Reference Include="System.Data.DataSetExtensions" />40 <Reference Include="Microsoft.CSharp" />41 <Reference Include="System.Data" />42 <Reference Include="System.Xml" />43 38 </ItemGroup> 44 39 <ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/IModel.cs
r11849 r11851 8 8 // represents a model for the reward distribution (of an action given a state) 9 9 public interface IModel : ICloneable { 10 double Sample ExpectedReward(Random random);10 double Sample(Random random); 11 11 void Update(double reward); 12 12 void Reset(); 13 void PrintStats();14 13 } 15 14 } -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/LogitNormalModel.cs
r11849 r11851 13 13 14 14 15 public double Sample ExpectedReward(Random random) {16 return 1.0 / (1 + Math.Exp(-gaussian.Sample ExpectedReward(random)));15 public double Sample(Random random) { 16 return 1.0 / (1 + Math.Exp(-gaussian.Sample(random))); 17 17 } 18 18 … … 23 23 public void Reset() { 24 24 gaussian.Reset(); 25 }26 27 public void PrintStats() {28 25 } 29 26 -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits
-
Property
svn:ignore
set to
bin
*.user
obj
-
Property
svn:ignore
set to
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj
r11849 r11851 36 36 <Reference Include="System" /> 37 37 <Reference Include="System.Core" /> 38 <Reference Include="System.Xml.Linq" />39 <Reference Include="System.Data.DataSetExtensions" />40 <Reference Include="Microsoft.CSharp" />41 <Reference Include="System.Data" />42 <Reference Include="System.Xml" />43 38 </ItemGroup> 44 39 <ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj
r11832 r11851 31 31 </PropertyGroup> 32 32 <ItemGroup> 33 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">34 <SpecificVersion>False</SpecificVersion>35 <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>36 </Reference>37 <Reference Include="AutoDiff-1.0">38 <HintPath>..\..\..\trunk\sources\bin\AutoDiff-1.0.dll</HintPath>39 </Reference>40 33 <Reference Include="HeuristicLab.Common-3.3"> 41 34 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> … … 47 40 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 48 41 </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>53 42 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4"> 54 43 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 55 </Reference>56 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4">57 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>58 44 </Reference> 59 45 <Reference Include="HeuristicLab.Problems.Instances-3.3"> … … 65 51 <Reference Include="System" /> 66 52 <Reference Include="System.Core" /> 67 <Reference Include="System.Xml.Linq" />68 <Reference Include="System.Data.DataSetExtensions" />69 <Reference Include="Microsoft.CSharp" />70 <Reference Include="System.Data" />71 <Reference Include="System.Xml" />72 53 </ItemGroup> 73 54 <ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs
r11832 r11851 5 5 using System.Security.AccessControl; 6 6 using System.Text; 7 using AutoDiff;8 7 using HeuristicLab.Common; 9 8 using HeuristicLab.Problems.DataAnalysis; -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Grammar.cs
r11799 r11851 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Data;4 3 using System.Diagnostics; 5 4 using System.IO; … … 7 6 using System.Text; 8 7 using System.Text.RegularExpressions; 9 using System.Xml.Linq;10 8 using HeuristicLab.Common; 11 9 -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj
r11848 r11851 72 72 <Reference Include="System.Core" /> 73 73 <Reference Include="System.Drawing" /> 74 <Reference Include="System.Xml.Linq" />75 <Reference Include="System.Data.DataSetExtensions" />76 <Reference Include="System.Data" />77 <Reference Include="System.Xml" />78 74 </ItemGroup> 79 75 <ItemGroup> -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/FindPhrasesProblem.cs
r11832 r11851 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Data.Odbc;4 3 using System.Diagnostics; 5 4 using System.Linq; 6 using System.Text;7 using System.Text.RegularExpressions;8 5 using HeuristicLab.Common; 9 6 -
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj
r11850 r11851 47 47 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 48 48 </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"> 50 50 <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> 58 52 </Reference> 59 53 <Reference Include="System" /> … … 86 80 <Project>{24408f7d-ee0f-4886-a08b-ec324d662e47}</Project> 87 81 <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> 88 86 </ProjectReference> 89 87 <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj"> -
branches/HeuristicLab.Problems.GrammaticalOptimization/Test/TestSolvers.cs
r11730 r11851 1 1 using System; 2 using HeuristicLab.Algorithms.GeneticProgramming; 2 3 using HeuristicLab.Algorithms.GrammaticalOptimization; 3 4 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 128 129 } 129 130 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 } 130 178 } 131 179 }
Note: See TracChangeset
for help on using the changeset viewer.