Changeset 12899
- Timestamp:
- 08/25/15 14:18:07 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 2 deleted
- 12 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r12895 r12899 438 438 EndProject 439 439 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.ArtificialAnt.Views-3.5", "HeuristicLab.Problems.ArtificialAnt.Views\3.5\HeuristicLab.Problems.ArtificialAnt.Views-3.5.csproj", "{0ABD192C-926A-47A9-878C-79B6AF5C07C9}" 440 EndProject 441 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.LawnMower-3.4", "HeuristicLab.Problems.LawnMower\3.4\HeuristicLab.Problems.LawnMower-3.4.csproj", "{9B44B886-729D-49B2-B887-4BDCACB91110}" 442 EndProject 443 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.LawnMower.Views-3.4", "HeuristicLab.Problems.LawnMower.Views\3.4\HeuristicLab.Problems.LawnMower.Views-3.4.csproj", "{E186E7BD-E90E-4027-9965-D5E0DBEB00E8}" 440 444 EndProject 441 445 Global … … 2141 2145 {0ABD192C-926A-47A9-878C-79B6AF5C07C9}.Release|x86.ActiveCfg = Release|x86 2142 2146 {0ABD192C-926A-47A9-878C-79B6AF5C07C9}.Release|x86.Build.0 = Release|x86 2147 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2148 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|Any CPU.Build.0 = Debug|Any CPU 2149 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|x64.ActiveCfg = Debug|x64 2150 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|x64.Build.0 = Debug|x64 2151 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|x86.ActiveCfg = Debug|x86 2152 {9B44B886-729D-49B2-B887-4BDCACB91110}.Debug|x86.Build.0 = Debug|x86 2153 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|Any CPU.ActiveCfg = Release|Any CPU 2154 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|Any CPU.Build.0 = Release|Any CPU 2155 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|x64.ActiveCfg = Release|x64 2156 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|x64.Build.0 = Release|x64 2157 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|x86.ActiveCfg = Release|x86 2158 {9B44B886-729D-49B2-B887-4BDCACB91110}.Release|x86.Build.0 = Release|x86 2159 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2160 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|Any CPU.Build.0 = Debug|Any CPU 2161 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|x64.ActiveCfg = Debug|x64 2162 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|x64.Build.0 = Debug|x64 2163 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|x86.ActiveCfg = Debug|x86 2164 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Debug|x86.Build.0 = Debug|x86 2165 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|Any CPU.ActiveCfg = Release|Any CPU 2166 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|Any CPU.Build.0 = Release|Any CPU 2167 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x64.ActiveCfg = Release|x64 2168 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x64.Build.0 = Release|x64 2169 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x86.ActiveCfg = Release|x86 2170 {E186E7BD-E90E-4027-9965-D5E0DBEB00E8}.Release|x86.Build.0 = Release|x86 2143 2171 EndGlobalSection 2144 2172 GlobalSection(SolutionProperties) = preSolution … … 2149 2177 {0C67A033-F6D9-4237-B3CA-C033A44706BE} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5} 2150 2178 {3083C7AA-5AF4-4C75-BA19-B69B86E2F66A} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5} 2179 {9A04599C-D608-4240-8DA6-D41F51C515A3} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5} 2180 {71CDE004-C50F-48DF-858E-AB0AAA3537BC} = {D1B1DE45-F9C7-4FBF-B73C-E759BC4223D5} 2151 2181 EndGlobalSection 2152 2182 EndGlobal -
trunk/sources/HeuristicLab.Problems.LawnMower.Views/3.3/HeuristicLab.Problems.LawnMower.Views-3.3.csproj
r12846 r12899 176 176 <ProjectReference Include="..\..\HeuristicLab.Problems.LawnMower\3.3\HeuristicLab.Problems.LawnMower-3.3.csproj"> 177 177 <Project>{9A04599C-D608-4240-8DA6-D41F51C515A3}</Project> 178 <Name>HeuristicLab.Problems.LawnMower </Name>178 <Name>HeuristicLab.Problems.LawnMower-3.3</Name> 179 179 <Private>False</Private> 180 180 </ProjectReference> -
trunk/sources/HeuristicLab.Problems.LawnMower.Views/3.4/Plugin.cs.frame
r12753 r12899 23 23 24 24 namespace HeuristicLab.Problems.LawnMower.Views { 25 [Plugin("HeuristicLab.Problems.LawnMower.Views", "Lawn mower demo problem for genetic programming (views)", "3. 3.12.$WCREV$")]26 [PluginFile("HeuristicLab.Problems.LawnMower.Views-3. 3.dll", PluginFileType.Assembly)]25 [Plugin("HeuristicLab.Problems.LawnMower.Views", "Lawn mower demo problem for genetic programming (views)", "3.4.0.$WCREV$")] 26 [PluginFile("HeuristicLab.Problems.LawnMower.Views-3.4.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Core", "3.3")] 28 28 [PluginDependency("HeuristicLab.Core.Views", "3.3")] … … 30 30 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views", "3.4")] 31 31 [PluginDependency("HeuristicLab.MainForm", "3.3")] 32 [PluginDependency("HeuristicLab.Problems.LawnMower", "3. 3")]32 [PluginDependency("HeuristicLab.Problems.LawnMower", "3.4")] 33 33 public class HeuristicLabProblemsLawnMowerViewsPlugin : PluginBase { 34 34 } -
trunk/sources/HeuristicLab.Problems.LawnMower.Views/3.4/Properties/AssemblyInfo.cs.frame
r12753 r12899 52 52 // You can specify all the values or you can default the Build and Revision Numbers 53 53 // by using the '*' as shown below: 54 [assembly: AssemblyVersion("3. 3.0.0")]55 [assembly: AssemblyFileVersion("3. 3.12.$WCREV$")]54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")] -
trunk/sources/HeuristicLab.Problems.LawnMower.Views/3.4/SolutionProgramView.cs
r12012 r12899 49 49 } 50 50 } 51 52 51 } 53 52 } -
trunk/sources/HeuristicLab.Problems.LawnMower/3.3/HeuristicLab.Problems.LawnMower-3.3.csproj
r12846 r12899 116 116 <ItemGroup> 117 117 <Compile Include="BestSolutionAnalyzer.cs" /> 118 <Compile Include="Symbols\Constant.cs"> 119 <SubType>Code</SubType> 120 </Compile> 121 <Compile Include="Symbols\ConstantTreeNode.cs"> 122 <SubType>Code</SubType> 123 </Compile> 124 <Compile Include="Symbols\Forward.cs"> 125 <SubType>Code</SubType> 126 </Compile> 127 <Compile Include="Symbols\Frog.cs"> 128 <SubType>Code</SubType> 129 </Compile> 130 <Compile Include="Symbols\Left.cs"> 131 <SubType>Code</SubType> 132 </Compile> 133 <Compile Include="Symbols\Prog.cs"> 134 <SubType>Code</SubType> 135 </Compile> 136 <Compile Include="Symbols\Sum.cs"> 137 <SubType>Code</SubType> 138 </Compile> 118 139 <None Include="HeuristicLab.snk" /> 119 140 <None Include="Plugin.cs.frame" /> … … 126 147 <Compile Include="Plugin.cs" /> 127 148 <Compile Include="Properties\AssemblyInfo.cs" /> 128 <Compile Include="Symbols\Constant.cs" />129 <Compile Include="Symbols\ConstantTreeNode.cs" />130 <Compile Include="Symbols\Forward.cs" />131 <Compile Include="Symbols\Frog.cs" />132 <Compile Include="Symbols\Left.cs" />133 <Compile Include="Symbols\Prog.cs" />134 <Compile Include="Symbols\Sum.cs" />135 149 </ItemGroup> 136 150 <ItemGroup> -
trunk/sources/HeuristicLab.Problems.LawnMower/3.3/Problem.cs
r12504 r12899 33 33 namespace HeuristicLab.Problems.LawnMower { 34 34 [StorableClass] 35 [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 160)]36 35 [Item("Lawn Mower Problem", "The lawn mower demo problem for genetic programming.")] 37 36 public class Problem : SingleObjectiveHeuristicOptimizationProblem<Evaluator, ISymbolicExpressionTreeCreator> { -
trunk/sources/HeuristicLab.Problems.LawnMower/3.4/Interpreter.cs
r12012 r12899 59 59 60 60 private static Tuple<int, int> EvaluateLawnMowerProgram(ISymbolicExpressionTreeNode node, MowerState mowerState, bool[,] lawn, IEnumerable<ISymbolicExpressionTreeNode> adfs) { 61 if (mowerState.Energy <= 0) return new Tuple<int, int>(0, 0);61 if (mowerState.Energy <= 0) return Tuple.Create(0, 0); 62 62 63 63 if (node.Symbol is ProgramRootSymbol) { … … 65 65 } else if (node.Symbol is StartSymbol) { 66 66 return EvaluateLawnMowerProgram(node.GetSubtree(0), mowerState, lawn, adfs); 67 } else if (node.Symbol is Left) {67 } else if (node.Symbol.Name == "Left") { 68 68 switch (mowerState.Heading) { 69 69 case Heading.East: mowerState.Heading = Heading.North; … … 78 78 } 79 79 return new Tuple<int, int>(0, 0); 80 } else if (node.Symbol is Forward) {80 } else if (node.Symbol.Name == "Forward") { 81 81 int dRow = 0; 82 82 int dCol = 0; … … 97 97 uint newRow = (uint)((mowerState.Position.Item1 + lawn.GetLength(0) + dRow) % lawn.GetLength(0)); 98 98 uint newColumn = (uint)((mowerState.Position.Item2 + lawn.GetLength(1) + dCol) % lawn.GetLength(1)); 99 mowerState.Position = new Tuple<uint, uint>(newRow, newColumn);99 mowerState.Position = Tuple.Create(newRow, newColumn); 100 100 mowerState.Energy = mowerState.Energy - 1; 101 101 lawn[newRow, newColumn] = true; 102 return new Tuple<int, int>(0, 0); 103 } else if (node.Symbol is Constant) { 104 var constNode = node as ConstantTreeNode; 105 return constNode.Value; 106 } else if (node.Symbol is Sum) { 102 return Tuple.Create(0, 0); 103 } else if (node.Symbol.Name == "Sum") { 107 104 var p = EvaluateLawnMowerProgram(node.GetSubtree(0), mowerState, lawn, adfs); 108 105 var q = EvaluateLawnMowerProgram(node.GetSubtree(1), mowerState, lawn, adfs); 109 return new Tuple<int, int>(p.Item1 + q.Item1, 110 p.Item2 + q.Item2); 111 } else if (node.Symbol is Prog) { 106 return Tuple.Create(p.Item1 + q.Item1, p.Item2 + q.Item2); 107 } else if (node.Symbol.Name == "Prog") { 112 108 EvaluateLawnMowerProgram(node.GetSubtree(0), mowerState, lawn, adfs); 113 109 return EvaluateLawnMowerProgram(node.GetSubtree(1), mowerState, lawn, adfs); 114 } else if (node.Symbol is Frog) {110 } else if (node.Symbol.Name == "Frog") { 115 111 var p = EvaluateLawnMowerProgram(node.GetSubtree(0), mowerState, lawn, adfs); 116 112 int x = p.Item1; … … 120 116 var newRow = (uint)((mowerState.Position.Item1 + x) % lawn.GetLength(0)); 121 117 var newCol = (uint)((mowerState.Position.Item2 + y) % lawn.GetLength(1)); 122 mowerState.Position = new Tuple<uint, uint>(newRow, newCol);118 mowerState.Position = Tuple.Create(newRow, newCol); 123 119 mowerState.Energy = mowerState.Energy - 1; 124 120 lawn[newRow, newCol] = true; 125 return new Tuple<int, int>(0, 0);121 return Tuple.Create(0, 0); 126 122 } else if (node.Symbol is InvokeFunction) { 127 123 var invokeNode = node as InvokeFunctionTreeNode; … … 147 143 return EvaluateLawnMowerProgram(functionDefinition.GetSubtree(0), mowerState, lawn, adfs); 148 144 } else { 149 throw new ArgumentException("Invalid symbol in the lawn mower program."); 145 // try to parse as ephemeral random const with format: "x,y" (x, y in [0..32[) 146 int x, y; 147 var tokens = node.Symbol.Name.Split(','); 148 if (tokens.Length == 2 && 149 int.TryParse(tokens[0], out x) && 150 int.TryParse(tokens[1], out y)) { 151 return Tuple.Create(x, y); 152 } else { 153 throw new ArgumentException("Invalid symbol in the lawn mower program."); 154 } 150 155 } 151 156 } -
trunk/sources/HeuristicLab.Problems.LawnMower/3.4/Plugin.cs.frame
r12753 r12899 23 23 24 24 namespace HeuristicLab.Problems.LawnMower { 25 [Plugin("HeuristicLab.Problems.LawnMower", "Lawn mower demo problem for genetic programming", "3. 3.12.$WCREV$")]26 [PluginFile("HeuristicLab.Problems.LawnMower-3. 3.dll", PluginFileType.Assembly)]25 [Plugin("HeuristicLab.Problems.LawnMower", "Lawn mower demo problem for genetic programming", "3.4.0.$WCREV$")] 26 [PluginFile("HeuristicLab.Problems.LawnMower-3.4.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 28 28 [PluginDependency("HeuristicLab.Common", "3.3")] … … 34 34 [PluginDependency("HeuristicLab.Parameters", "3.3")] 35 35 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 [PluginDependency("HeuristicLab.Random", "3.3")] 36 37 public class HeuristicLabProblemsLawnMowerPlugin : PluginBase { 37 38 } -
trunk/sources/HeuristicLab.Problems.LawnMower/3.4/Problem.cs
r12504 r12899 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 31 using HeuristicLab.PluginInfrastructure; 32 using HeuristicLab.Random; 32 33 33 34 namespace HeuristicLab.Problems.LawnMower { … … 35 36 [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 160)] 36 37 [Item("Lawn Mower Problem", "The lawn mower demo problem for genetic programming.")] 37 public class Problem : S ingleObjectiveHeuristicOptimizationProblem<Evaluator, ISymbolicExpressionTreeCreator>{38 public class Problem : SymbolicExpressionTreeProblem { 38 39 private const string LawnWidthParameterName = "LawnWidth"; 39 40 private const string LawnLengthParameterName = "LawnLength"; 40 private const string LawnMowerProgramParameterName = "Program";41 private const string MaxLawnMowerProgramLengthParameterName = "MaxProgramLength";42 private const string MaxLawnMowerProgramDepthParameterName = "MaxProgramDepth";43 private const string LawnMowerGrammarParameterName = "Grammar";44 private const string MaxFunctionDefinitionsParameterName = "MaxFunctionDefinitions";45 private const string MaxArgumentDefinitionsParameterName = "MaxArgumentDefinitions";46 41 47 42 public IFixedValueParameter<IntValue> LawnWidthParameter { … … 51 46 get { return (IFixedValueParameter<IntValue>)Parameters[LawnLengthParameterName]; } 52 47 } 53 public IFixedValueParameter<IntValue> MaxLawnMowerProgramLengthParameter { 54 get { return (IFixedValueParameter<IntValue>)Parameters[MaxLawnMowerProgramLengthParameterName]; } 55 } 56 public IFixedValueParameter<IntValue> MaxLawnMowerProgramDepthParameter { 57 get { return (IFixedValueParameter<IntValue>)Parameters[MaxLawnMowerProgramDepthParameterName]; } 58 } 59 public IValueParameter<Grammar> GrammarParameter { 60 get { return (IValueParameter<Grammar>)Parameters[LawnMowerGrammarParameterName]; } 61 } 62 public IFixedValueParameter<IntValue> MaxFunctionDefinitionsParameter { 63 get { return (IFixedValueParameter<IntValue>)Parameters[MaxFunctionDefinitionsParameterName]; } 64 } 65 public IFixedValueParameter<IntValue> MaxArgumentDefinitionsParameter { 66 get { return (IFixedValueParameter<IntValue>)Parameters[MaxArgumentDefinitionsParameterName]; } 48 49 public override bool Maximization { 50 get { return true; } 67 51 } 68 52 … … 73 57 protected Problem(Problem original, Cloner cloner) 74 58 : base(original, cloner) { 75 RegisterEventHandlers();76 59 } 77 60 public Problem() 78 : base( new Evaluator(), new RampedHalfAndHalfTreeCreator()) {61 : base() { 79 62 Parameters.Add(new FixedValueParameter<IntValue>(LawnWidthParameterName, "Width of the lawn.", new IntValue(8))); 80 63 Parameters.Add(new FixedValueParameter<IntValue>(LawnLengthParameterName, "Length of the lawn.", new IntValue(8))); 81 Parameters.Add(new FixedValueParameter<IntValue>(MaxLawnMowerProgramDepthParameterName, "Maximal depth of the lawn mower program.", new IntValue(13)));82 Parameters.Add(new FixedValueParameter<IntValue>(MaxLawnMowerProgramLengthParameterName, "Maximal length of the lawn mower program.", new IntValue(1000)));83 Parameters.Add(new FixedValueParameter<IntValue>(MaxFunctionDefinitionsParameterName, "Maximal number of automatically defined functions (ADF).", new IntValue(3)));84 Parameters.Add(new FixedValueParameter<IntValue>(MaxArgumentDefinitionsParameterName, "Maximal number of automatically defined arguments.", new IntValue(3)));85 Parameters.Add(new ValueParameter<Grammar>(LawnMowerGrammarParameterName, "Grammar for the lawn mower program.",86 new Grammar()));87 Maximization.Value = true;88 64 89 GrammarParameter.Value.MaximumFunctionDefinitions = MaxFunctionDefinitionsParameter.Value.Value; 90 GrammarParameter.Value.MaximumFunctionArguments = MaxArgumentDefinitionsParameter.Value.Value; 65 var g = new SimpleSymbolicExpressionGrammar(); 66 g.AddSymbols(new string[] { "Sum", "Prog" }, 2, 2); 67 g.AddSymbols(new string[] { "Frog" }, 1, 1); 68 g.AddTerminalSymbols(new string[] { "Left", "Forward" }); 69 // initialize 20 ephemeral random constants in [0..32[ 70 var fastRand = new FastRandom(314159); 71 for (int i = 0; i < 20; i++) { 72 g.AddTerminalSymbol(string.Format("{0},{1}", fastRand.Next(0, 32), fastRand.Next(0, 32))); 73 } 91 74 92 InitializeOperators(); 93 RegisterEventHandlers(); 75 Encoding = new SymbolicExpressionTreeEncoding(g, 1000, 17); 76 } 77 78 public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, IRandom random) { 79 const string bestSolutionResultName = "Best Solution"; 80 var bestQuality = Maximization ? qualities.Max() : qualities.Min(); 81 var bestIdx = Array.IndexOf(qualities, bestQuality); 82 83 if (!results.ContainsKey(bestSolutionResultName)) { 84 results.Add(new Result(bestSolutionResultName, new Solution(trees[bestIdx], LawnLengthParameter.Value.Value, LawnWidthParameter.Value.Value, bestQuality))); 85 } else if (((Solution)(results[bestSolutionResultName].Value)).Quality < qualities[bestIdx]) { 86 results[bestSolutionResultName].Value = new Solution(trees[bestIdx], LawnLengthParameter.Value.Value, LawnWidthParameter.Value.Value, bestQuality); 87 } 94 88 } 95 89 96 90 97 91 [StorableHook(HookType.AfterDeserialization)] 98 private void AfterDeserialization() { 99 RegisterEventHandlers(); 92 private void AfterDeserialization() { } 93 94 public override double Evaluate(ISymbolicExpressionTree tree, IRandom random) { 95 var length = LawnLengthParameter.Value.Value; 96 var width = LawnWidthParameter.Value.Value; 97 98 var lawn = Interpreter.EvaluateLawnMowerProgram(length, width, tree); 99 // count number of squares that have been mowed 100 int numberOfMowedCells = 0; 101 for (int i = 0; i < length; i++) 102 for (int j = 0; j < width; j++) 103 if (lawn[i, j]) { 104 numberOfMowedCells++; 105 } 106 return numberOfMowedCells; 100 107 } 101 108 … … 103 110 return new Problem(this, cloner); 104 111 } 105 106 private void InitializeOperators() {107 Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());108 Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());109 Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());110 Operators.Add(new BestSolutionAnalyzer());111 ParameterizeOperators();112 ParameterizeAnalyzers();113 }114 115 116 private void RegisterEventHandlers() {117 Evaluator.QualityParameter.ActualNameChanged += QualityParameterOnActualNameChanged;118 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged +=119 SymbolicExpressionTreeParameterOnActualNameChanged;120 MaxArgumentDefinitionsParameter.ValueChanged += ParameterizeGrammar;121 MaxFunctionDefinitionsParameter.ValueChanged += ParameterizeGrammar;122 }123 124 protected override void OnEvaluatorChanged() {125 Evaluator.LawnMowerProgramParameter.ActualName = LawnMowerProgramParameterName;126 Evaluator.LawnLengthParameter.ActualName = LawnLengthParameterName;127 Evaluator.LawnWidthParameter.ActualName = LawnWidthParameterName;128 Evaluator.QualityParameter.ActualNameChanged += QualityParameterOnActualNameChanged;129 ParameterizeAnalyzers();130 ParameterizeOperators();131 base.OnEvaluatorChanged();132 }133 134 protected override void OnSolutionCreatorChanged() {135 SolutionCreator.SymbolicExpressionTreeParameter.ActualName = LawnMowerProgramParameterName;136 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += SymbolicExpressionTreeParameterOnActualNameChanged;137 ParameterizeAnalyzers();138 ParameterizeOperators();139 base.OnSolutionCreatorChanged();140 }141 142 private void SymbolicExpressionTreeParameterOnActualNameChanged(object sender, EventArgs eventArgs) {143 ParameterizeAnalyzers();144 ParameterizeOperators();145 }146 147 private void QualityParameterOnActualNameChanged(object sender, EventArgs eventArgs) {148 ParameterizeAnalyzers();149 ParameterizeOperators();150 }151 152 private void ParameterizeGrammar(object sender, EventArgs eventArgs) {153 GrammarParameter.Value.MaximumFunctionArguments = MaxArgumentDefinitionsParameter.Value.Value;154 GrammarParameter.Value.MaximumFunctionDefinitions = MaxFunctionDefinitionsParameter.Value.Value;155 }156 157 private void ParameterizeAnalyzers() {158 var analyzers = Operators.OfType<IAnalyzer>();159 foreach (var o in analyzers.OfType<ISymbolicExpressionTreeAnalyzer>()) {160 o.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;161 }162 foreach (var o in analyzers.OfType<BestSolutionAnalyzer>()) {163 o.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;164 }165 }166 167 private void ParameterizeOperators() {168 var operators = Parameters169 .OfType<IValueParameter>()170 .Select(p => p.Value)171 .OfType<IOperator>()172 .Union(Operators);173 foreach (var o in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {174 o.SymbolicExpressionTreeGrammarParameter.ActualName = LawnMowerGrammarParameterName;175 }176 foreach (var o in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {177 o.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaxLawnMowerProgramDepthParameterName;178 o.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaxLawnMowerProgramLengthParameterName;179 }180 foreach (var op in operators.OfType<Evaluator>()) {181 op.LawnMowerProgramParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;182 op.LawnLengthParameter.ActualName = LawnLengthParameterName;183 op.LawnWidthParameter.ActualName = LawnWidthParameterName;184 }185 foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) {186 op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;187 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;188 }189 foreach (var op in operators.OfType<ISymbolicExpressionTreeManipulator>()) {190 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;191 }192 foreach (var op in operators.OfType<ISymbolicExpressionTreeCreator>()) {193 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;194 }195 foreach (ISymbolicExpressionTreeArchitectureAlteringOperator op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) {196 op.MaximumFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;197 op.MaximumFunctionArgumentsParameter.ActualName = MaxArgumentDefinitionsParameter.Name;198 }199 }200 112 } 201 113 } -
trunk/sources/HeuristicLab.Problems.LawnMower/3.4/Properties/AssemblyInfo.cs.frame
r12753 r12899 53 53 // by using the '*' as shown below: 54 54 // [assembly: AssemblyVersion("1.0.*")] 55 [assembly: AssemblyVersion("3. 3.0.0")]56 [assembly: AssemblyFileVersion("3. 3.12.$WCREV$")]55 [assembly: AssemblyVersion("3.4.0.0")] 56 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")] -
trunk/sources/HeuristicLab.Problems.LawnMower/3.4/Solution.cs
r12012 r12899 28 28 [StorableClass] 29 29 public sealed class Solution : NamedItem { 30 private int width;31 30 [Storable] 32 public int Width { 33 get { return width; } 34 private set { this.width = value; } 35 } 36 private int length; 31 public int Width { get; private set; } 37 32 [Storable] 38 public int Length { 39 get { return length; } 40 private set { this.length = value; } 41 } 42 private ISymbolicExpressionTree tree; 33 public int Length { get; private set; } 43 34 [Storable] 44 public ISymbolicExpressionTree Tree { 45 get { return tree; }46 private set { this.tree = value; }47 } 35 public ISymbolicExpressionTree Tree { get; private set; } 36 [Storable] 37 public double Quality { get; private set; } 38 48 39 [StorableConstructor] 49 40 private Solution(bool deserializing) : base(deserializing) { } 50 41 private Solution(Solution original, Cloner cloner) 51 42 : base(original, cloner) { 52 this.length = original.length; 53 this.width = original.width; 54 this.tree = cloner.Clone(tree); 43 this.Length = original.Length; 44 this.Width = original.Width; 45 this.Tree = cloner.Clone(original.Tree); 46 this.Quality = original.Quality; 55 47 } 56 48 57 public Solution(ISymbolicExpressionTree tree, int length, int width )49 public Solution(ISymbolicExpressionTree tree, int length, int width, double quality) 58 50 : base("Solution", "A lawn mower solution.") { 59 this.tree = tree; 60 this.length = length; 61 this.width = width; 51 this.Tree = tree; 52 this.Length = length; 53 this.Width = width; 54 this.Quality = quality; 62 55 } 63 56 [StorableHook(HookType.AfterDeserialization)]
Note: See TracChangeset
for help on using the changeset viewer.