Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16813


Ignore:
Timestamp:
04/18/19 13:23:10 (6 years ago)
Author:
mkommend
Message:

#2521: Changed base ctor call in all GeneticProgrammingProblems.

Location:
branches/2521_ProblemRefactoring
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessCovarianceOptimizationProblem.cs

    r16723 r16813  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.Problems.DataAnalysis;
    3232using HeuristicLab.Problems.Instances;
     
    6060    private static readonly CovarianceSquaredExponentialIso sqrExpIso;
    6161
     62    private static readonly SymbolicExpressionTreeEncoding defaultEncoding;
     63
    6264    static GaussianProcessCovarianceOptimizationProblem() {
    6365      // cumbersome initialization because of ConstrainedValueParameters
     
    150152    private ICovarianceFunction covFunc;
    151153
    152     public GaussianProcessCovarianceOptimizationProblem()
    153       : base() {
     154    public GaussianProcessCovarianceOptimizationProblem() : base(new SymbolicExpressionTreeEncoding()) {
    154155      Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData()));
    155156      Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptIterationsParameterName, "Number of optimization steps for hyperparameter values", new IntValue(50)));
    156157      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of random restarts for constant optimization.", new IntValue(10)));
    157158      Parameters["Restarts"].Hidden = true;
     159
     160
    158161      var g = new SimpleSymbolicExpressionGrammar();
    159162      g.AddSymbols(new string[] { "Sum", "Product" }, 2, 2);
     
    181184        "SquaredExponentialIso"
    182185      });
    183       base.Encoding = new SymbolicExpressionTreeEncoding(g, 10, 5);
     186
     187      Encoding.TreeLength = 10;
     188      Encoding.TreeDepth = 5;
     189      Encoding.Grammar = g;
    184190    }
    185191
     
    327333        var gradients = model.HyperparameterGradients;
    328334        Array.Copy(gradients, grad, gradients.Length);
    329       }
    330       catch (ArgumentException) {
     335      } catch (ArgumentException) {
    331336        // building the GaussianProcessModel might fail, in this case we return the worst possible objective value
    332337        func = 1.0E+300;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs

    r16723 r16813  
    2424using System;
    2525using System.Linq;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Data;
    2930using HeuristicLab.Optimization;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    4646    }
    4747
    48     protected SymbolicExpressionTreeProblem() : base() { }
     48    protected SymbolicExpressionTreeProblem(SymbolicExpressionTreeEncoding encoding) : base(encoding) { }
    4949
    5050    public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results,
     
    6363        var bestIdx = Array.IndexOf(qualities, bestQuality);
    6464        var bestClone = (IItem)trees[bestIdx].Clone();
     65
    6566        results["Best Solution"].Value = bestClone;
    6667        results["Best Solution Quality"].Value = new DoubleValue(bestQuality);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Problem.cs

    r16723 r16813  
    2323using System.Diagnostics.Contracts;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
    31 using HEAL.Attic;
    3232
    3333
     
    116116    #endregion
    117117
    118     public Problem()
    119       : base() {
     118    public Problem() : base(new SymbolicExpressionTreeEncoding()) {
    120119      BoolMatrix world = new BoolMatrix(ToBoolMatrix(santaFeAntTrail));
    121120      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
    122121      Parameters.Add(new ValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
    123122
    124       base.BestKnownQuality = 89;
    125123      var g = new SimpleSymbolicExpressionGrammar();
    126124      g.AddSymbols(new string[] { "IfFoodAhead", "Prog2" }, 2, 2);
    127125      g.AddSymbols(new string[] { "Prog3" }, 3, 3);
    128126      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;
    130132    }
    131133
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/BasicSymbolicRegression/Problem.cs

    r16723 r16813  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.Parameters;
    29 using HEAL.Attic;
    3030using HeuristicLab.Problems.DataAnalysis;
    3131using HeuristicLab.Problems.Instances;
     
    8181    #endregion
    8282
    83     public Problem()
    84       : base() {
     83    public Problem() : base(new SymbolicExpressionTreeEncoding()) {
    8584      Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData()));
    8685
    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;
    8988
    9089      UpdateGrammar();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs

    r16723 r16813  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131
    3232
     
    7878
    7979    public EvenParityProblem()
    80       : base() {
     80      : base(new SymbolicExpressionTreeEncoding()) {
    8181      Parameters.Add(new FixedValueParameter<IntValue>(NumberOfBitsParameterName, "The number of bits for the input parameter for the even parity function", new IntValue(4)));
    8282
    83       var g = new SimpleSymbolicExpressionGrammar(); // will be replaced in update grammar
    84       Encoding = new SymbolicExpressionTreeEncoding(g, 100, 17);
     83      Encoding.TreeLength = 100;
     84      Encoding.TreeDepth = 17;
    8585
    8686      UpdateGrammar();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs

    r16723 r16813  
    2424using System.Diagnostics.Contracts;
    2525using System.Linq;
     26using HEAL.Attic;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    2930using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3031using HeuristicLab.Parameters;
    31 using HEAL.Attic;
    3232
    3333
     
    8181
    8282    public MultiplexerProblem()
    83       : base() {
     83      : base(new SymbolicExpressionTreeEncoding()) {
    8484      Parameters.Add(new FixedValueParameter<IntValue>(NumberOfBitsParameterName,
    8585        "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",
    8686        new IntValue(11)));
    8787
    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;
    9190      UpdateGrammar();
    9291      RegisterEventHandlers();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/LawnMower/Problem.cs

    r16723 r16813  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.Random;
    3232
     
    6262    #endregion
    6363
    64     public Problem()
    65       : base() {
     64    public Problem() : base(new SymbolicExpressionTreeEncoding()) {
    6665      Parameters.Add(new FixedValueParameter<IntValue>(LawnWidthParameterName, "Width of the lawn.", new IntValue(8)));
    6766      Parameters.Add(new FixedValueParameter<IntValue>(LawnLengthParameterName, "Length of the lawn.", new IntValue(8)));
     
    7776      }
    7877
    79       Encoding = new SymbolicExpressionTreeEncoding(g, 1000, 17);
     78      Encoding.TreeLength = 1000;
     79      Encoding.TreeDepth = 17;
     80      Encoding.Grammar = g;
    8081    }
    8182
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Problem.cs

    r16723 r16813  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
     
    7373    }
    7474
    75     public Problem()
    76       : base() {
     75    public Problem() : base(new SymbolicExpressionTreeEncoding()) {
    7776      DirectoryValue robocodeDir = new DirectoryValue { Value = @"robocode" };
    7877
     
    8584      Parameters.Add(new ValueParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList));
    8685
    87       Encoding = new SymbolicExpressionTreeEncoding(new Grammar(), 1000, 10);
     86      Encoding.TreeLength = 1000;
     87      Encoding.TreeDepth = 10;
     88      Encoding.Grammar = new Grammar();
    8889      Encoding.FunctionArguments = 0;
    8990      Encoding.FunctionDefinitions = 0;
     
    134135    }
    135136
    136     void RobocodePathParameter_ValueChanged(object sender, System.EventArgs e) {
     137    private void RobocodePathParameter_ValueChanged(object sender, System.EventArgs e) {
    137138      EnemiesParameter.Value.RobocodePath = RobocodePathParameter.Value.Value;
    138139    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntProblem.cs

    r16723 r16813  
    2323
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
    31 using HEAL.Attic;
    3232using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt;
    3333using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
     
    8585    }
    8686
    87     public GEArtificialAntProblem()
    88       : base() {
     87    public GEArtificialAntProblem() : base(new IntegerVectorEncoding()) {
    8988      wrappedAntProblem = new HeuristicLab.Problems.GeneticProgramming.ArtificialAnt.Problem();
    9089      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", wrappedAntProblem.World));
     
    9291      Parameters.Add(new ValueParameter<IGenotypeToPhenotypeMapper>("GenotypeToPhenotypeMapper", "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).", new DepthFirstMapper()));
    9392
    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 } });
    9595
    9696      BestKnownQuality = wrappedAntProblem.BestKnownQuality;
Note: See TracChangeset for help on using the changeset viewer.