Changeset 12809
- Timestamp:
- 07/29/15 13:07:08 (9 years ago)
- Location:
- branches/TerminationCriteria
- Files:
-
- 16 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Optimization
- Property svn:mergeinfo changed
-
branches/TerminationCriteria/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
-
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r12529 r12809 327 327 <DependentUpon>RunCollectionChartAggregationView.cs</DependentUpon> 328 328 </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> 329 335 <Compile Include="ThresholdTerminatorView.cs"> 330 336 <SubType>UserControl</SubType> -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame
r12012 r12809 26 26 /// Plugin class for HeuristicLab.Optimization.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Optimization.Views", "3.3.1 1.$WCREV$")]28 [Plugin("HeuristicLab.Optimization.Views", "3.3.12.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Optimization.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/Properties/AssemblyInfo.cs.frame
r12012 r12809 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.1 1.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.12.$WCREV$")] -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r12077 r12809 345 345 switch (axisDimension) { 346 346 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); 348 358 break; 349 359 } -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r12012 r12809 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using System.Windows.Forms;27 26 using HeuristicLab.Analysis; 28 27 using HeuristicLab.Collections; … … 41 40 } 42 41 43 private int rowNumber = 0;42 private int rowNumber; 44 43 private bool suppressUpdates; 45 44 private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping; … … 60 59 protected override void RegisterContentEvents() { 61 60 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; 67 66 } 68 67 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; 74 73 base.DeregisterContentEvents(); 75 74 } 76 75 77 76 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 77 if (suppressUpdates) return; 78 78 if (InvokeRequired) { 79 79 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 80 80 return; 81 81 } 82 UpdateDataTableComboBox(); 83 UpdateDataRowComboBox(); 82 84 AddRuns(e.Items); 83 85 } 84 86 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 87 if (suppressUpdates) return; 85 88 if (InvokeRequired) { 86 89 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 87 90 return; 88 91 } 92 UpdateDataTableComboBox(); 93 UpdateDataRowComboBox(); 89 94 RemoveRuns(e.Items); 90 95 } 91 96 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 97 if (suppressUpdates) return; 92 98 if (InvokeRequired) { 93 99 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 94 100 return; 95 101 } 102 UpdateDataTableComboBox(); 103 UpdateDataRowComboBox(); 96 104 RemoveRuns(e.OldItems); 97 105 AddRuns(e.Items); … … 108 116 } 109 117 suppressUpdates = Content.UpdateOfRunsInProgress; 110 if (!suppressUpdates) UpdateRuns(Content); 118 if (!suppressUpdates) { 119 UpdateDataTableComboBox(); 120 UpdateDataRowComboBox(); 121 UpdateRuns(Content); 122 } 111 123 } 112 124 … … 124 136 var run = (IRun)sender; 125 137 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 126 UpdateRuns(new IRun[] { run });138 UpdateRuns(new[] { run }); 127 139 } 128 140 } … … 168 180 169 181 private void UpdateRuns(IEnumerable<IRun> runs) { 170 if (suppressUpdates) return;171 182 foreach (var run in runs) { 172 183 //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 } 175 191 } 176 //update visibility - remove and add all rows to keep the same order as before177 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)); 180 196 } 181 197 182 198 private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) { 183 199 var resultName = (string)dataTableComboBox.SelectedItem; 200 if (string.IsNullOrEmpty(resultName)) yield break; 201 184 202 var rowName = (string)dataRowComboBox.SelectedItem; 185 203 if (!run.Results.ContainsKey(resultName)) yield break; … … 199 217 200 218 private void UpdateDataTableComboBox() { 219 string selectedItem = (string)dataTableComboBox.SelectedItem; 220 201 221 dataTableComboBox.Items.Clear(); 202 222 var dataTables = (from run in Content … … 206 226 207 227 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 } 209 233 } 210 234 … … 214 238 215 239 private void UpdateDataRowComboBox() { 240 string selectedItem = (string)dataRowComboBox.SelectedItem; 241 216 242 dataRowComboBox.Items.Clear(); 217 243 var resultName = (string)dataTableComboBox.SelectedItem; 244 if (resultName == null) return; 245 218 246 var dataTables = from run in Content 219 247 where run.Results.ContainsKey(resultName) … … 225 253 dataRowComboBox.Items.AddRange(rowNames); 226 254 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; 234 267 RebuildCombinedDataTable(); 235 268 } -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r12077 r12809 53 53 base.OnContentChanged(); 54 54 if (Content != null) { 55 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();56 55 UpdateRowAttributes(); 57 56 } … … 151 150 suppressUpdates = Content.UpdateOfRunsInProgress; 152 151 if (!suppressUpdates) { 152 UpdateData(); 153 153 UpdateRowAttributes(); 154 UpdateData();155 154 } 156 155 } … … 179 178 protected override void ClearSorting() { 180 179 base.ClearSorting(); 181 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();182 180 UpdateRowAttributes(); 183 181 } … … 198 196 i++; 199 197 } 200 UpdateRowAttributes( );198 UpdateRowAttributes(rebuild: false); 201 199 return newSortedIndex; 202 200 } 203 201 204 private void UpdateRowAttributes() { 202 private void UpdateRowAttributes(bool rebuild = true) { 203 if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 205 204 int runIndex = 0; 206 205 foreach (IRun run in Content) { -
branches/TerminationCriteria/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r12012 r12809 41 41 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 42 42 private bool validDragOperation; 43 private bool suppressUpdates; 43 44 44 45 public new IItemCollection<IRun> Content { … … 66 67 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 67 68 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 69 if (RunCollection != null) 70 RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 68 71 foreach (IRun run in itemListViewItemMapping.Keys) { 69 72 DeregisterItemEvents(run); … … 76 79 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 77 80 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 81 if (RunCollection != null) 82 RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 78 83 } 79 84 private void DeregisterItemEvents(IRun item) { … … 394 399 #region Content Events 395 400 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 401 if (suppressUpdates) return; 396 402 if (InvokeRequired) 397 403 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); … … 407 413 } 408 414 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 415 if (suppressUpdates) return; 409 416 if (InvokeRequired) 410 417 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); … … 422 429 } 423 430 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 431 if (suppressUpdates) return; 424 432 if (InvokeRequired) 425 433 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); … … 440 448 } 441 449 } 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 } 442 471 #endregion 443 472 444 473 #region Item Events 445 474 private void Item_ItemImageChanged(object sender, EventArgs e) { 475 if (suppressUpdates) return; 446 476 if (InvokeRequired) 447 477 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); … … 453 483 } 454 484 private void Item_ToStringChanged(object sender, EventArgs e) { 485 if (suppressUpdates) return; 455 486 if (InvokeRequired) 456 487 Invoke(new EventHandler(Item_ToStringChanged), sender, e); … … 463 494 } 464 495 private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { 496 if (suppressUpdates) return; 465 497 if (InvokeRequired) 466 this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);498 Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e); 467 499 else { 468 500 IRun run = (IRun)sender; -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiObjectiveEvaluator.cs
r12012 r12809 31 31 [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")] 32 32 [StorableClass] 33 public class MultiObjectiveEvaluator : SingleSuccessorOperator, IMultiObjectiveEvaluationOperator, IStochasticOperator {33 public class MultiObjectiveEvaluator : InstrumentedOperator, IMultiObjectiveEvaluationOperator, IStochasticOperator { 34 34 35 35 public ILookupParameter<IRandom> RandomParameter { … … 60 60 } 61 61 62 public override IOperation Apply() {62 public override IOperation InstrumentedApply() { 63 63 var random = RandomParameter.ActualValue; 64 64 var encoding = EncodingParameter.ActualValue; 65 65 var individual = encoding.GetIndividual(ExecutionContext.Scope); 66 66 QualitiesParameter.ActualValue = new DoubleArray(EvaluateFunc(individual, random)); 67 return base. Apply();67 return base.InstrumentedApply(); 68 68 } 69 69 } -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveEvaluator.cs
r12012 r12809 31 31 [Item("Single-objective Evaluator", "Calls the script's Evaluate method to get the quality value of the parameter vector.")] 32 32 [StorableClass] 33 public sealed class SingleObjectiveEvaluator : SingleSuccessorOperator, ISingleObjectiveEvaluationOperator, IStochasticOperator {33 public sealed class SingleObjectiveEvaluator : InstrumentedOperator, ISingleObjectiveEvaluationOperator, IStochasticOperator { 34 34 35 35 public ILookupParameter<IRandom> RandomParameter { … … 58 58 public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveEvaluator(this, cloner); } 59 59 60 public override IOperation Apply() {60 public override IOperation InstrumentedApply() { 61 61 var random = RandomParameter.ActualValue; 62 62 var encoding = EncodingParameter.ActualValue; 63 63 var individual = encoding.GetIndividual(ExecutionContext.Scope); 64 64 QualityParameter.ActualValue = new DoubleValue(EvaluateFunc(individual, random)); 65 return base. Apply();65 return base.InstrumentedApply(); 66 66 } 67 67 } -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r12529 r12809 194 194 <Compile Include="MetaOptimizers\BatchRun.cs" /> 195 195 <Compile Include="MetaOptimizers\Experiment.cs" /> 196 <Compile Include="MetaOptimizers\TimeLimitRun.cs" /> 196 197 <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" /> 197 198 <Compile Include="Plugin.cs" /> -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Plugin.cs.frame
r12012 r12809 26 26 /// Plugin class for HeuristicLab.Optimization plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Optimization", "3.3.1 1.$WCREV$")]28 [Plugin("HeuristicLab.Optimization", "3.3.12.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Optimization-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
- Property svn:mergeinfo changed
-
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/Properties/AssemblyInfo.cs.frame
r12012 r12809 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.1 1.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.12.$WCREV$")] -
branches/TerminationCriteria/HeuristicLab.Optimization/3.3/RunCollection.cs
r12504 r12809 445 445 EventHandler<EventArgs<int, int>> handler = ItemChanged; 446 446 if (handler != null) handler(this, new EventArgs<int, int>(rowIndex, columnIndex)); 447 OnToStringChanged();448 447 } 449 448 public event EventHandler Reset; … … 451 450 EventHandler handler = Reset; 452 451 if (handler != null) handler(this, EventArgs.Empty); 453 OnToStringChanged();454 452 } 455 453 public event EventHandler ColumnsChanged; … … 485 483 #region Filtering 486 484 private void UpdateFiltering(bool reset) { 485 var oldUpateRuns = UpdateOfRunsInProgress; 487 486 UpdateOfRunsInProgress = true; 488 487 if (reset) … … 490 489 foreach (IRunCollectionConstraint constraint in this.constraints) 491 490 constraint.Check(); 492 UpdateOfRunsInProgress = false;491 UpdateOfRunsInProgress = oldUpateRuns; 493 492 } 494 493 … … 552 551 #region Modification 553 552 public void Modify() { 553 var oldUpateRuns = UpdateOfRunsInProgress; 554 554 UpdateOfRunsInProgress = true; 555 555 var runs = this.ToList(); … … 566 566 } 567 567 } 568 UpdateOfRunsInProgress = false;568 UpdateOfRunsInProgress = oldUpateRuns; 569 569 } 570 570
Note: See TracChangeset
for help on using the changeset viewer.