Changeset 16813
- Timestamp:
- 04/18/19 13:23:10 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessCovarianceOptimizationProblem.cs
r16723 r16813 22 22 using System; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.Problems.DataAnalysis; 32 32 using HeuristicLab.Problems.Instances; … … 60 60 private static readonly CovarianceSquaredExponentialIso sqrExpIso; 61 61 62 private static readonly SymbolicExpressionTreeEncoding defaultEncoding; 63 62 64 static GaussianProcessCovarianceOptimizationProblem() { 63 65 // cumbersome initialization because of ConstrainedValueParameters … … 150 152 private ICovarianceFunction covFunc; 151 153 152 public GaussianProcessCovarianceOptimizationProblem() 153 : base() { 154 public GaussianProcessCovarianceOptimizationProblem() : base(new SymbolicExpressionTreeEncoding()) { 154 155 Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData())); 155 156 Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptIterationsParameterName, "Number of optimization steps for hyperparameter values", new IntValue(50))); 156 157 Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of random restarts for constant optimization.", new IntValue(10))); 157 158 Parameters["Restarts"].Hidden = true; 159 160 158 161 var g = new SimpleSymbolicExpressionGrammar(); 159 162 g.AddSymbols(new string[] { "Sum", "Product" }, 2, 2); … … 181 184 "SquaredExponentialIso" 182 185 }); 183 base.Encoding = new SymbolicExpressionTreeEncoding(g, 10, 5); 186 187 Encoding.TreeLength = 10; 188 Encoding.TreeDepth = 5; 189 Encoding.Grammar = g; 184 190 } 185 191 … … 327 333 var gradients = model.HyperparameterGradients; 328 334 Array.Copy(gradients, grad, gradients.Length); 329 } 330 catch (ArgumentException) { 335 } catch (ArgumentException) { 331 336 // building the GaussianProcessModel might fail, in this case we return the worst possible objective value 332 337 func = 1.0E+300; -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs
r16723 r16813 24 24 using System; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Data; 29 30 using HeuristicLab.Optimization; 30 using HEAL.Attic;31 31 32 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 46 46 } 47 47 48 protected SymbolicExpressionTreeProblem( ) : base() { }48 protected SymbolicExpressionTreeProblem(SymbolicExpressionTreeEncoding encoding) : base(encoding) { } 49 49 50 50 public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, … … 63 63 var bestIdx = Array.IndexOf(qualities, bestQuality); 64 64 var bestClone = (IItem)trees[bestIdx].Clone(); 65 65 66 results["Best Solution"].Value = bestClone; 66 67 results["Best Solution Quality"].Value = new DoubleValue(bestQuality); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Problem.cs
r16723 r16813 23 23 using System.Diagnostics.Contracts; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 using HEAL.Attic;32 32 33 33 … … 116 116 #endregion 117 117 118 public Problem() 119 : base() { 118 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 120 119 BoolMatrix world = new BoolMatrix(ToBoolMatrix(santaFeAntTrail)); 121 120 Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world)); 122 121 Parameters.Add(new ValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600))); 123 122 124 base.BestKnownQuality = 89;125 123 var g = new SimpleSymbolicExpressionGrammar(); 126 124 g.AddSymbols(new string[] { "IfFoodAhead", "Prog2" }, 2, 2); 127 125 g.AddSymbols(new string[] { "Prog3" }, 3, 3); 128 126 g.AddTerminalSymbols(new string[] { "Move", "Left", "Right" }); 129 base.Encoding = new SymbolicExpressionTreeEncoding(g, 20, 10); 127 128 Encoding.TreeLength = 20; 129 Encoding.TreeDepth = 10; 130 Encoding.Grammar = g; 131 base.BestKnownQuality = 89; 130 132 } 131 133 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/BasicSymbolicRegression/Problem.cs
r16723 r16813 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 29 using HeuristicLab.Parameters; 29 using HEAL.Attic;30 30 using HeuristicLab.Problems.DataAnalysis; 31 31 using HeuristicLab.Problems.Instances; … … 81 81 #endregion 82 82 83 public Problem() 84 : base() { 83 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 85 84 Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData())); 86 85 87 var g = new SimpleSymbolicExpressionGrammar(); // empty grammar is replaced in UpdateGrammar()88 base.Encoding = new SymbolicExpressionTreeEncoding(g, 100, 17);86 Encoding.TreeLength = 100; 87 Encoding.TreeDepth = 17; 89 88 90 89 UpdateGrammar(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
r16723 r16813 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 32 32 … … 78 78 79 79 public EvenParityProblem() 80 : base( ) {80 : base(new SymbolicExpressionTreeEncoding()) { 81 81 Parameters.Add(new FixedValueParameter<IntValue>(NumberOfBitsParameterName, "The number of bits for the input parameter for the even parity function", new IntValue(4))); 82 82 83 var g = new SimpleSymbolicExpressionGrammar(); // will be replaced in update grammar84 Encoding = new SymbolicExpressionTreeEncoding(g, 100, 17);83 Encoding.TreeLength = 100; 84 Encoding.TreeDepth = 17; 85 85 86 86 UpdateGrammar(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs
r16723 r16813 24 24 using System.Diagnostics.Contracts; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; … … 29 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 31 using HeuristicLab.Parameters; 31 using HEAL.Attic;32 32 33 33 … … 81 81 82 82 public MultiplexerProblem() 83 : base( ) {83 : base(new SymbolicExpressionTreeEncoding()) { 84 84 Parameters.Add(new FixedValueParameter<IntValue>(NumberOfBitsParameterName, 85 85 "The number of bits for the input parameter for the multiplexer function. This is the sum of the number of address bits and the number of input lines. E.g. the 11-MUX has 3 address bits and 8 input lines", 86 86 new IntValue(11))); 87 87 88 var g = new SimpleSymbolicExpressionGrammar(); // will be replaced in update grammar 89 Encoding = new SymbolicExpressionTreeEncoding(g, 100, 17); 90 88 Encoding.TreeLength = 100; 89 Encoding.TreeDepth = 17; 91 90 UpdateGrammar(); 92 91 RegisterEventHandlers(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/LawnMower/Problem.cs
r16723 r16813 22 22 using System; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.Random; 32 32 … … 62 62 #endregion 63 63 64 public Problem() 65 : base() { 64 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 66 65 Parameters.Add(new FixedValueParameter<IntValue>(LawnWidthParameterName, "Width of the lawn.", new IntValue(8))); 67 66 Parameters.Add(new FixedValueParameter<IntValue>(LawnLengthParameterName, "Length of the lawn.", new IntValue(8))); … … 77 76 } 78 77 79 Encoding = new SymbolicExpressionTreeEncoding(g, 1000, 17); 78 Encoding.TreeLength = 1000; 79 Encoding.TreeDepth = 17; 80 Encoding.Grammar = g; 80 81 } 81 82 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Problem.cs
r16723 r16813 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Parameters; 28 using HEAL.Attic;29 29 30 30 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { … … 73 73 } 74 74 75 public Problem() 76 : base() { 75 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 77 76 DirectoryValue robocodeDir = new DirectoryValue { Value = @"robocode" }; 78 77 … … 85 84 Parameters.Add(new ValueParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList)); 86 85 87 Encoding = new SymbolicExpressionTreeEncoding(new Grammar(), 1000, 10); 86 Encoding.TreeLength = 1000; 87 Encoding.TreeDepth = 10; 88 Encoding.Grammar = new Grammar(); 88 89 Encoding.FunctionArguments = 0; 89 90 Encoding.FunctionDefinitions = 0; … … 134 135 } 135 136 136 void RobocodePathParameter_ValueChanged(object sender, System.EventArgs e) {137 private void RobocodePathParameter_ValueChanged(object sender, System.EventArgs e) { 137 138 EnemiesParameter.Value.RobocodePath = RobocodePathParameter.Value.Value; 138 139 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntProblem.cs
r16723 r16813 23 23 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 using HEAL.Attic;32 32 using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt; 33 33 using HeuristicLab.Problems.GrammaticalEvolution.Mappers; … … 85 85 } 86 86 87 public GEArtificialAntProblem() 88 : base() { 87 public GEArtificialAntProblem() : base(new IntegerVectorEncoding()) { 89 88 wrappedAntProblem = new HeuristicLab.Problems.GeneticProgramming.ArtificialAnt.Problem(); 90 89 Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", wrappedAntProblem.World)); … … 92 91 Parameters.Add(new ValueParameter<IGenotypeToPhenotypeMapper>("GenotypeToPhenotypeMapper", "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).", new DepthFirstMapper())); 93 92 94 Encoding = new IntegerVectorEncoding(30) { Bounds = new IntMatrix(new int[,] { { 0, 100 } }) }; 93 Encoding.Length = 30; 94 Encoding.Bounds = new IntMatrix(new int[,] { { 0, 100 } }); 95 95 96 96 BestKnownQuality = wrappedAntProblem.BestKnownQuality;
Note: See TracChangeset
for help on using the changeset viewer.