source: branches/DataAnalysisService/HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard/3.3/MediumAnalysisPage.cs @ 7912

Last change on this file since 7912 was 7912, checked in by spimming, 9 years ago

#1807:

  • adapted plugin frame
  • added new wizard page to view generated experiment
  • generate experiments in backgroundworker
File size: 3.2 KB
Line 
1
2using System.ComponentModel;
3using System.Linq;
4using HeuristicLab.Algorithms.DataAnalysis;
5using HeuristicLab.Data;
6using HeuristicLab.Encodings.ParameterConfigurationTreeEncoding;
7using HeuristicLab.Optimization;
8using HeuristicLab.Problems.DataAnalysis;
9namespace HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard {
10  public partial class MediumAnalysisPage : HeuristicLab.ExperimentGeneration.DataAnalysis.Wizard.WizardPage {
11    private BackgroundWorker worker;
12
13    private DataAnalysisWizardContext context;
14    public DataAnalysisWizardContext Context {
15      get { return context; }
16    }
17
18    public MediumAnalysisPage(DataAnalysisWizardContext context) {
19      InitializeComponent();
20      this.context = context;
21      worker = new BackgroundWorker();
22      worker.DoWork += new DoWorkEventHandler(GenerateExperimentsTask);
23      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
24
25    }
26
27    private void GenerateExperimentsTask(object sender, DoWorkEventArgs e) {
28      DataAnalysisWizardContext c = e.Argument as DataAnalysisWizardContext;
29      IProblem problem = c.Problem;
30      SupportVectorRegression svr = new SupportVectorRegression();
31      svr.Problem = (IRegressionProblem)problem;
32      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));
38
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));
44
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));
50
51      Experiment experiment = vc.GenerateExperiment(svr);
52      e.Result = experiment;
53    }
54
55    private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
56      SetWizardButton(Wizard.WizardButtons.Next);
57      Experiment experiment = (Experiment)e.Result;
58      context.Experiment = experiment;
59    }
60
61    private void MediumAnalysisPage_WizardBack(object sender, Wizard.WizardPageEventArgs e) {
62      e.NewPage = "SelectAnalysisPage";
63    }
64
65    private void MediumAnalysisPage_SetActive(object sender, System.ComponentModel.CancelEventArgs e) {
66      SetWizardButton(Wizard.WizardButtons.None);
67      worker.RunWorkerAsync(context);
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.