Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/13 16:23:59 (12 years ago)
Author:
ascheibe
Message:

#1886 added repetitions for random parameter configurations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentDialog.cs

    r9361 r9364  
    4444      set {
    4545        optimizer = value;
    46         Experiment = null;
     46        Experiments = null;
    4747        okButton.Enabled = optimizer != null;
    4848        SetTabControlVisibility();
     
    5252    }
    5353
    54     public Experiment Experiment { get; private set; }
     54    public List<Experiment> Experiments { get; private set; }
    5555
    5656    private bool createBatchRun;
     
    7575      // do not set the Optimizer property here, because we want to delay instance discovery to the time when the form loads
    7676      this.optimizer = optimizer;
    77       Experiment = null;
     77      Experiments = null;
    7878      okButton.Enabled = optimizer != null;
    7979
     
    715715    private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
    716716      backgroundWorkerWaitHandle.Set(); // notify the ok button that we're busy now
    717       failedInstances = new StringBuilder();
    718       var localExperiment = new Experiment();
    719 
    720       int counter = 0, totalVariations = GetNumberOfVariations();
    721       int totalInstances = instances.Values.SelectMany(x => x).Count();
    722       if (totalInstances == 0) {
    723         try {
    724           AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
    725         }
    726         catch (OperationCanceledException) {
    727           e.Cancel = true;
    728           return;
    729         }
    730         experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
    731       } else {
    732         foreach (var provider in instances.Keys) {
    733           foreach (var descriptor in instances[provider]) {
    734             var algorithm = (IAlgorithm)Optimizer.Clone();
    735             bool failed = false;
    736             try {
    737               ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
    738             }
    739             catch (Exception ex) {
    740               failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
    741               failed = true;
    742             }
    743             if (!failed) {
     717
     718      int b = int.Parse(repetitionsTextBox.Text);
     719      for (int i = 0; i < b; i++) {
     720        failedInstances = new StringBuilder();
     721        var localExperiment = new Experiment();
     722
     723        int counter = 0, totalVariations = GetNumberOfVariations();
     724        int totalInstances = instances.Values.SelectMany(x => x).Count();
     725        if (totalInstances == 0) {
     726          try {
     727            AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
     728          }
     729          catch (OperationCanceledException) {
     730            e.Cancel = true;
     731            return;
     732          }
     733          experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
     734        } else {
     735          foreach (var provider in instances.Keys) {
     736            foreach (var descriptor in instances[provider]) {
     737              var algorithm = (IAlgorithm)Optimizer.Clone();
     738              bool failed = false;
    744739              try {
    745                 if (totalInstances > 1 && totalVariations / totalInstances > 1) {
    746                   var experiment = new Experiment(descriptor.Name);
    747                   AddParameterVariations(algorithm, experiment, ref counter, totalVariations);
    748                   localExperiment.Optimizers.Add(experiment);
    749                 } else {
    750                   AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     740                ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
     741              }
     742              catch (Exception ex) {
     743                failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
     744                failed = true;
     745              }
     746              if (!failed) {
     747                try {
     748                  if (totalInstances > 1 && totalVariations / totalInstances > 1) {
     749                    var experiment = new Experiment(descriptor.Name);
     750                    AddParameterVariations(algorithm, experiment, ref counter, totalVariations);
     751                    localExperiment.Optimizers.Add(experiment);
     752                  } else {
     753                    AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     754                  }
    751755                }
    752               }
    753               catch (OperationCanceledException) {
    754                 e.Cancel = true;
    755                 return;
    756               }
    757             } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
    758           }
    759         }
    760       }
    761       // this step can take some time
    762       SetMode(DialogMode.PreparingExperiment);
    763       experimentCreationBackgroundWorker.ReportProgress(-1);
    764       localExperiment.Prepare(true);
    765       experimentCreationBackgroundWorker.ReportProgress(100);
    766       Experiment = localExperiment;
     756                catch (OperationCanceledException) {
     757                  e.Cancel = true;
     758                  return;
     759                }
     760              } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
     761            }
     762          }
     763        }
     764        // this step can take some time
     765        SetMode(DialogMode.PreparingExperiment);
     766        experimentCreationBackgroundWorker.ReportProgress(-1);
     767        localExperiment.Prepare(true);
     768        experimentCreationBackgroundWorker.ReportProgress(100);
     769        if (Experiments == null) Experiments = new List<Experiment>();
     770        Experiments.Add(localExperiment);
     771      }
    767772    }
    768773
Note: See TracChangeset for help on using the changeset viewer.