- Timestamp:
- 07/03/12 16:46:35 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:mergeinfo changed
/trunk/sources merged: 8084,8088-8090,8092-8100,8102-8113,8115,8117-8132,8134-8146,8148-8156,8158-8160,8163-8170,8173-8176,8178-8190,8192-8205
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
r8085 r8206 126 126 if (intValue != null) { 127 127 if (e.Item.Checked) { 128 intParameters.Add(parameter, new IntArray()); 128 IntArray initialValues; 129 if (intValue.Value == int.MinValue) 130 initialValues = new IntArray(new int[] { -100, -50, 5 }); 131 else if (intValue.Value == int.MaxValue) 132 initialValues = new IntArray(new int[] { 5, 50, 100 }); 133 else if (intValue.Value == 0) 134 initialValues = new IntArray(new int[] { 0, 1, 2 }); 135 else if (Math.Abs(intValue.Value) < 10) 136 initialValues = new IntArray(new int[] { intValue.Value - 1, intValue.Value, intValue.Value + 1 }); 137 else initialValues = new IntArray(new int[] { intValue.Value / 2, intValue.Value, intValue.Value * 2 }); 138 intParameters.Add(parameter, initialValues); 129 139 intParameters[parameter].Reset += new EventHandler(ValuesArray_Reset); 130 140 } else intParameters.Remove(parameter); … … 134 144 if (doubleValue != null) { 135 145 if (e.Item.Checked) { 136 doubleParameters.Add(parameter, new DoubleArray()); 146 DoubleArray initialValues; 147 if (doubleValue.Value == double.MinValue) 148 initialValues = new DoubleArray(new double[] { -1, -0.5, 0 }); 149 else if (doubleValue.Value == double.MaxValue) 150 initialValues = new DoubleArray(new double[] { 0, 0.5, 1 }); 151 else if (doubleValue.Value == 0.0) 152 initialValues = new DoubleArray(new double[] { 0, 0.1, 0.2 }); 153 else if (Math.Abs(doubleValue.Value) <= 1.0) { 154 if (doubleValue.Value > 0.9 || (doubleValue.Value < 0.0 && doubleValue.Value > -0.1)) 155 initialValues = new DoubleArray(new double[] { doubleValue.Value - 0.2, doubleValue.Value - 0.1, doubleValue.Value }); 156 else if (doubleValue.Value < -0.9 || (doubleValue.Value > 0 && doubleValue.Value < 0.1)) 157 initialValues = new DoubleArray(new double[] { doubleValue.Value, doubleValue.Value + 0.1, doubleValue.Value + 0.2 }); 158 else initialValues = new DoubleArray(new double[] { doubleValue.Value - 0.1, doubleValue.Value, doubleValue.Value + 0.1 }); 159 } else initialValues = new DoubleArray(new double[] { doubleValue.Value / 2.0, doubleValue.Value, doubleValue.Value * 2.0 }); 160 doubleParameters.Add(parameter, initialValues); 137 161 doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset); 138 162 } else doubleParameters.Remove(parameter); … … 295 319 selectAllCheckBox.Checked = treeViewNodes.Count() == instances.SelectMany(x => x.Value).Count(); 296 320 selectNoneCheckBox.Checked = !treeViewNodes.Any(x => x.Checked); 297 } 298 finally { suppressCheckAllNoneEventHandling = false; } 321 } finally { suppressCheckAllNoneEventHandling = false; } 299 322 UpdateVariationsLabel(); 300 323 } … … 310 333 } 311 334 } 312 } 313 finally { suppressTreeViewEventHandling = false; } 335 } finally { suppressTreeViewEventHandling = false; } 314 336 } 315 337 … … 333 355 try { 334 356 node.Parent.Checked = allChecked; 335 } 336 finally { suppressTreeViewEventHandling = false; } 357 } finally { suppressTreeViewEventHandling = false; } 337 358 } 338 359 } … … 342 363 if (selectAllCheckBox.Checked) { 343 364 suppressCheckAllNoneEventHandling = true; 344 try { selectNoneCheckBox.Checked = false; } 345 finally { suppressCheckAllNoneEventHandling = false; } 365 try { selectNoneCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; } 346 366 try { 347 367 suppressTreeViewEventHandling = true; … … 352 372 } 353 373 } 354 } 355 finally { suppressTreeViewEventHandling = false;}356 }374 } finally { suppressTreeViewEventHandling = false; } 375 } 376 UpdateVariationsLabel(); 357 377 } 358 378 } … … 362 382 if (selectNoneCheckBox.Checked) { 363 383 suppressCheckAllNoneEventHandling = true; 364 try { selectAllCheckBox.Checked = false; } 365 finally { suppressCheckAllNoneEventHandling = false; } 384 try { selectAllCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; } 366 385 try { 367 386 suppressTreeViewEventHandling = true; … … 372 391 } 373 392 } 374 } 375 finally { suppressTreeViewEventHandling = false;}376 }393 } finally { suppressTreeViewEventHandling = false; } 394 } 395 UpdateVariationsLabel(); 377 396 } 378 397 } … … 633 652 #region Instance discovery 634 653 private void instanceDiscoveryBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { 654 instanceDiscoveryBackgroundWorker.ReportProgress(0, "Finding instance providers..."); 635 655 var instanceProviders = ProblemInstanceManager.GetProviders(((IAlgorithm)Optimizer).Problem).ToArray(); 636 var nodes = new TreeNode[instanceProviders.Length];656 var nodes = new List<TreeNode>(instanceProviders.Length); 637 657 for (int i = 0; i < instanceProviders.Length; i++) { 638 658 var provider = instanceProviders[i]; 639 nodes[i] = new TreeNode(provider.Name) { Tag = provider }; 640 } 641 e.Result = nodes; 642 for (int i = 0; i < nodes.Length; i++) { 643 var providerNode = nodes[i]; 644 var provider = providerNode.Tag as IProblemInstanceProvider; 645 double progress = i / (double)nodes.Length; 646 instanceDiscoveryBackgroundWorker.ReportProgress((int)(100 * progress), provider.Name); 647 var descriptors = ProblemInstanceManager.GetDataDescriptors(provider).ToArray(); 648 for (int j = 0; j < descriptors.Length; j++) { 659 var providerNode = new TreeNode(provider.Name) { Tag = provider }; 660 var descriptors = ProblemInstanceManager.GetDataDescriptors(provider); 661 foreach (var desc in descriptors) { 649 662 #region Check cancellation request 650 663 if (instanceDiscoveryBackgroundWorker.CancellationPending) { 651 664 e.Cancel = true; 665 e.Result = nodes.ToArray(); 652 666 return; 653 667 } 654 668 #endregion 655 var node = new TreeNode(desc riptors[j].Name) { Tag = descriptors[j]};669 var node = new TreeNode(desc.Name) { Tag = desc }; 656 670 providerNode.Nodes.Add(node); 657 } 658 } 671 if (providerNode.Nodes.Count == 1) 672 nodes.Add(providerNode); 673 } 674 double progress = nodes.Count > 0 ? i / (double)nodes.Count : 0.0; 675 instanceDiscoveryBackgroundWorker.ReportProgress((int)(100 * progress), provider.Name); 676 } 677 e.Result = nodes.ToArray(); 659 678 instanceDiscoveryBackgroundWorker.ReportProgress(100, string.Empty); 660 679 } … … 664 683 instanceDiscoveryProgressBar.Value = e.ProgressPercentage; 665 684 instanceDiscoveryProgressLabel.Text = (string)e.UserState; 666 Application.DoEvents();667 685 } 668 686 669 687 private void instanceDiscoveryBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 670 688 try { 671 instancesTreeView.Nodes.AddRange((TreeNode[])e.Result); 672 foreach (TreeNode node in instancesTreeView.Nodes) 673 node.Collapse(); 689 if (((TreeNode[])e.Result).Length > 0) { 690 instancesTreeView.Nodes.AddRange((TreeNode[])e.Result); 691 foreach (TreeNode node in instancesTreeView.Nodes) 692 node.Collapse(); 693 } 674 694 selectNoneCheckBox.Checked = true; 675 } 676 catch { } 695 } catch { } 677 696 try { 678 697 SetMode(DialogMode.Normal); 679 698 if (e.Error != null) MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error); 680 } 681 catch { } 699 } catch { } 682 700 } 683 701 #endregion … … 695 713 } catch (OperationCanceledException) { 696 714 e.Cancel = true; 697 localExperiment = null;698 715 return; 699 716 } … … 715 732 } catch (OperationCanceledException) { 716 733 e.Cancel = true; 717 localExperiment = null;718 734 return; 719 735 } … … 722 738 } 723 739 } 724 if (localExperiment != null) { 725 // this step can take some time 726 SetMode(DialogMode.PreparingExperiment); 727 experimentCreationBackgroundWorker.ReportProgress(-1); 728 localExperiment.Prepare(true); 729 experimentCreationBackgroundWorker.ReportProgress(100); 730 } 740 // this step can take some time 741 SetMode(DialogMode.PreparingExperiment); 742 experimentCreationBackgroundWorker.ReportProgress(-1); 743 localExperiment.Prepare(true); 744 experimentCreationBackgroundWorker.ReportProgress(100); 731 745 Experiment = localExperiment; 732 746 } 733 747 734 748 private void AddParameterVariations(IOptimizer optimizer, Experiment localExperiment, ref int counter, int totalVariations) { 735 var variations = experimentCreationBackgroundWorker_CalculateParameterVariations(optimizer);749 var variations = CalculateParameterVariations(optimizer); 736 750 foreach (var v in variations) { 737 751 if (experimentCreationBackgroundWorker.CancellationPending) … … 743 757 } 744 758 745 private IEnumerable<IOptimizer> experimentCreationBackgroundWorker_CalculateParameterVariations(IOptimizer optimizer) {759 private IEnumerable<IOptimizer> CalculateParameterVariations(IOptimizer optimizer) { 746 760 if (!boolParameters.Any() && !intParameters.Any() && !doubleParameters.Any() && !multipleChoiceParameters.Any()) { 747 761 var o = (IOptimizer)optimizer.Clone(); … … 847 861 experimentCreationProgressBar.Style = ProgressBarStyle.Marquee; 848 862 } 849 Application.DoEvents();850 863 } 851 864 … … 859 872 Close(); 860 873 } 861 } 862 catch { } 874 } catch { } 863 875 } 864 876 #endregion
Note: See TracChangeset
for help on using the changeset viewer.