Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/15 15:38:50 (9 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.