Changeset 9364 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentDialog.cs
- Timestamp:
- 04/16/13 16:23:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentDialog.cs
r9361 r9364 44 44 set { 45 45 optimizer = value; 46 Experiment = null;46 Experiments = null; 47 47 okButton.Enabled = optimizer != null; 48 48 SetTabControlVisibility(); … … 52 52 } 53 53 54 public Experiment Experiment{ get; private set; }54 public List<Experiment> Experiments { get; private set; } 55 55 56 56 private bool createBatchRun; … … 75 75 // do not set the Optimizer property here, because we want to delay instance discovery to the time when the form loads 76 76 this.optimizer = optimizer; 77 Experiment = null;77 Experiments = null; 78 78 okButton.Enabled = optimizer != null; 79 79 … … 715 715 private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { 716 716 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; 744 739 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 } 751 755 } 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 } 767 772 } 768 773
Note: See TracChangeset
for help on using the changeset viewer.