Changeset 13163


Ignore:
Timestamp:
11/15/15 15:38:50 (3 years ago)
Author:
gkronber
Message:

#2472: adapted the multiplexer sample to use the specific implementation of the multiplexer problem instead of symbolic regression. Added best known solutions for the Boolean benchmark problems

Location:
trunk/sources
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs

    r12938 r13163  
    8484
    8585      Encoding.Grammar = g;
     86
     87      BestKnownQuality = Math.Pow(2, NumberOfBits); // this is a benchmark problem (the best achievable quality is known for a given number of bits)
    8688    }
    8789
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs

    r12940 r13163  
    9898
    9999      Encoding.Grammar = g;
     100
     101      BestKnownQuality = Math.Pow(2, NumberOfBits); // this is a benchmark problem (the best achievable quality is known for a given number of bits)
    100102    }
    101103
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPMultiplexerSampleTest.cs

    r13160 r13163  
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.Xml;
    26 using HeuristicLab.Problems.DataAnalysis.Symbolic;
    27 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
    28 using HeuristicLab.Problems.Instances.DataAnalysis;
    2926using HeuristicLab.Selection;
    3027using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    5148      SamplesUtils.RunAlgorithm(osga);
    5249
    53       Assert.AreEqual(0.125, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8);
    54       Assert.AreEqual(0.237275390625, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8);
    55       Assert.AreEqual(1.181640625, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8);
    56       Assert.AreEqual(105500, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"));
     50      Assert.AreEqual(1856, SamplesUtils.GetDoubleResult(osga, "BestQuality"), 1E-8);
     51      Assert.AreEqual(1784.76, SamplesUtils.GetDoubleResult(osga, "CurrentAverageQuality"), 1E-8);
     52      Assert.AreEqual(1536, SamplesUtils.GetDoubleResult(osga, "CurrentWorstQuality"), 1E-8);
     53      Assert.AreEqual(66900, SamplesUtils.GetIntResult(osga, "EvaluatedSolutions"));
    5754    }
    5855
    5956    public static OffspringSelectionGeneticAlgorithm CreateGpMultiplexerSample() {
    60       var instanceProvider = new RegressionCSVInstanceProvider();
    61       var regressionImportType = new RegressionImportType();
    62       regressionImportType.TargetVariable = "output";
    63       regressionImportType.TrainingPercentage = 100;
    64       var dataAnalysisCSVFormat = new DataAnalysisCSVFormat();
    65       dataAnalysisCSVFormat.Separator = ',';
    66       dataAnalysisCSVFormat.VariableNamesAvailable = true;
    67 
    68       var problemData = instanceProvider.ImportData(@"Test Resources\Multiplexer11.csv", regressionImportType, dataAnalysisCSVFormat);
    69       problemData.Name = "11-Multiplexer";
    70 
    71       var problem = new SymbolicRegressionSingleObjectiveProblem();
     57      var problem = new HeuristicLab.Problems.GeneticProgramming.Boolean.MultiplexerProblem();
    7258      problem.Name = "11-Multiplexer Problem";
    73       problem.ProblemData = problemData;
    74       problem.MaximumSymbolicExpressionTreeLength.Value = 50;
    75       problem.MaximumSymbolicExpressionTreeDepth.Value = 50;
    76       problem.EvaluatorParameter.Value = new SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator();
    77       problem.ApplyLinearScaling.Value = false;
    78 
    79 
    80       var grammar = new FullFunctionalExpressionGrammar();
    81       problem.SymbolicExpressionTreeGrammar = grammar;
    82       foreach (var symbol in grammar.Symbols) {
    83         if (symbol is ProgramRootSymbol) symbol.Enabled = true;
    84         else if (symbol is StartSymbol) symbol.Enabled = true;
    85         else if (symbol is IfThenElse) symbol.Enabled = true;
    86         else if (symbol is And) symbol.Enabled = true;
    87         else if (symbol is Or) symbol.Enabled = true;
    88         else if (symbol is Xor) symbol.Enabled = true;
    89         else if (symbol.GetType() == typeof(Variable)) {
    90           //necessary as there are multiple classes derived from Variable (e.g., VariableCondition)
    91           symbol.Enabled = true;
    92           var variableSymbol = (Variable)symbol;
    93           variableSymbol.MultiplicativeWeightManipulatorSigma = 0.0;
    94           variableSymbol.WeightManipulatorSigma = 0.0;
    95           variableSymbol.WeightSigma = 0.0;
    96         } else symbol.Enabled = false;
    97       }
     59      problem.Encoding.TreeLength = 50;
     60      problem.Encoding.TreeDepth = 50;
    9861
    9962      var osga = new OffspringSelectionGeneticAlgorithm();
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r13064 r13163  
    629629      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    630630    </None>
    631     <None Include="Test Resources\Multiplexer11.csv">
    632       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    633     </None>
    634631    <None Include="Test Resources\SamplesExperimentFinished.hl">
    635632      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Note: See TracChangeset for help on using the changeset viewer.