Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/30/12 17:24:16 (12 years ago)
Author:
spimming
Message:

#1807:

  • wizard page to view generated experiments
  • generate experiments according to example
  • plugin frame adapted
  • new version of problem view dialog included
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysisService/HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard/3.3/MediumAnalysisPage.cs

    r7912 r7939  
    33using System.Linq;
    44using HeuristicLab.Algorithms.DataAnalysis;
     5using HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm;
     6using HeuristicLab.Common;
    57using HeuristicLab.Data;
    68using HeuristicLab.Encodings.ParameterConfigurationTreeEncoding;
    79using HeuristicLab.Optimization;
    810using HeuristicLab.Problems.DataAnalysis;
     11using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
    912namespace HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard {
    1013  public partial class MediumAnalysisPage : HeuristicLab.ExperimentGeneration.DataAnalysis.Wizard.WizardPage {
     14    private const int nrOfRepetitions = 10;
     15    private const string gaCrossover = "SubtreeSwappingCrossover";
     16    private const string gaMutator = "MultiSymbolicExpressionTreeManipulator";
     17    private const string gaSelector = "GenderSpecificSelection";
     18
    1119    private BackgroundWorker worker;
    1220
     
    2230      worker.DoWork += new DoWorkEventHandler(GenerateExperimentsTask);
    2331      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
     32      worker.WorkerReportsProgress = true;
     33      worker.ProgressChanged += new ProgressChangedEventHandler(WorkerProgressChanged);
    2434
    2535    }
     
    2838      DataAnalysisWizardContext c = e.Argument as DataAnalysisWizardContext;
    2939      IProblem problem = c.Problem;
     40
     41      // SVR Experiment -------------------------------------------------------
    3042      SupportVectorRegression svr = new SupportVectorRegression();
    3143      svr.Problem = (IRegressionProblem)problem;
    3244      ParameterConfigurationTree vc = new ParameterConfigurationTree(svr, problem);
    33       var nuPc = vc.AlgorithmConfiguration.ParameterConfigurations.Where(x => x.ParameterName == "Nu").SingleOrDefault();
    34       nuPc.Optimize = true;
    35       var nuVc = (RangeValueConfiguration)nuPc.ValueConfigurations.First();
    36       nuVc.Optimize = true;
    37       nuVc.RangeConstraint = new DoubleValueRange(new DoubleValue(0.1), new DoubleValue(0.9), new DoubleValue(0.1));
    3845
    39       var costPc = vc.AlgorithmConfiguration.ParameterConfigurations.Where(x => x.ParameterName == "Cost").SingleOrDefault();
    40       costPc.Optimize = true;
    41       var costVc = (RangeValueConfiguration)costPc.ValueConfigurations.First();
    42       costVc.Optimize = true;
    43       costVc.RangeConstraint = new DoubleValueFactorRange(new DoubleValue(0.03125), new DoubleValue(32768), new DoubleValue(4));
     46      var nuRange = new DoubleValueRange(new DoubleValue(0.1), new DoubleValue(0.9), new DoubleValue(0.1));
     47      SetParameterRangeContraint(vc, "Nu", nuRange);
    4448
    45       var gammaPc = vc.AlgorithmConfiguration.ParameterConfigurations.Where(x => x.ParameterName == "Gamma").SingleOrDefault();
    46       gammaPc.Optimize = true;
    47       var gammaVc = (RangeValueConfiguration)gammaPc.ValueConfigurations.First();
    48       gammaVc.Optimize = true;
    49       gammaVc.RangeConstraint = new DoubleValueFactorRange(new DoubleValue(6.10352E-05), new DoubleValue(64), new DoubleValue(4));
     49      var costRange = new DoubleValueFactorRange(new DoubleValue(0.03125), new DoubleValue(32768), new DoubleValue(4));
     50      SetParameterRangeContraint(vc, "Cost", costRange);
    5051
    51       Experiment experiment = vc.GenerateExperiment(svr);
     52      var gammaRange = new DoubleValueFactorRange(new DoubleValue(6.10352E-05), new DoubleValue(64), new DoubleValue(4));
     53      SetParameterRangeContraint(vc, "Gamma", gammaRange);
     54      worker.ReportProgress(5);
     55      Experiment svrExperiment = vc.GenerateExperiment(svr);
     56      // ======================================================================
     57      worker.ReportProgress(20);
     58
     59      // RF Experiment --------------------------------------------------------
     60      RandomForestRegression rfr = new RandomForestRegression();
     61      rfr.Problem = (IRegressionProblem)problem;
     62      ParameterConfigurationTree rfConfig = new ParameterConfigurationTree(rfr, problem);
     63      var rRange = new DoubleValueRange(new DoubleValue(0.1), new DoubleValue(0.7), new DoubleValue(0.1));
     64      SetParameterRangeContraint(rfConfig, "R", rRange);
     65      var treeRange = new IntValueRange(new IntValue(250), new IntValue(250), new IntValue(250));
     66      SetParameterRangeContraint(rfConfig, "Number of trees", treeRange);
     67      Experiment rfrExperiment = rfConfig.GenerateExperiment(rfr);
     68      // ======================================================================
     69      worker.ReportProgress(40);
     70      // NN Experiment --------------------------------------------------------
     71      NeuralNetworkRegression nnr = new NeuralNetworkRegression();
     72      nnr.Problem = (IRegressionProblem)problem;
     73      ParameterConfigurationTree nnrConfig = new ParameterConfigurationTree(nnr, problem);
     74      var decayRange = new DoubleValueFactorRange(new DoubleValue(0.001), new DoubleValue(100), new DoubleValue(10));
     75      SetParameterRangeContraint(nnrConfig, "Decay", decayRange);
     76      var nodesRange = new IntValueFactorRange(new IntValue(1), new IntValue(100), new IntValue(3));
     77      SetParameterRangeContraint(nnrConfig, "NodesInFirstHiddenLayer", nodesRange);
     78      Experiment nnrExperiment = nnrConfig.GenerateExperiment(nnr);
     79      // ======================================================================
     80      worker.ReportProgress(60);
     81      // GP Experiment --------------------------------------------------------
     82      OffspringSelectionGeneticAlgorithm osga = new OffspringSelectionGeneticAlgorithm();
     83      var prob = new SymbolicRegressionSingleObjectiveProblem();
     84      prob.ProblemData = ((IRegressionProblem)problem).ProblemData;
     85      //prob.SolutionCreator = new MultiSymbolicDataAnalysisExpressionCreator();
     86      osga.Problem = prob;
     87      osga.ComparisonFactorLowerBound.Value = 1;
     88      osga.Crossover = osga.Problem.Operators.OfType<ICrossover>().FirstOrDefault(x => x.Name == gaCrossover);
     89      osga.MaximumEvaluatedSolutions.Value = 500000;
     90      osga.MaximumGenerations.Value = 100;
     91      osga.MutationProbability = new PercentValue(0.15);
     92      osga.Mutator = osga.Problem.Operators.OfType<IManipulator>().FirstOrDefault(x => x.Name == gaMutator);
     93      osga.PopulationSize.Value = 500;
     94      osga.Selector = osga.SelectorParameter.ValidValues.FirstOrDefault(x => x.Name == gaSelector);
     95
     96      CrossValidation crossSmall = new CrossValidation();
     97      crossSmall.Algorithm = osga;
     98      BatchRun batchSmall = new BatchRun("small");
     99      batchSmall.Repetitions = nrOfRepetitions;
     100      batchSmall.Optimizer = crossSmall;
     101
     102      CrossValidation crossMedium = (CrossValidation)crossSmall.Clone(new Cloner());
     103      var probMedium = (SymbolicRegressionSingleObjectiveProblem)prob.Clone(new Cloner());
     104      probMedium.MaximumSymbolicExpressionTreeDepth.Value = 12;
     105      probMedium.MaximumSymbolicExpressionTreeLength.Value = 125;
     106      crossMedium.Algorithm.Problem = probMedium;
     107      BatchRun batchMedium = new BatchRun("medium");
     108      batchMedium.Repetitions = nrOfRepetitions;
     109      batchMedium.Optimizer = crossMedium;
     110
     111      CrossValidation crossLarge = (CrossValidation)crossSmall.Clone(new Cloner());
     112      var probLarge = (SymbolicRegressionSingleObjectiveProblem)prob.Clone(new Cloner());
     113      probLarge.MaximumSymbolicExpressionTreeDepth.Value = 17;
     114      probLarge.MaximumSymbolicExpressionTreeLength.Value = 250;
     115      crossLarge.Algorithm.Problem = probLarge;
     116      BatchRun batchLarge = new BatchRun("large");
     117      batchLarge.Repetitions = nrOfRepetitions;
     118      batchLarge.Optimizer = crossLarge;
     119
     120      Experiment gpExperiment = new Experiment();
     121      gpExperiment.Optimizers.Add(batchSmall);
     122      gpExperiment.Optimizers.Add(batchMedium);
     123      gpExperiment.Optimizers.Add(batchLarge);
     124      // ======================================================================
     125      worker.ReportProgress(80);
     126
     127      Experiment experiment = new Experiment("Data Analysis Experiment");
     128      experiment.Optimizers.Add(svrExperiment);
     129      experiment.Optimizers.Add(rfrExperiment);
     130      experiment.Optimizers.Add(nnrExperiment);
     131      experiment.Optimizers.Add(gpExperiment);
     132
     133      worker.ReportProgress(100);
     134
    52135      e.Result = experiment;
     136    }
     137
     138    private void SetParameterRangeContraint(ParameterConfigurationTree pct, string parameterName, IRange rangeContraint) {
     139      var pc = pct.AlgorithmConfiguration.ParameterConfigurations.Where(x => x.ParameterName == parameterName).SingleOrDefault();
     140      pc.Optimize = true;
     141      var vc = (RangeValueConfiguration)pc.ValueConfigurations.First();
     142      vc.Optimize = true;
     143      vc.RangeConstraint = rangeContraint;
     144
     145    }
     146
     147    private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e) {
     148      progressBar1.Value = e.ProgressPercentage;
    53149    }
    54150
Note: See TracChangeset for help on using the changeset viewer.