- Timestamp:
- 07/23/17 00:52:14 (7 years ago)
- Location:
- branches/Async
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Optimizer
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimizer (added) merged: 13397,13406,13433-13434,13567,13586,13671,13681,13813
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
r12680 r15280 26 26 using System.Linq; 27 27 using System.Text; 28 using System.Threading;29 28 using System.Windows.Forms; 30 29 using HeuristicLab.Core; … … 56 55 private bool createBatchRun; 57 56 private int repetitions; 58 private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> instances;59 private Dictionary<IValueParameter, IntArray> intParameters;60 private Dictionary<IValueParameter, DoubleArray> doubleParameters;61 private HashSet<IValueParameter> boolParameters;62 private Dictionary<IValueParameter, HashSet<IItem>> multipleChoiceParameters;63 private IItem optionalNullChoice = new BoolValue(); // any item will do57 private readonly Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> instances; 58 private readonly Dictionary<IValueParameter, IntArray> intParameters; 59 private readonly Dictionary<IValueParameter, DoubleArray> doubleParameters; 60 private readonly HashSet<IValueParameter> boolParameters; 61 private readonly Dictionary<IValueParameter, HashSet<IItem>> multipleChoiceParameters; 62 private readonly IItem optionalNullChoice = new BoolValue(); // any item will do 64 63 65 64 private StringBuilder failedInstances; 66 private EventWaitHandle backgroundWorkerWaitHandle = new ManualResetEvent(false);67 65 private bool suppressTreeViewEventHandling, suppressCheckAllNoneEventHandling; 68 66 … … 105 103 SetMode(DialogMode.CreatingExperiment); 106 104 experimentCreationBackgroundWorker.RunWorkerAsync(); 107 backgroundWorkerWaitHandle.WaitOne(); // make sure the background worker has started before exiting108 105 } 109 106 … … 343 340 selectAllCheckBox.Checked = treeViewNodes.Count() == instances.SelectMany(x => x.Value).Count(); 344 341 selectNoneCheckBox.Checked = !treeViewNodes.Any(x => x.Checked); 345 } finally { suppressCheckAllNoneEventHandling = false; } 342 } 343 finally { suppressCheckAllNoneEventHandling = false; } 346 344 UpdateVariationsLabel(); 347 345 } … … 357 355 } 358 356 } 359 } finally { suppressTreeViewEventHandling = false; } 357 } 358 finally { suppressTreeViewEventHandling = false; } 360 359 } 361 360 … … 379 378 try { 380 379 node.Parent.Checked = allChecked; 381 } finally { suppressTreeViewEventHandling = false; } 380 } 381 finally { suppressTreeViewEventHandling = false; } 382 382 } 383 383 } … … 387 387 if (selectAllCheckBox.Checked) { 388 388 suppressCheckAllNoneEventHandling = true; 389 try { selectNoneCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; } 389 try { selectNoneCheckBox.Checked = false; } 390 finally { suppressCheckAllNoneEventHandling = false; } 390 391 try { 391 392 suppressTreeViewEventHandling = true; … … 396 397 } 397 398 } 398 } finally { suppressTreeViewEventHandling = false; } 399 } 400 finally { suppressTreeViewEventHandling = false; } 399 401 } 400 402 UpdateVariationsLabel(); … … 406 408 if (selectNoneCheckBox.Checked) { 407 409 suppressCheckAllNoneEventHandling = true; 408 try { selectAllCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; } 410 try { selectAllCheckBox.Checked = false; } 411 finally { suppressCheckAllNoneEventHandling = false; } 409 412 try { 410 413 suppressTreeViewEventHandling = true; … … 415 418 } 416 419 } 417 } finally { suppressTreeViewEventHandling = false; } 420 } 421 finally { suppressTreeViewEventHandling = false; } 418 422 } 419 423 UpdateVariationsLabel(); … … 482 486 || typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(param.GetType().GetGenericTypeDefinition()) 483 487 || typeof(ConstrainedValueParameter<>).IsAssignableFrom(param.GetType().GetGenericTypeDefinition())) 484 parametersListView.Items.Add(new ListViewItem(param.Name) { Tag = param });488 parametersListView.Items.Add(new ListViewItem(param.Name) { Tag = param, ToolTipText = param.Description }); 485 489 } 486 490 } … … 720 724 var node = new TreeNode(desc.Name) { Tag = desc }; 721 725 providerNode.Nodes.Add(node); 722 if (providerNode.Nodes.Count == 1) 723 nodes.Add(providerNode); 724 } 725 double progress = nodes.Count > 0 ? i / (double)nodes.Count : 0.0; 726 } 727 728 //Do not add instance providers without data descriptors 729 if (providerNode.Nodes.Count > 0) { 730 nodes.Add(providerNode); 731 } 732 733 double progress = nodes.Count > 0 ? i / (double)instanceProviders.Length : 0.0; 726 734 instanceDiscoveryBackgroundWorker.ReportProgress((int)(100 * progress), provider.Name); 727 735 } … … 744 752 } 745 753 selectNoneCheckBox.Checked = true; 746 } catch { } 754 } 755 catch { } 747 756 try { 748 757 SetMode(DialogMode.Normal); 749 758 if (e.Error != null) MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error); 750 } catch { } 759 } 760 catch { } 751 761 } 752 762 #endregion … … 754 764 #region Experiment creation 755 765 private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { 756 backgroundWorkerWaitHandle.Set(); // notify the ok button that we're busy now757 766 failedInstances = new StringBuilder(); 758 767 var localExperiment = new Experiment(); … … 763 772 try { 764 773 AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations); 765 } catch (OperationCanceledException) { 774 } 775 catch (OperationCanceledException) { 766 776 e.Cancel = true; 767 777 return; … … 775 785 try { 776 786 ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem); 777 } catch (Exception ex) { 787 } 788 catch (Exception ex) { 778 789 failedInstances.AppendLine(descriptor.Name + ": " + ex.Message); 779 790 failed = true; … … 788 799 AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations); 789 800 } 790 } catch (OperationCanceledException) { 801 } 802 catch (OperationCanceledException) { 791 803 e.Cancel = true; 792 804 return; … … 883 895 && typeof(EnumValue<>).IsAssignableFrom(m.Key.Value.GetType().GetGenericTypeDefinition())) { 884 896 var valueParam = (IValueParameter)variant.Parameters[m.Key.Name]; 885 valueParam.Value = m.Value; 897 dynamic targetEnumValue = valueParam.Value; 898 dynamic sourceEnumValue = m.Value; 899 targetEnumValue.Value = sourceEnumValue.Value; 886 900 variant.Name += m.Key.Name + "=" + m.Value + ", "; 887 901 } else { … … 937 951 Close(); 938 952 } 939 } catch { } 953 } 954 catch { } 940 955 } 941 956 #endregion
Note: See TracChangeset
for help on using the changeset viewer.