Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/17 00:52:14 (7 years ago)
Author:
abeham
Message:

#2258: merged r13329:14000 from trunk into branch

Location:
branches/Async
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Async

  • branches/Async/HeuristicLab.Optimizer

  • branches/Async/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r12680 r15280  
    2626using System.Linq;
    2727using System.Text;
    28 using System.Threading;
    2928using System.Windows.Forms;
    3029using HeuristicLab.Core;
     
    5655    private bool createBatchRun;
    5756    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 do
     57    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
    6463
    6564    private StringBuilder failedInstances;
    66     private EventWaitHandle backgroundWorkerWaitHandle = new ManualResetEvent(false);
    6765    private bool suppressTreeViewEventHandling, suppressCheckAllNoneEventHandling;
    6866
     
    105103      SetMode(DialogMode.CreatingExperiment);
    106104      experimentCreationBackgroundWorker.RunWorkerAsync();
    107       backgroundWorkerWaitHandle.WaitOne(); // make sure the background worker has started before exiting
    108105    }
    109106
     
    343340          selectAllCheckBox.Checked = treeViewNodes.Count() == instances.SelectMany(x => x.Value).Count();
    344341          selectNoneCheckBox.Checked = !treeViewNodes.Any(x => x.Checked);
    345         } finally { suppressCheckAllNoneEventHandling = false; }
     342        }
     343        finally { suppressCheckAllNoneEventHandling = false; }
    346344        UpdateVariationsLabel();
    347345      }
     
    357355          }
    358356        }
    359       } finally { suppressTreeViewEventHandling = false; }
     357      }
     358      finally { suppressTreeViewEventHandling = false; }
    360359    }
    361360
     
    379378        try {
    380379          node.Parent.Checked = allChecked;
    381         } finally { suppressTreeViewEventHandling = false; }
     380        }
     381        finally { suppressTreeViewEventHandling = false; }
    382382      }
    383383    }
     
    387387        if (selectAllCheckBox.Checked) {
    388388          suppressCheckAllNoneEventHandling = true;
    389           try { selectNoneCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; }
     389          try { selectNoneCheckBox.Checked = false; }
     390          finally { suppressCheckAllNoneEventHandling = false; }
    390391          try {
    391392            suppressTreeViewEventHandling = true;
     
    396397              }
    397398            }
    398           } finally { suppressTreeViewEventHandling = false; }
     399          }
     400          finally { suppressTreeViewEventHandling = false; }
    399401        }
    400402        UpdateVariationsLabel();
     
    406408        if (selectNoneCheckBox.Checked) {
    407409          suppressCheckAllNoneEventHandling = true;
    408           try { selectAllCheckBox.Checked = false; } finally { suppressCheckAllNoneEventHandling = false; }
     410          try { selectAllCheckBox.Checked = false; }
     411          finally { suppressCheckAllNoneEventHandling = false; }
    409412          try {
    410413            suppressTreeViewEventHandling = true;
     
    415418              }
    416419            }
    417           } finally { suppressTreeViewEventHandling = false; }
     420          }
     421          finally { suppressTreeViewEventHandling = false; }
    418422        }
    419423        UpdateVariationsLabel();
     
    482486            || typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(param.GetType().GetGenericTypeDefinition())
    483487            || 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 });
    485489        }
    486490      }
     
    720724          var node = new TreeNode(desc.Name) { Tag = desc };
    721725          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;
    726734        instanceDiscoveryBackgroundWorker.ReportProgress((int)(100 * progress), provider.Name);
    727735      }
     
    744752        }
    745753        selectNoneCheckBox.Checked = true;
    746       } catch { }
     754      }
     755      catch { }
    747756      try {
    748757        SetMode(DialogMode.Normal);
    749758        if (e.Error != null) MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
    750       } catch { }
     759      }
     760      catch { }
    751761    }
    752762    #endregion
     
    754764    #region Experiment creation
    755765    private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
    756       backgroundWorkerWaitHandle.Set(); // notify the ok button that we're busy now
    757766      failedInstances = new StringBuilder();
    758767      var localExperiment = new Experiment();
     
    763772        try {
    764773          AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
    765         } catch (OperationCanceledException) {
     774        }
     775        catch (OperationCanceledException) {
    766776          e.Cancel = true;
    767777          return;
     
    775785            try {
    776786              ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
    777             } catch (Exception ex) {
     787            }
     788            catch (Exception ex) {
    778789              failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
    779790              failed = true;
     
    788799                  AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
    789800                }
    790               } catch (OperationCanceledException) {
     801              }
     802              catch (OperationCanceledException) {
    791803                e.Cancel = true;
    792804                return;
     
    883895                && typeof(EnumValue<>).IsAssignableFrom(m.Key.Value.GetType().GetGenericTypeDefinition())) {
    884896              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;
    886900              variant.Name += m.Key.Name + "=" + m.Value + ", ";
    887901            } else {
     
    937951          Close();
    938952        }
    939       } catch { }
     953      }
     954      catch { }
    940955    }
    941956    #endregion
Note: See TracChangeset for help on using the changeset viewer.