Changeset 12809


Ignore:
Timestamp:
07/29/15 13:07:08 (4 years ago)
Author:
pfleck
Message:

#2027 Merged trunk changes.

Location:
branches/TerminationCriteria
Files:
16 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/TerminationCriteria/HeuristicLab.Optimization

  • branches/TerminationCriteria/HeuristicLab.Optimization.Views

  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r12529 r12809  
    327327      <DependentUpon>RunCollectionChartAggregationView.cs</DependentUpon>
    328328    </Compile>
     329    <Compile Include="TimeLimitRunView.cs">
     330      <SubType>UserControl</SubType>
     331    </Compile>
     332    <Compile Include="TimeLimitRunView.Designer.cs">
     333      <DependentUpon>TimeLimitRunView.cs</DependentUpon>
     334    </Compile>
    329335    <Compile Include="ThresholdTerminatorView.cs">
    330336      <SubType>UserControl</SubType>
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame

    r12012 r12809  
    2626  /// Plugin class for HeuristicLab.Optimization.Views plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Optimization.Views", "3.3.11.$WCREV$")]
     28  [Plugin("HeuristicLab.Optimization.Views", "3.3.12.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Optimization.Views-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/Properties/AssemblyInfo.cs.frame

    r12012 r12809  
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.11.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.12.$WCREV$")]
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs

    r12077 r12809  
    345345      switch (axisDimension) {
    346346        case AxisDimension.Color: {
    347             value = GetCategoricalValue(-1, run.Color.ToString());
     347            const int colorDimension = -1;
     348            if (!categoricalMapping.ContainsKey(colorDimension)) {
     349              categoricalMapping[colorDimension] = Content.Where(r => r.Visible)
     350                  .Select(r => r.Color.Name)
     351                  .Distinct()
     352                  .OrderBy(c => c, new NaturalStringComparer())
     353                  .Select((c, i) => new { Color = c, Index = i })
     354                  .ToDictionary(a => (object)a.Color, a => (double)a.Index);
     355
     356            }
     357            value = GetCategoricalValue(colorDimension, run.Color.Name);
    348358            break;
    349359          }
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs

    r12012 r12809  
    2424using System.ComponentModel;
    2525using System.Linq;
    26 using System.Windows.Forms;
    2726using HeuristicLab.Analysis;
    2827using HeuristicLab.Collections;
     
    4140    }
    4241
    43     private int rowNumber = 0;
     42    private int rowNumber;
    4443    private bool suppressUpdates;
    4544    private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping;
     
    6059    protected override void RegisterContentEvents() {
    6160      base.RegisterContentEvents();
    62       Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    63       Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    64       Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    65       Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
    66       Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);
     61      Content.ItemsAdded += Content_ItemsAdded;
     62      Content.ItemsRemoved += Content_ItemsRemoved;
     63      Content.CollectionReset += Content_CollectionReset;
     64      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
     65      Content.OptimizerNameChanged += Content_AlgorithmNameChanged;
    6766    }
    6867    protected override void DeregisterContentEvents() {
    69       Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    70       Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    71       Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    72       Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
    73       Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
     68      Content.ItemsAdded -= Content_ItemsAdded;
     69      Content.ItemsRemoved -= Content_ItemsRemoved;
     70      Content.CollectionReset -= Content_CollectionReset;
     71      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
     72      Content.OptimizerNameChanged -= Content_AlgorithmNameChanged;
    7473      base.DeregisterContentEvents();
    7574    }
    7675
    7776    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     77      if (suppressUpdates) return;
    7878      if (InvokeRequired) {
    7979        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
    8080        return;
    8181      }
     82      UpdateDataTableComboBox();
     83      UpdateDataRowComboBox();
    8284      AddRuns(e.Items);
    8385    }
    8486    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     87      if (suppressUpdates) return;
    8588      if (InvokeRequired) {
    8689        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
    8790        return;
    8891      }
     92      UpdateDataTableComboBox();
     93      UpdateDataRowComboBox();
    8994      RemoveRuns(e.Items);
    9095    }
    9196    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     97      if (suppressUpdates) return;
    9298      if (InvokeRequired) {
    9399        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
    94100        return;
    95101      }
     102      UpdateDataTableComboBox();
     103      UpdateDataRowComboBox();
    96104      RemoveRuns(e.OldItems);
    97105      AddRuns(e.Items);
     
    108116      }
    109117      suppressUpdates = Content.UpdateOfRunsInProgress;
    110       if (!suppressUpdates) UpdateRuns(Content);
     118      if (!suppressUpdates) {
     119        UpdateDataTableComboBox();
     120        UpdateDataRowComboBox();
     121        UpdateRuns(Content);
     122      }
    111123    }
    112124
     
    124136        var run = (IRun)sender;
    125137        if (e.PropertyName == "Color" || e.PropertyName == "Visible")
    126           UpdateRuns(new IRun[] { run });
     138          UpdateRuns(new[] { run });
    127139      }
    128140    }
     
    168180
    169181    private void UpdateRuns(IEnumerable<IRun> runs) {
    170       if (suppressUpdates) return;
    171182      foreach (var run in runs) {
    172183        //update color
    173         foreach (var dataRow in runMapping[run]) {
    174           dataRow.VisualProperties.Color = run.Color;
     184        if (!runMapping.ContainsKey(run)) {
     185          runMapping[run] = ExtractDataRowsFromRun(run).ToList();
     186          RegisterRunEvents(run);
     187        } else {
     188          foreach (var dataRow in runMapping[run]) {
     189            dataRow.VisualProperties.Color = run.Color;
     190          }
    175191        }
    176         //update visibility - remove and add all rows to keep the same order as before
    177         combinedDataTable.Rows.Clear();
    178         combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    179       }
     192      }
     193      //update visibility - remove and add all rows to keep the same order as before
     194      combinedDataTable.Rows.Clear();
     195      combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    180196    }
    181197
    182198    private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) {
    183199      var resultName = (string)dataTableComboBox.SelectedItem;
     200      if (string.IsNullOrEmpty(resultName)) yield break;
     201
    184202      var rowName = (string)dataRowComboBox.SelectedItem;
    185203      if (!run.Results.ContainsKey(resultName)) yield break;
     
    199217
    200218    private void UpdateDataTableComboBox() {
     219      string selectedItem = (string)dataTableComboBox.SelectedItem;
     220
    201221      dataTableComboBox.Items.Clear();
    202222      var dataTables = (from run in Content
     
    206226
    207227      dataTableComboBox.Items.AddRange(dataTables);
    208       if (dataTableComboBox.Items.Count > 0) dataTableComboBox.SelectedItem = dataTableComboBox.Items[0];
     228      if (selectedItem != null && dataTableComboBox.Items.Contains(selectedItem)) {
     229        dataTableComboBox.SelectedItem = selectedItem;
     230      } else if (dataTableComboBox.Items.Count > 0) {
     231        dataTableComboBox.SelectedItem = dataTableComboBox.Items[0];
     232      }
    209233    }
    210234
     
    214238
    215239    private void UpdateDataRowComboBox() {
     240      string selectedItem = (string)dataRowComboBox.SelectedItem;
     241
    216242      dataRowComboBox.Items.Clear();
    217243      var resultName = (string)dataTableComboBox.SelectedItem;
     244      if (resultName == null) return;
     245
    218246      var dataTables = from run in Content
    219247                       where run.Results.ContainsKey(resultName)
     
    225253      dataRowComboBox.Items.AddRange(rowNames);
    226254      dataRowComboBox.Items.Add(AllDataRows);
    227       if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0];
    228     }
    229 
    230     private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    231       UpdateDataRowComboBox();
    232     }
    233     private void dataRowComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     255      if (selectedItem != null && dataRowComboBox.Items.Contains(selectedItem)) {
     256        dataRowComboBox.SelectedItem = selectedItem;
     257      } else if (dataRowComboBox.Items.Count > 0) {
     258        dataRowComboBox.SelectedItem = dataRowComboBox.Items[0];
     259      }
     260    }
     261
     262    private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     263      UpdateDataRowComboBox();
     264    }
     265    private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     266      if (suppressUpdates) return;
    234267      RebuildCombinedDataTable();
    235268    }
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs

    r12077 r12809  
    5353      base.OnContentChanged();
    5454      if (Content != null) {
    55         runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    5655        UpdateRowAttributes();
    5756      }
     
    151150        suppressUpdates = Content.UpdateOfRunsInProgress;
    152151        if (!suppressUpdates) {
     152          UpdateData();
    153153          UpdateRowAttributes();
    154           UpdateData();
    155154        }
    156155      }
     
    179178    protected override void ClearSorting() {
    180179      base.ClearSorting();
    181       runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    182180      UpdateRowAttributes();
    183181    }
     
    198196        i++;
    199197      }
    200       UpdateRowAttributes();
     198      UpdateRowAttributes(rebuild: false);
    201199      return newSortedIndex;
    202200    }
    203201
    204     private void UpdateRowAttributes() {
     202    private void UpdateRowAttributes(bool rebuild = true) {
     203      if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    205204      int runIndex = 0;
    206205      foreach (IRun run in Content) {
  • branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r12012 r12809  
    4141    private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping;
    4242    private bool validDragOperation;
     43    private bool suppressUpdates;
    4344
    4445    public new IItemCollection<IRun> Content {
     
    6667      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    6768      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     69      if (RunCollection != null)
     70        RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    6871      foreach (IRun run in itemListViewItemMapping.Keys) {
    6972        DeregisterItemEvents(run);
     
    7679      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    7780      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     81      if (RunCollection != null)
     82        RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    7883    }
    7984    private void DeregisterItemEvents(IRun item) {
     
    394399    #region Content Events
    395400    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     401      if (suppressUpdates) return;
    396402      if (InvokeRequired)
    397403        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
     
    407413    }
    408414    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     415      if (suppressUpdates) return;
    409416      if (InvokeRequired)
    410417        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
     
    422429    }
    423430    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     431      if (suppressUpdates) return;
    424432      if (InvokeRequired)
    425433        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
     
    440448      }
    441449    }
     450    private void RunCollection_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     451      if (InvokeRequired) Invoke((Action<object, EventArgs>)RunCollection_UpdateOfRunsInProgressChanged, sender, e);
     452      else {
     453        suppressUpdates = RunCollection.UpdateOfRunsInProgress;
     454        if (!suppressUpdates) {
     455          foreach (IRun item in Content) {
     456            //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection
     457            ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault();
     458            if (listViewItem != null) RemoveListViewItem(listViewItem);
     459          }
     460          RebuildImageList();
     461          foreach (IRun item in Content)
     462            AddListViewItem(CreateListViewItem(item));
     463
     464          AdjustListViewColumnSizes();
     465          analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     466          clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
     467          runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     468        }
     469      }
     470    }
    442471    #endregion
    443472
    444473    #region Item Events
    445474    private void Item_ItemImageChanged(object sender, EventArgs e) {
     475      if (suppressUpdates) return;
    446476      if (InvokeRequired)
    447477        Invoke(new EventHandler(Item_ItemImageChanged), sender, e);
     
    453483    }
    454484    private void Item_ToStringChanged(object sender, EventArgs e) {
     485      if (suppressUpdates) return;
    455486      if (InvokeRequired)
    456487        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
     
    463494    }
    464495    private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     496      if (suppressUpdates) return;
    465497      if (InvokeRequired)
    466         this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
     498        Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
    467499      else {
    468500        IRun run = (IRun)sender;
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveEvaluator.cs

    r12012 r12809  
    3131  [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")]
    3232  [StorableClass]
    33   public class MultiObjectiveEvaluator : SingleSuccessorOperator, IMultiObjectiveEvaluationOperator, IStochasticOperator {
     33  public class MultiObjectiveEvaluator : InstrumentedOperator, IMultiObjectiveEvaluationOperator, IStochasticOperator {
    3434
    3535    public ILookupParameter<IRandom> RandomParameter {
     
    6060    }
    6161
    62     public override IOperation Apply() {
     62    public override IOperation InstrumentedApply() {
    6363      var random = RandomParameter.ActualValue;
    6464      var encoding = EncodingParameter.ActualValue;
    6565      var individual = encoding.GetIndividual(ExecutionContext.Scope);
    6666      QualitiesParameter.ActualValue = new DoubleArray(EvaluateFunc(individual, random));
    67       return base.Apply();
     67      return base.InstrumentedApply();
    6868    }
    6969  }
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs

    r12012 r12809  
    3131  [Item("Single-objective Evaluator", "Calls the script's Evaluate method to get the quality value of the parameter vector.")]
    3232  [StorableClass]
    33   public sealed class SingleObjectiveEvaluator : SingleSuccessorOperator, ISingleObjectiveEvaluationOperator, IStochasticOperator {
     33  public sealed class SingleObjectiveEvaluator : InstrumentedOperator, ISingleObjectiveEvaluationOperator, IStochasticOperator {
    3434
    3535    public ILookupParameter<IRandom> RandomParameter {
     
    5858    public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveEvaluator(this, cloner); }
    5959
    60     public override IOperation Apply() {
     60    public override IOperation InstrumentedApply() {
    6161      var random = RandomParameter.ActualValue;
    6262      var encoding = EncodingParameter.ActualValue;
    6363      var individual = encoding.GetIndividual(ExecutionContext.Scope);
    6464      QualityParameter.ActualValue = new DoubleValue(EvaluateFunc(individual, random));
    65       return base.Apply();
     65      return base.InstrumentedApply();
    6666    }
    6767  }
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r12529 r12809  
    194194    <Compile Include="MetaOptimizers\BatchRun.cs" />
    195195    <Compile Include="MetaOptimizers\Experiment.cs" />
     196    <Compile Include="MetaOptimizers\TimeLimitRun.cs" />
    196197    <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" />
    197198    <Compile Include="Plugin.cs" />
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Plugin.cs.frame

    r12012 r12809  
    2626  /// Plugin class for HeuristicLab.Optimization plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Optimization", "3.3.11.$WCREV$")]
     28  [Plugin("HeuristicLab.Optimization", "3.3.12.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Optimization-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs

  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Properties/AssemblyInfo.cs.frame

    r12012 r12809  
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.11.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.12.$WCREV$")]
  • branches/TerminationCriteria/HeuristicLab.Optimization/3.3/RunCollection.cs

    r12504 r12809  
    445445      EventHandler<EventArgs<int, int>> handler = ItemChanged;
    446446      if (handler != null) handler(this, new EventArgs<int, int>(rowIndex, columnIndex));
    447       OnToStringChanged();
    448447    }
    449448    public event EventHandler Reset;
     
    451450      EventHandler handler = Reset;
    452451      if (handler != null) handler(this, EventArgs.Empty);
    453       OnToStringChanged();
    454452    }
    455453    public event EventHandler ColumnsChanged;
     
    485483    #region Filtering
    486484    private void UpdateFiltering(bool reset) {
     485      var oldUpateRuns = UpdateOfRunsInProgress;
    487486      UpdateOfRunsInProgress = true;
    488487      if (reset)
     
    490489      foreach (IRunCollectionConstraint constraint in this.constraints)
    491490        constraint.Check();
    492       UpdateOfRunsInProgress = false;
     491      UpdateOfRunsInProgress = oldUpateRuns;
    493492    }
    494493
     
    552551    #region Modification
    553552    public void Modify() {
     553      var oldUpateRuns = UpdateOfRunsInProgress;
    554554      UpdateOfRunsInProgress = true;
    555555      var runs = this.ToList();
     
    566566        }
    567567      }
    568       UpdateOfRunsInProgress = false;
     568      UpdateOfRunsInProgress = oldUpateRuns;
    569569    }
    570570
Note: See TracChangeset for help on using the changeset viewer.