Changeset 15256
- Timestamp:
- 07/15/17 14:25:44 (7 years ago)
- Location:
- branches/PerformanceComparison
- Files:
-
- 8 deleted
- 32 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs
r14695 r15256 120 120 var groupItems = new List<int>(); 121 121 var lleb = current.ToBackLinks(); 122 Move bestOfTheRest = null;122 EMSSMove bestOfTheRest = null; 123 123 var bestOfTheRestF = double.NaN; 124 124 var lastAppliedMove = -1; … … 161 161 break; 162 162 } else { 163 foreach (var move in MoveGenerator.GenerateForItem(i, groupItems, current, lleb)) {163 foreach (var move in ExhaustiveEMSSMoveGenerator.GenerateForItem(i, groupItems, current, lleb)) { 164 164 // we intend to break link i -> next 165 165 var qualityToBreak = tabu[i, next]; … … 289 289 ISingleObjectiveSolutionScope<LinearLinkage> best = null; 290 290 while (true) { 291 Move bestMove = null;291 EMSSMove bestMove = null; 292 292 var bestMoveQ = double.NaN; 293 293 // this approach may not fully relink the two solutions 294 foreach (var m in MoveGenerator.Generate(probe.Solution)) {294 foreach (var m in ExhaustiveEMSSMoveGenerator.Generate(probe.Solution)) { 295 295 var distBefore = Dist(probe, b); 296 296 m.Apply(probe.Solution); -
branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LocalSearch/StaticAPI/ExhaustiveLocalSearch.cs
r14552 r15256 42 42 var groupItems = new List<int>(); 43 43 for (var i = 0; i < solution.Length; i++) { 44 foreach (var move in MoveGenerator.GenerateForItem(i, groupItems, solution, lleb).ToList()) {44 foreach (var move in ExhaustiveEMSSMoveGenerator.GenerateForItem(i, groupItems, solution, lleb).ToList()) { 45 45 move.Apply(solution); 46 46 var moveF = eval(solution, token); -
branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEqualityComparer.cs
r14659 r15256 19 19 */ 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using System.Linq;24 using HeuristicLab.PluginInfrastructure; 24 25 25 26 namespace HeuristicLab.Encodings.BinaryVectorEncoding { 27 [NonDiscoverableType] 26 28 public class BinaryVectorEqualityComparer : EqualityComparer<BinaryVector> { 27 public override bool Equals(BinaryVector first, BinaryVector second) { 28 return first.SequenceEqual(second); 29 public override bool Equals(BinaryVector x, BinaryVector y) { 30 if (ReferenceEquals(x, y)) return true; 31 if (x == null || y == null) return false; 32 if (x.Length != y.Length) return false; 33 for (var i = 0; i < x.Length; i++) 34 if (x[i] != y[i]) return false; 35 return true; 29 36 } 37 30 38 public override int GetHashCode(BinaryVector obj) { 39 if (obj == null) throw new ArgumentNullException("obj", "BinaryVectorEqualityComparer: Cannot compute hash value of null."); 31 40 unchecked { 32 41 int hash = 17; 33 foreach (var bit in obj) {42 foreach (var bit in obj) 34 43 hash = hash * 29 + (bit ? 1231 : 1237); 35 }36 44 return hash; 37 45 } -
branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs
r14659 r15256 45 45 public static double CalculateSimilarity(BinaryVector left, BinaryVector right) { 46 46 if (left == null || right == null) 47 throw new ArgumentException("Cannot calculate similarity because one or both of the provided s copes is null.");47 throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null."); 48 48 if (left.Length != right.Length) 49 49 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different lengths."); 50 if (left == right) return 1.0; 50 if (left.Length == 0) 51 throw new ArgumentException("Cannot calculate similarity because solutions are of length 0."); 52 if (ReferenceEquals(left, right)) return 1.0; 51 53 52 54 double similarity = 0.0; -
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding
-
Property
svn:mergeinfo
set to
/trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding merged eligible
-
Property
svn:mergeinfo
set to
-
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj
r14776 r15256 155 155 <Compile Include="Crossovers\SinglePointCrossover.cs" /> 156 156 <Compile Include="Interfaces\ILinearLinkageMoveOperator.cs" /> 157 <Compile Include="Interfaces\ILinearLinkageEMSSMoveOperator.cs" /> 157 158 <Compile Include="Interfaces\ILinearLinkageSwap2MoveOperator.cs" /> 158 159 <Compile Include="Interfaces\ILinearLinkageCreator.cs" /> … … 167 168 <Compile Include="Manipulators\MergeGroupManipulator.cs" /> 168 169 <Compile Include="Manipulators\MultiLLEManipulator.cs" /> 169 <Compile Include="Moves\ExtractMove.cs" /> 170 <Compile Include="Moves\MergeMove.cs" /> 171 <Compile Include="Moves\Move.cs" /> 172 <Compile Include="Moves\ShiftMove.cs" /> 173 <Compile Include="Moves\SplitMove.cs" /> 174 <Compile Include="Moves\StaticAPI\MoveGenerator.cs" /> 170 <Compile Include="Moves\EMSS\EMSSMoveMaker.cs" /> 171 <Compile Include="Moves\EMSS\ExtractMove.cs" /> 172 <Compile Include="Moves\EMSS\MergeMove.cs" /> 173 <Compile Include="Moves\EMSS\EMSSMove.cs" /> 174 <Compile Include="Moves\EMSS\ExhaustiveEMSSMoveGenerator.cs" /> 175 <Compile Include="Moves\EMSS\EMSSMoveGenerator.cs" /> 176 <Compile Include="Moves\EMSS\StochasticEMSSMultiMoveGenerator.cs" /> 177 <Compile Include="Moves\EMSS\StochasticEMSSSingleMoveGenerator.cs" /> 178 <Compile Include="Moves\EMSS\ShiftMove.cs" /> 179 <Compile Include="Moves\EMSS\SplitMove.cs" /> 175 180 <Compile Include="Moves\Swap\ExhaustiveSwap2MoveGenerator.cs" /> 176 181 <Compile Include="Moves\Swap\StochasticSwap2MultiMoveGenerator.cs" /> -
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEqualityComparer.cs
r14659 r15256 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using HeuristicLab.PluginInfrastructure; 23 25 24 26 namespace HeuristicLab.Encodings.LinearLinkageEncoding { 27 [NonDiscoverableType] 25 28 public class LinearLinkageEqualityComparer : EqualityComparer<LinearLinkage> { 26 29 public override bool Equals(LinearLinkage x, LinearLinkage y) { 27 if ( x == null && y == null) return true;30 if (ReferenceEquals(x, y)) return true; 28 31 if (x == null || y == null) return false; 29 32 if (x.Length != y.Length) return false; … … 34 37 35 38 public override int GetHashCode(LinearLinkage obj) { 39 if (obj == null) throw new ArgumentNullException("obj", "LinearLinkageEqualityComparer: Cannot compute hash value of null."); 36 40 unchecked { 37 41 int hash = 17; -
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Moves/Swap/ExhaustiveSwap2MoveGenerator.cs
r14185 r15256 29 29 30 30 namespace HeuristicLab.Encodings.LinearLinkageEncoding { 31 [Item("ExhaustiveSwap2MoveGenerator", "Generates all possible swap-2 moves from a given permutation.")]31 [Item("ExhaustiveSwap2MoveGenerator", "Generates all possible swap-2 moves from a given lle grouping.")] 32 32 [StorableClass] 33 33 public class ExhaustiveSwap2MoveGenerator : Swap2MoveGenerator, IExhaustiveMoveGenerator { -
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Moves/Swap/StochasticSwap2SingleMoveGenerator.cs
r14185 r15256 29 29 30 30 namespace HeuristicLab.Encodings.LinearLinkageEncoding { 31 [Item("StochasticSwap2SingleMoveGenerator", "Randomly samples a single from all possible swap-2 moves from a given grouping.")]31 [Item("StochasticSwap2SingleMoveGenerator", "Randomly samples a single from all possible swap-2 moves from a given lle grouping.")] 32 32 [StorableClass] 33 33 public class StochasticSwap2SingleMoveGenerator : Swap2MoveGenerator, IStochasticOperator, ISingleMoveGenerator { -
branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/SimilarityCalculators/HammingSimilarityCalculator.cs
r14659 r15256 30 30 [StorableClass] 31 31 public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 32 33 protected override bool IsCommutative { 34 get { return true; } 35 } 32 protected override bool IsCommutative { get { return true; } } 36 33 37 34 [StorableConstructor] 38 35 private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { } 39 36 private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } 40 public HammingSimilarityCalculator() { }37 public HammingSimilarityCalculator() : base() { } 41 38 42 39 public override IDeepCloneable Clone(Cloner cloner) { … … 45 42 46 43 public static double CalculateSimilarity(LinearLinkage left, LinearLinkage right) { 47 if (left.Length != right.Length) throw new ArgumentException("Comparing encodings of unequal length"); 44 if (left == null || right == null) 45 throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null."); 46 if (left.Length != right.Length) 47 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different lengths."); 48 if (left.Length == 0) 49 throw new ArgumentException("Cannot calculate similarity because solutions are of length 0."); 50 if (ReferenceEquals(left, right)) return 1.0; 51 48 52 var similarity = 0; 49 53 for (var i = 0; i < left.Length; i++) { -
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs
r14600 r15256 30 30 public class PermutationEqualityComparer : EqualityComparer<Permutation> { 31 31 public override bool Equals(Permutation x, Permutation y) { 32 if (ReferenceEquals(x, y)) return true; 33 if (x == null || y == null) return false; 34 if (x.Length != y.Length) return false; 32 35 if (x.PermutationType != y.PermutationType) return false; 33 if (x.Length != y.Length) return false;34 36 switch (x.PermutationType) { 35 37 case PermutationTypes.Absolute: … … 67 69 68 70 public override int GetHashCode(Permutation obj) { 69 if (obj == null) return 0;71 if (obj == null) throw new ArgumentNullException("obj", "PermutationEqualityComparer: Cannot compute hash value of null."); 70 72 return GenerateHashString(obj).GetHashCode(); 71 73 } -
branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs
r14659 r15256 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Optimization.Operators; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 27 28 namespace HeuristicLab.Encodings.PermutationEncoding { 28 29 [Item("Hamming Similarity Calculator for Permutation", "An operator that performs similarity calculation between two permutation-encoded solutions.")] 30 [StorableClass] 29 31 public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 30 32 protected override bool IsCommutative { get { return true; } } 31 33 34 [StorableConstructor] 32 35 private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { } 33 36 private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } … … 40 43 public static double CalculateSimilarity(Permutation left, Permutation right) { 41 44 if (left == null || right == null) 42 throw new ArgumentException("Cannot calculate similarity because one o f the provided solutions or both arenull.");45 throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null."); 43 46 if (left.PermutationType != right.PermutationType) 44 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different types.");47 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different permutation types."); 45 48 if (left.Length != right.Length) 46 49 throw new ArgumentException("Cannot calculate similarity because the provided solutions have different lengths."); 47 if (object.ReferenceEquals(left, right)) return 1.0; 50 if (left.Length == 0) 51 throw new ArgumentException("Cannot calculate similarity because solutions are of length 0."); 52 if (ReferenceEquals(left, right)) return 1.0; 48 53 49 54 switch (left.PermutationType) { -
branches/PerformanceComparison/HeuristicLab.Optimization
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r14600 r15256 463 463 } 464 464 465 public bool StatisticsVisible { 466 get { return splitContainer.Panel2Collapsed; } 467 set { splitContainer.Panel2Collapsed = value; } 468 } 469 465 470 public void SetXAxis(string axisName) { 466 471 xAxisComboBox.SelectedItem = axisName; -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs
r14600 r15256 139 139 this.xAxisComboBox.Size = new System.Drawing.Size(400, 21); 140 140 this.xAxisComboBox.TabIndex = 7; 141 this.xAxisComboBox.Sorted = false; 141 142 this.xAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); 142 143 // … … 160 161 this.yAxisComboBox.Size = new System.Drawing.Size(400, 21); 161 162 this.yAxisComboBox.TabIndex = 5; 163 this.yAxisComboBox.Sorted = false; 162 164 this.yAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); 163 165 // … … 183 185 this.sizeComboBox.Name = "sizeComboBox"; 184 186 this.sizeComboBox.Size = new System.Drawing.Size(300, 21); 187 this.sizeComboBox.Sorted = false; 185 188 this.sizeComboBox.TabIndex = 14; 186 189 this.sizeComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); … … 264 267 this.radioButtonGroup.Controls.Add(this.zoomButton); 265 268 this.radioButtonGroup.Controls.Add(this.selectButton); 266 this.radioButtonGroup.Location = new System.Drawing.Point( 3, 704);269 this.radioButtonGroup.Location = new System.Drawing.Point(6, 679); 267 270 this.radioButtonGroup.Name = "radioButtonGroup"; 268 271 this.radioButtonGroup.Size = new System.Drawing.Size(122, 32); … … 275 278 this.colorRunsButton.Enabled = false; 276 279 this.colorRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 277 this.colorRunsButton.Location = new System.Drawing.Point( 131, 713);280 this.colorRunsButton.Location = new System.Drawing.Point(6, 715); 278 281 this.colorRunsButton.Name = "colorRunsButton"; 279 282 this.colorRunsButton.Size = new System.Drawing.Size(21, 21); … … 317 320 this.transparencyTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 318 321 this.transparencyTrackBar.LargeChange = 16; 319 this.transparencyTrackBar.Location = new System.Drawing.Point( 302, 715);322 this.transparencyTrackBar.Location = new System.Drawing.Point(177, 717); 320 323 this.transparencyTrackBar.Maximum = 254; 321 324 this.transparencyTrackBar.Name = "transparencyTrackBar"; … … 331 334 this.hideRunsButton.Enabled = false; 332 335 this.hideRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 333 this.hideRunsButton.Location = new System.Drawing.Point( 172, 713);336 this.hideRunsButton.Location = new System.Drawing.Point(47, 715); 334 337 this.hideRunsButton.Name = "hideRunsButton"; 335 338 this.hideRunsButton.Size = new System.Drawing.Size(43, 21); … … 347 350 this.colorDialogButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 348 351 this.colorDialogButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 349 this.colorDialogButton.Location = new System.Drawing.Point( 152, 713);352 this.colorDialogButton.Location = new System.Drawing.Point(27, 715); 350 353 this.colorDialogButton.Name = "colorDialogButton"; 351 354 this.colorDialogButton.Size = new System.Drawing.Size(14, 21); … … 390 393 this.transparencyLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 391 394 this.transparencyLabel.AutoSize = true; 392 this.transparencyLabel.Location = new System.Drawing.Point( 233, 717);395 this.transparencyLabel.Location = new System.Drawing.Point(108, 719); 393 396 this.transparencyLabel.Name = "transparencyLabel"; 394 397 this.transparencyLabel.Size = new System.Drawing.Size(75, 13); -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r14600 r15256 93 93 } 94 94 95 public string SelectedXAxis { 96 get { return xAxisValue; } 97 set { 98 if (xAxisComboBox.Items.Contains(value)) { 99 xAxisComboBox.SelectedItem = value; 100 } 101 } 102 } 103 public string SelectedYAxis { 104 get { return yAxisValue; } 105 set { 106 if (yAxisComboBox.Items.Contains(value)) { 107 yAxisComboBox.SelectedItem = value; 108 } 109 } 110 } 111 95 112 protected override void RegisterContentEvents() { 96 113 base.RegisterContentEvents(); … … 227 244 string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension)); 228 245 this.xAxisComboBox.Items.AddRange(additionalAxisDimension); 229 this.xAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 246 var comparer = new HeuristicLab.Common.NaturalStringComparer(); 247 var sortedColumnNames = Matrix.ColumnNames.ToArray(); 248 sortedColumnNames.StableSort(comparer); 249 this.xAxisComboBox.Items.AddRange(sortedColumnNames); 230 250 this.yAxisComboBox.Items.AddRange(additionalAxisDimension); 231 this.yAxisComboBox.Items.AddRange( Matrix.ColumnNames.ToArray());251 this.yAxisComboBox.Items.AddRange(sortedColumnNames); 232 252 string[] additionalSizeDimension = Enum.GetNames(typeof(SizeDimension)); 233 253 this.sizeComboBox.Items.AddRange(additionalSizeDimension); 234 this.sizeComboBox.Items.AddRange( Matrix.ColumnNames.ToArray());254 this.sizeComboBox.Items.AddRange(sortedColumnNames); 235 255 this.sizeComboBox.SelectedItem = SizeDimension.Constant.ToString(); 236 256 … … 726 746 } 727 747 private void hideRunsToolStripMenuItem_Click(object sender, EventArgs e) { 728 //ToList is necessary to prevent lazy evaluation 729 HideRuns(selectedRuns.ToList()); 748 HideRuns(selectedRuns); 730 749 //could not use ClearSelectedRuns as the runs are not visible anymore 731 750 selectedRuns.Clear(); 732 751 } 733 752 private void hideRunsButton_Click(object sender, EventArgs e) { 734 //ToList is necessary to prevent lazy evaluation 735 HideRuns(selectedRuns.ToList()); 753 HideRuns(selectedRuns); 736 754 //could not use ClearSelectedRuns as the runs are not visible anymore 737 755 selectedRuns.Clear(); … … 739 757 740 758 private void HideRuns(IEnumerable<IRun> runs) { 759 Content.UpdateOfRunsInProgress = true; 741 760 visibilityConstraint.Active = false; 742 761 if (!Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Add(visibilityConstraint); … … 745 764 } 746 765 visibilityConstraint.Active = true; 766 Content.UpdateOfRunsInProgress = false; 747 767 } 748 768 -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs
r14665 r15256 45 45 private void InitializeComponent() { 46 46 this.components = new System.ComponentModel.Container(); 47 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea 1= new System.Windows.Forms.DataVisualization.Charting.ChartArea();48 System.Windows.Forms.DataVisualization.Charting.Legend legend 1= new System.Windows.Forms.DataVisualization.Charting.Legend();47 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 48 System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 49 49 this.dataTableComboBox = new System.Windows.Forms.ComboBox(); 50 50 this.dataTableLabel = new System.Windows.Forms.Label(); … … 66 66 this.relativeOrAbsoluteComboBox = new System.Windows.Forms.ComboBox(); 67 67 this.targetChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 68 this.showLabelsCheckBox = new System.Windows.Forms.CheckBox(); 68 69 this.markerCheckBox = new System.Windows.Forms.CheckBox(); 69 70 this.boundShadingCheckBox = new System.Windows.Forms.CheckBox(); … … 71 72 this.byCostViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 72 73 this.budgetLogScalingCheckBox = new System.Windows.Forms.CheckBox(); 73 this.aggregateBudgetsCheckBox = new System.Windows.Forms.CheckBox();74 74 this.generateBudgetsButton = new System.Windows.Forms.Button(); 75 75 this.byTableTabPage = new System.Windows.Forms.TabPage(); … … 202 202 this.budgetsTextBox.Location = new System.Drawing.Point(59, 8); 203 203 this.budgetsTextBox.Name = "budgetsTextBox"; 204 this.budgetsTextBox.Size = new System.Drawing.Size(3 09, 20);204 this.budgetsTextBox.Size = new System.Drawing.Size(391, 20); 205 205 this.budgetsTextBox.TabIndex = 6; 206 206 this.budgetsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.budgetsTextBox_Validating); … … 249 249 this.byTargetTabPage.Controls.Add(this.relativeOrAbsoluteComboBox); 250 250 this.byTargetTabPage.Controls.Add(this.targetChart); 251 this.byTargetTabPage.Controls.Add(this.showLabelsCheckBox); 251 252 this.byTargetTabPage.Controls.Add(this.markerCheckBox); 252 253 this.byTargetTabPage.Controls.Add(this.boundShadingCheckBox); … … 284 285 | System.Windows.Forms.AnchorStyles.Left) 285 286 | System.Windows.Forms.AnchorStyles.Right))); 286 chartArea 1.AxisX.IsStartedFromZero = false;287 chartArea 1.AxisX.MinorGrid.Enabled = true;288 chartArea 1.AxisX.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke;289 chartArea 1.AxisX.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;290 chartArea 1.AxisY.Maximum = 1D;291 chartArea 1.AxisY.Minimum = 0D;292 chartArea 1.AxisY.MinorGrid.Enabled = true;293 chartArea 1.AxisY.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke;294 chartArea 1.AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;295 chartArea 1.Name = "ChartArea1";296 this.targetChart.ChartAreas.Add(chartArea 1);297 legend 1.Alignment = System.Drawing.StringAlignment.Center;298 legend 1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;299 legend 1.Name = "Legend1";300 this.targetChart.Legends.Add(legend 1);287 chartArea2.AxisX.IsStartedFromZero = false; 288 chartArea2.AxisX.MinorGrid.Enabled = true; 289 chartArea2.AxisX.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke; 290 chartArea2.AxisX.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash; 291 chartArea2.AxisY.Maximum = 1D; 292 chartArea2.AxisY.Minimum = 0D; 293 chartArea2.AxisY.MinorGrid.Enabled = true; 294 chartArea2.AxisY.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke; 295 chartArea2.AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash; 296 chartArea2.Name = "ChartArea1"; 297 this.targetChart.ChartAreas.Add(chartArea2); 298 legend2.Alignment = System.Drawing.StringAlignment.Center; 299 legend2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 300 legend2.Name = "Legend1"; 301 this.targetChart.Legends.Add(legend2); 301 302 this.targetChart.Location = new System.Drawing.Point(6, 34); 302 303 this.targetChart.Name = "targetChart"; … … 308 309 this.targetChart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 309 310 this.targetChart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 311 // 312 // showLabelsCheckBox 313 // 314 this.showLabelsCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 315 this.showLabelsCheckBox.AutoSize = true; 316 this.showLabelsCheckBox.Checked = true; 317 this.showLabelsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 318 this.showLabelsCheckBox.Location = new System.Drawing.Point(329, 364); 319 this.showLabelsCheckBox.Name = "showLabelsCheckBox"; 320 this.showLabelsCheckBox.Size = new System.Drawing.Size(81, 17); 321 this.showLabelsCheckBox.TabIndex = 6; 322 this.showLabelsCheckBox.Text = "show labels"; 323 this.showLabelsCheckBox.UseVisualStyleBackColor = true; 324 this.showLabelsCheckBox.CheckedChanged += new System.EventHandler(this.showLabelsCheckBox_CheckedChanged); 310 325 // 311 326 // markerCheckBox … … 339 354 this.byCostTabPage.Controls.Add(this.byCostViewHost); 340 355 this.byCostTabPage.Controls.Add(this.budgetLogScalingCheckBox); 341 this.byCostTabPage.Controls.Add(this.aggregateBudgetsCheckBox);342 356 this.byCostTabPage.Controls.Add(this.generateBudgetsButton); 343 357 this.byCostTabPage.Controls.Add(this.budgetsLabel); … … 379 393 this.budgetLogScalingCheckBox.UseVisualStyleBackColor = true; 380 394 this.budgetLogScalingCheckBox.CheckedChanged += new System.EventHandler(this.logScalingCheckBox_CheckedChanged); 381 //382 // aggregateBudgetsCheckBox383 //384 this.aggregateBudgetsCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));385 this.aggregateBudgetsCheckBox.AutoSize = true;386 this.aggregateBudgetsCheckBox.Checked = true;387 this.aggregateBudgetsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;388 this.aggregateBudgetsCheckBox.Location = new System.Drawing.Point(374, 10);389 this.aggregateBudgetsCheckBox.Name = "aggregateBudgetsCheckBox";390 this.aggregateBudgetsCheckBox.Size = new System.Drawing.Size(74, 17);391 this.aggregateBudgetsCheckBox.TabIndex = 10;392 this.aggregateBudgetsCheckBox.Text = "aggregate";393 this.aggregateBudgetsCheckBox.UseVisualStyleBackColor = true;394 this.aggregateBudgetsCheckBox.CheckedChanged += new System.EventHandler(this.aggregateBudgetsCheckBox_CheckedChanged);395 395 // 396 396 // generateBudgetsButton … … 496 496 private System.Windows.Forms.TabPage byCostTabPage; 497 497 private System.Windows.Forms.TabPage byTableTabPage; 498 private System.Windows.Forms.CheckBox aggregateBudgetsCheckBox;499 498 private System.Windows.Forms.Button generateBudgetsButton; 500 499 private System.Windows.Forms.CheckBox budgetLogScalingCheckBox; … … 507 506 private System.Windows.Forms.CheckBox markerCheckBox; 508 507 private System.Windows.Forms.ComboBox relativeOrAbsoluteComboBox; 508 private System.Windows.Forms.CheckBox showLabelsCheckBox; 509 509 } 510 510 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r14776 r15256 81 81 private double[] budgets; 82 82 private bool targetsAreRelative = true; 83 private bool showLabelsInTargetChart = true; 83 84 private readonly BindingList<ProblemInstance> problems; 84 85 … … 96 97 targetChart.ChartAreas[0].CursorX.Interval = 1; 97 98 targetChart.SuppressExceptions = true; 98 byCostDataTable = new IndexedDataTable<double>("ECDF by Cost", "A data table containing the ECDF of each of a number of groups.") {99 byCostDataTable = new IndexedDataTable<double>("ECDF by Cost", "A data table containing the ECDF of function values (relative to best-known).") { 99 100 VisualProperties = { 100 YAxisTitle = "Proportion of unused budgets",101 YAxisTitle = "Proportion of runs", 101 102 YAxisMinimumFixedValue = 0, 102 103 YAxisMinimumAuto = false, … … 284 285 addTargetsAsResultButton.Enabled = Content != null && targets != null && dataTableComboBox.SelectedIndex >= 0; 285 286 addBudgetsAsResultButton.Enabled = Content != null && budgets != null && dataTableComboBox.SelectedIndex >= 0; 287 generateTargetsButton.Enabled = targets != null; 286 288 } 287 289 … … 314 316 targetChart.Series.Clear(); 315 317 invisibleTargetSeries.Clear(); 316 318 317 319 var table = (string)dataTableComboBox.SelectedItem; 318 320 if (string.IsNullOrEmpty(table)) return; … … 424 426 if (!labelPrinted && row.Points.Count > 0) { 425 427 var point = row.Points.Last(); 426 point.Label = row.Name; 428 if (showLabelsInTargetChart) 429 point.Label = row.Name; 427 430 point.MarkerStyle = MarkerStyle.Cross; 428 431 point.MarkerBorderWidth = 1; … … 456 459 if (!labelPrinted) { 457 460 var point = row.Points.Last(); 458 point.Label = row.Name; 461 if (showLabelsInTargetChart) 462 point.Label = row.Name; 459 463 point.MarkerStyle = MarkerStyle.Cross; 460 464 point.MarkerBorderWidth = 1; … … 504 508 if (!labelPrinted && row.Points.Count > 0) { 505 509 var point = row.Points.Last(); 506 point.Label = row.Name; 510 if (showLabelsInTargetChart) 511 point.Label = row.Name; 507 512 point.MarkerStyle = MarkerStyle.Cross; 508 513 point.MarkerBorderWidth = 1; … … 514 519 if (!labelPrinted) { 515 520 var point = row.Points.Last(); 516 point.Label = row.Name; 521 if (showLabelsInTargetChart) 522 point.Label = row.Name; 517 523 point.MarkerStyle = MarkerStyle.Cross; 518 524 point.MarkerBorderWidth = 1; … … 572 578 private void GenerateDefaultTargets() { 573 579 targets = new[] { 0.1, 0.095, 0.09, 0.085, 0.08, 0.075, 0.07, 0.065, 0.06, 0.055, 0.05, 0.045, 0.04, 0.035, 0.03, 0.025, 0.02, 0.015, 0.01, 0.005, 0 }; 574 suppressTargetsEvents = true; 575 targetsTextBox.Text = string.Join("% ; ", targets.Select(x => x * 100)) + "%"; 576 suppressTargetsEvents = false; 580 SynchronizeTargetTextBox(); 577 581 } 578 582 579 583 private Tuple<bool, double> GetEffortToHitTarget( 580 IEnumerable<Tuple<double, double>> convergenceGraph,584 ObservableList<Tuple<double, double>> convergenceGraph, 581 585 double absTarget, bool maximization) { 582 var hit = false; 583 var effort = double.NaN; 584 foreach (var dent in convergenceGraph) { 585 effort = dent.Item1; 586 hit = maximization && dent.Item2 >= absTarget || !maximization && dent.Item2 <= absTarget; 587 if (hit) break; 588 } 589 if (double.IsNaN(effort)) throw new ArgumentException("Convergence graph is empty.", "convergenceGraph"); 590 return Tuple.Create(hit, effort); 586 if (convergenceGraph.Count == 0) 587 throw new ArgumentException("Convergence graph is empty.", "convergenceGraph"); 588 589 var index = convergenceGraph.BinarySearch(Tuple.Create(0.0, absTarget), new TargetComparer(maximization)); 590 if (index >= 0) { 591 return Tuple.Create(true, convergenceGraph[index].Item1); 592 } else { 593 index = ~index; 594 if (index >= convergenceGraph.Count) 595 return Tuple.Create(false, convergenceGraph.Last().Item1); 596 return Tuple.Create(true, convergenceGraph[index].Item1); 597 } 591 598 } 592 599 593 600 private void UpdateErtTables(List<AlgorithmInstance> algorithmInstances) { 594 601 ertTableView.Content = null; 595 var columns = 1 + targets.Length + 1; 596 var matrix = new string[algorithmInstances.Count * algorithmInstances.Max(x => x.GetNumberOfProblemInstances()) + algorithmInstances.Max(x => x.GetNumberOfProblemInstances()), columns]; 602 var columns = targets.Length + 1; 603 var totalRows = algorithmInstances.Count * algorithmInstances.Max(x => x.GetNumberOfProblemInstances()) + algorithmInstances.Max(x => x.GetNumberOfProblemInstances()); 604 var matrix = new StringMatrix(totalRows, columns); 605 var rowNames = new List<string>(); 606 matrix.ColumnNames = targets.Select(x => targetsAreRelative ? (100 * x).ToString() + "%" : x.ToString()) 607 .Concat(new[] { "#succ" }).ToList(); 597 608 var rowCount = 0; 598 609 … … 604 615 foreach (var problem in problems) { 605 616 var max = problem.IsMaximization(); 606 matrix[rowCount, 0] = problem.ToString();617 rowNames.Add(problem.ToString()); 607 618 var absTargets = GetAbsoluteTargetsWorstToBest(problem); 608 for (var i = 0; i < absTargets.Length; i++) { 609 matrix[rowCount, i + 1] = absTargets[i].ToString(CultureInfo.CurrentCulture.NumberFormat); 610 } 611 matrix[rowCount, columns - 1] = "#succ"; 619 if (targetsAreRelative) { 620 // print out the absolute target values 621 for (var i = 0; i < absTargets.Length; i++) { 622 matrix[rowCount, i] = absTargets[i].ToString("##,0.0", CultureInfo.CurrentCulture.NumberFormat); 623 } 624 } 612 625 rowCount++; 613 626 614 627 foreach (var alg in algorithmInstances) { 615 matrix[rowCount, 0] = alg.Name;628 rowNames.Add(alg.Name); 616 629 var runs = alg.GetRuns(problem).ToList(); 617 630 if (runs.Count == 0) { … … 623 636 for (var i = 0; i < absTargets.Length; i++) { 624 637 result = ExpectedRuntimeHelper.CalculateErt(runs, tableName, absTargets[i], max); 625 matrix[rowCount, i + 1] = result.ToString();638 matrix[rowCount, i] = result.ToString(); 626 639 } 627 640 matrix[rowCount, columns - 1] = targets.Length > 0 ? result.SuccessfulRuns + "/" + result.TotalRuns : "-"; … … 629 642 } 630 643 } 631 ertTableView.Content = new StringMatrix(matrix); 644 matrix.RowNames = rowNames; 645 ertTableView.Content = matrix; 632 646 ertTableView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); 633 647 } … … 658 672 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 659 673 660 if (aggregateBudgetsCheckBox.Checked) { 661 CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), alg.GetNumberOfProblemInstances(), problem, alg.Name, alg.GetNumberOfRuns(problem)); 662 } else { 663 CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), alg.GetNumberOfProblemInstances(), problem, alg.Name, alg.GetNumberOfRuns(problem)); 664 } 674 CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), problem, alg.Name); 665 675 } 666 676 } … … 678 688 679 689 var total = 0.0; 690 var count = list.Value.Count; 680 691 foreach (var h in list.Value) { 681 692 total += h.Value; 682 row.Values.Add(Tuple.Create(h.Key, total ));693 row.Values.Add(Tuple.Create(h.Key, total / (double)count)); 683 694 } 684 695 … … 697 708 var min = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Min()).Min(); 698 709 var max = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Max()).Max(); 699 var points = 20;710 var points = 3; 700 711 budgets = Enumerable.Range(1, points).Select(x => min + (x / (double)points) * (max - min)).ToArray(); 701 712 suppressBudgetsEvents = true; … … 704 715 } 705 716 706 private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, ProblemInstance problem, string groupName, int problemCount) {717 private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, ProblemInstance problem, string groupName) { 707 718 var max = problem.IsMaximization(); 719 var prevIndex = 0; 708 720 foreach (var b in budgets) { 709 721 var key = groupName + "-" + b; 722 var index = row.Values.BinarySearch(prevIndex, row.Values.Count - prevIndex, Tuple.Create(b, 0.0), new CostComparer()); 723 if (index < 0) { 724 index = ~index; 725 if (index >= row.Values.Count) break; // the run wasn't long enough to use up budget b (or any subsequent larger one) 726 } 710 727 if (!hits.ContainsKey(key)) hits.Add(key, new SortedList<double, double>()); 711 Tuple<double, double> prev = null; 712 foreach (var v in row.Values) { 713 if (v.Item1 >= b) { 714 // the budget may be too low to achieve any target 715 if (prev == null && v.Item1 != b) break; 716 var tgt = ((prev == null || v.Item1 == b) ? v.Item2 : prev.Item2); 717 var relTgt = CalculateRelativeDifference(max, problem.BestKnownQuality, tgt) + 1; 718 if (hits[key].ContainsKey(relTgt)) 719 hits[key][relTgt] += 1.0 / (groupCount * problemCount); 720 else hits[key][relTgt] = 1.0 / (groupCount * problemCount); 721 break; 722 } 723 prev = v; 724 } 725 if (hits[key].Count == 0) hits.Remove(key); 726 } 727 } 728 729 private void CalculateHitsForAllBudgets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, ProblemInstance problem, string groupName, int problemCount) { 730 var values = row.Values; 731 if (!hits.ContainsKey(groupName)) hits.Add(groupName, new SortedList<double, double>()); 732 733 var i = 0; 734 var j = 0; 735 Tuple<double, double> prev = null; 736 var max = problem.IsMaximization(); 737 while (i < budgets.Length && j < values.Count) { 738 var current = values[j]; 739 if (current.Item1 >= budgets[i]) { 740 if (prev != null || current.Item1 == budgets[i]) { 741 var tgt = (prev == null || current.Item1 == budgets[i]) ? current.Item2 : prev.Item2; 742 var relTgt = CalculateRelativeDifference(max, problem.BestKnownQuality, tgt) + 1; 743 if (!hits[groupName].ContainsKey(relTgt)) hits[groupName][relTgt] = 0; 744 hits[groupName][relTgt] += 1.0 / (groupCount * problemCount * budgets.Length); 745 } 746 i++; 747 } else { 748 j++; 749 prev = current; 750 } 751 } 752 var lastTgt = values.Last().Item2; 753 var lastRelTgt = CalculateRelativeDifference(max, problem.BestKnownQuality, lastTgt) + 1; 754 if (i < budgets.Length && !hits[groupName].ContainsKey(lastRelTgt)) hits[groupName][lastRelTgt] = 0; 755 while (i < budgets.Length) { 756 hits[groupName][lastRelTgt] += 1.0 / (groupCount * problemCount * budgets.Length); 757 i++; 728 var v = row.Values[index]; 729 var relTgt = CalculateRelativeDifference(max, problem.BestKnownQuality, v.Item2) + 1; 730 if (hits[key].ContainsKey(relTgt)) 731 hits[key][relTgt]++; 732 else hits[key][relTgt] = 1.0; 733 prevIndex = index; 758 734 } 759 735 } … … 762 738 private void UpdateCaption() { 763 739 Caption = Content != null ? Content.OptimizerName + " RLD View" : ViewAttribute.GetViewName(GetType()); 740 } 741 742 private void SynchronizeTargetTextBox() { 743 if (InvokeRequired) Invoke((Action)SynchronizeTargetTextBox); 744 else { 745 suppressTargetsEvents = true; 746 try { 747 if (targetsAreRelative) 748 targetsTextBox.Text = string.Join("% ; ", targets.Select(x => x * 100)) + "%"; 749 else targetsTextBox.Text = string.Join(" ; ", targets); 750 } finally { suppressTargetsEvents = false; } 751 } 764 752 } 765 753 … … 814 802 errorProvider.SetError(targetsTextBox, null); 815 803 targets = targetsAreRelative ? targetList.Select(x => (double)x).OrderByDescending(x => x).ToArray() : targetList.Select(x => (double)x).ToArray(); 816 suppressTargetsEvents = true; 817 try { 818 if (targetsAreRelative) 819 targetsTextBox.Text = string.Join("% ; ", targets.Select(x => x * 100)) + "%"; 820 else targetsTextBox.Text = string.Join(" ; ", targets); 821 } finally { suppressTargetsEvents = false; } 822 804 805 SynchronizeTargetTextBox(); 823 806 UpdateResultsByTarget(); 824 807 SetEnabledStateOfControls(); … … 848 831 } 849 832 targetsAreRelative = (string)relativeOrAbsoluteComboBox.SelectedItem == "relative"; 850 S uspendRepaint();851 suppressTargetsEvents = true; 833 SynchronizeTargetTextBox(); 834 852 835 try { 853 if (targetsAreRelative) 854 targetsTextBox.Text = string.Join("% ; ", targets.Select(x => x * 100)) + "%"; 855 else targetsTextBox.Text = string.Join(" ; ", targets); 856 836 SuspendRepaint(); 857 837 UpdateResultsByTarget(); 858 } finally { suppressTargetsEvents = false;ResumeRepaint(true); }838 } finally { ResumeRepaint(true); } 859 839 } 860 840 861 841 private void generateTargetsButton_Click(object sender, EventArgs e) { 862 decimal max = 1, min = 0, count = 10; 863 if (targets != null) { 864 max = (decimal)targets.Max(); 865 min = (decimal)targets.Min(); 866 count = targets.Length; 867 } else if (Content.Count > 0 && dataTableComboBox.SelectedIndex >= 0) { 868 var table = (string)dataTableComboBox.SelectedItem; 869 max = (decimal)Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).Max(); 870 min = (decimal)Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Min(); 871 count = 6; 842 if (targets == null) return; 843 decimal max = 10, min = 0, count = 10; 844 max = (decimal)targets.Max(); 845 min = (decimal)targets.Min(); 846 count = targets.Length - 1; 847 if (targetsAreRelative) { 848 max *= 100; 849 min *= 100; 872 850 } 873 851 using (var dialog = new DefineArithmeticProgressionDialog(false, min, max, (max - min) / count)) { 874 852 if (dialog.ShowDialog() == DialogResult.OK) { 875 853 if (dialog.Values.Any()) { 876 targets = dialog.Values.Select(x => (double)x).ToArray(); 877 suppressTargetsEvents = true; 878 if (targetsAreRelative) 879 targetsTextBox.Text = string.Join("% ; ", targets); 880 else targetsTextBox.Text = string.Join(" ; ", targets); 881 suppressTargetsEvents = false; 882 854 targets = targetsAreRelative 855 ? dialog.Values.OrderByDescending(x => x).Select(x => (double)x / 100.0).ToArray() 856 : dialog.Values.Select(x => (double)x).ToArray(); 857 858 SynchronizeTargetTextBox(); 883 859 UpdateResultsByTarget(); 884 860 SetEnabledStateOfControls(); … … 896 872 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 897 873 var values = resultsTable.Rows.First().Values; 898 var i = 0;899 var j = 0;900 874 var pd = new ProblemInstance(run); 875 pd = problems.Single(x => x.Equals(pd)); 901 876 var max = pd.IsMaximization(); 902 var absTargets = GetAbsoluteTargetsWorstToBest(problems.Single(x => x.Equals(pd))); 903 while (i < absTargets.Length && j < values.Count) { 904 var target = absTargets[i]; 905 var current = values[j]; 906 if (max && current.Item2 >= target || !max && current.Item2 <= target) { 907 run.Results[table + ".Target" + target] = new DoubleValue(current.Item1); 908 i++; 909 } else { 910 j++; 911 } 877 var absTargets = GetAbsoluteTargetsWorstToBest(pd); 878 879 var prevIndex = 0; 880 for (var i = 0; i < absTargets.Length; i++) { 881 var absTarget = absTargets[i]; 882 var index = values.BinarySearch(prevIndex, values.Count - prevIndex, Tuple.Create(0.0, absTarget), new TargetComparer(max)); 883 if (index < 0) { 884 index = ~index; 885 if (index >= values.Count) break; // the target (and subsequent ones) wasn't achieved 886 } 887 var target = targetsAreRelative ? (targets[i] * 100) : absTarget; 888 run.Results[table + (targetsAreRelative ? ".RelTarget " : ".AbsTarget ") + target + (targetsAreRelative ? "%" : string.Empty)] = new DoubleValue(values[index].Item1); 889 prevIndex = index; 912 890 } 913 891 } … … 915 893 916 894 private void markerCheckBox_CheckedChanged(object sender, EventArgs e) { 895 SuspendRepaint(); 896 try { 897 UpdateResultsByTarget(); 898 } finally { ResumeRepaint(true); } 899 } 900 901 private void showLabelsCheckBox_CheckedChanged(object sender, EventArgs e) { 902 showLabelsInTargetChart = showLabelsCheckBox.Checked; 917 903 SuspendRepaint(); 918 904 try { … … 931 917 double b; 932 918 if (!double.TryParse(ts, out b)) { 933 errorProvider.SetError(budgetsTextBox, "Not all targets can be parsed: " + ts);919 errorProvider.SetError(budgetsTextBox, "Not all budgets can be parsed: " + ts); 934 920 e.Cancel = true; 935 921 return; … … 938 924 } 939 925 if (budgetList.Count == 0) { 940 errorProvider.SetError(budgetsTextBox, "Give at least one target value!");926 errorProvider.SetError(budgetsTextBox, "Give at least one budget value!"); 941 927 e.Cancel = true; 942 928 return; … … 944 930 e.Cancel = false; 945 931 errorProvider.SetError(budgetsTextBox, null); 946 budgets = budgetList.ToArray(); 932 budgets = budgetList.OrderBy(x => x).ToArray(); 933 try { 934 suppressBudgetsEvents = true; 935 budgetsTextBox.Text = string.Join(" ; ", budgets); 936 } finally { suppressBudgetsEvents = false; } 947 937 UpdateResultsByCost(); 948 938 SetEnabledStateOfControls(); 949 }950 951 private void aggregateBudgetsCheckBox_CheckedChanged(object sender, EventArgs e) {952 SuspendRepaint();953 try {954 UpdateResultsByCost();955 } finally { ResumeRepaint(true); }956 939 } 957 940 … … 966 949 min = (decimal)Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item1)).Min(); 967 950 max = (decimal)Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item1)).Max(); 968 count = 6;951 count = 3; 969 952 } 970 953 using (var dialog = new DefineArithmeticProgressionDialog(false, min, max, (max - min) / count)) { … … 973 956 budgets = dialog.Values.OrderBy(x => x).Select(x => (double)x).ToArray(); 974 957 975 suppressBudgetsEvents = true; 976 budgetsTextBox.Text = string.Join(" ; ", budgets); 977 suppressBudgetsEvents = false; 958 try { 959 suppressBudgetsEvents = true; 960 budgetsTextBox.Text = string.Join(" ; ", budgets); 961 } finally { suppressBudgetsEvents = false; } 978 962 979 963 UpdateResultsByCost(); … … 986 970 private void addBudgetsAsResultButton_Click(object sender, EventArgs e) { 987 971 var table = (string)dataTableComboBox.SelectedItem; 988 var budgetStrings = budgetsTextBox.Text.Split(new[] { ';', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);989 if (budgetStrings.Length == 0) {990 MessageBox.Show("Define a number of budgets.");991 return;992 }993 var budgetList = new List<double>();994 foreach (var bs in budgetStrings) {995 double v;996 if (!double.TryParse(bs, out v)) {997 MessageBox.Show("Budgets must be a valid number: " + bs);998 return;999 }1000 budgetList.Add(v);1001 }1002 budgetList.Sort();1003 972 1004 973 foreach (var run in Content) { … … 1006 975 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 1007 976 var values = resultsTable.Rows.First().Values; 1008 var i = 0; 1009 var j = 0; 1010 Tuple<double, double> prev = null; 1011 while (i < budgetList.Count && j < values.Count) { 1012 var current = values[j]; 1013 if (current.Item1 >= budgetList[i]) { 1014 if (prev != null || current.Item1 == budgetList[i]) { 1015 var tgt = (prev == null || current.Item1 == budgetList[i]) ? current.Item2 : prev.Item2; 1016 run.Results[table + ".Cost" + budgetList[i]] = new DoubleValue(tgt); 1017 } 1018 i++; 1019 } else { 1020 j++; 1021 prev = current; 1022 } 977 var pd = new ProblemInstance(run); 978 pd = problems.Single(x => x.Equals(pd)); 979 980 var prevIndex = 0; 981 foreach (var b in budgets) { 982 var index = values.BinarySearch(prevIndex, values.Count - prevIndex, Tuple.Create(b, 0.0), new CostComparer()); 983 if (index < 0) { 984 index = ~index; 985 if (index >= values.Count) break; // the run wasn't long enough to use up budget b (or any subsequent larger one) 986 } 987 var v = values[index]; 988 var tgt = targetsAreRelative ? CalculateRelativeDifference(pd.IsMaximization(), pd.BestKnownQuality, v.Item2) : v.Item2; 989 run.Results[table + (targetsAreRelative ? ".CostForRelTarget " : ".CostForAbsTarget ") + b] = new DoubleValue(tgt); 990 prevIndex = index; 1023 991 } 1024 992 } … … 1080 1048 else pd.BestKnownQuality = double.NaN; 1081 1049 } 1082 //problemComboBox.ResetBindings();1083 1050 } 1084 1051 #endregion 1085 1052 1086 1053 private void ConfigureSeries(Series series) { 1087 series.SmartLabelStyle.Enabled = true;1054 series.SmartLabelStyle.Enabled = showLabelsInTargetChart; 1088 1055 series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.No; 1089 1056 series.SmartLabelStyle.CalloutLineAnchorCapStyle = LineAnchorCapStyle.None; … … 1418 1385 } 1419 1386 } 1387 1388 private class CostComparer : Comparer<Tuple<double, double>> { 1389 public override int Compare(Tuple<double, double> x, Tuple<double, double> y) { 1390 return x.Item1.CompareTo(y.Item1); 1391 } 1392 } 1393 1394 private class TargetComparer : Comparer<Tuple<double, double>> { 1395 public bool Maximization { get; private set; } 1396 public TargetComparer(bool maximization) { 1397 Maximization = maximization; 1398 } 1399 1400 public override int Compare(Tuple<double, double> x, Tuple<double, double> y) { 1401 return Maximization ? x.Item2.CompareTo(y.Item2) : y.Item2.CompareTo(x.Item2); 1402 } 1403 } 1420 1404 } 1421 1405 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r14600 r15256 52 52 } 53 53 54 public ListView ItemsListView { 55 get { return itemsListView; } 56 } 54 private int EmptyImageIndex { get { return 0; } } 55 private int RunImageIndex { get { return 1; } } 57 56 58 57 public RunCollectionView() { 59 58 InitializeComponent(); 60 itemsGroupBox.Text = "Runs"; 59 UpdateGroupBoxText(); 60 61 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Nothing); 62 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class); 63 61 64 itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>(); 62 65 runCollectionModifiersListView.Evaluator = EvaluateModifications; … … 83 86 } 84 87 private void DeregisterItemEvents(IRun item) { 85 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);86 88 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 87 89 item.PropertyChanged -= Item_PropertyChanged; 88 90 } 89 91 private void RegisterItemEvents(IRun item) { 90 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);91 92 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 92 93 item.PropertyChanged += Item_PropertyChanged; … … 116 117 itemsListView.Items.Clear(); 117 118 itemListViewItemMapping.Clear(); 118 RebuildImageList();119 119 viewHost.Content = null; 120 121 UpdateGroupBoxText(); 120 122 121 123 if (Content != null) { … … 129 131 runCollectionModifiersListView.Content = RunCollection.Modifiers; 130 132 } 133 134 ListViewItem[] items = new ListViewItem[Content.Count]; 135 int count = 0; 131 136 foreach (IRun item in Content) { 132 137 ListViewItem listViewItem = CreateListViewItem(item); 133 AddListViewItem(listViewItem); 138 134 139 if ((selectedName != null) && item.Name.Equals(selectedName)) 135 140 listViewItem.Selected = true; 136 } 141 items[count] = listViewItem; 142 count++; 143 } 144 itemsListView.Items.AddRange(items); 137 145 AdjustListViewColumnSizes(); 138 146 } else { … … 166 174 } 167 175 168 private ListViewItem CreateListViewItem(IRun item) { 176 private static readonly string tooltipText = ItemAttribute.GetName(typeof(Run)) + ": " + 177 ItemAttribute.GetDescription(typeof(Run)); 178 private ListViewItem CreateListViewItem(IRun run) { 169 179 ListViewItem listViewItem = new ListViewItem(); 170 if ( item== null) {180 if (run == null) { 171 181 listViewItem.Text = "null"; 172 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Nothing); 173 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 182 listViewItem.ImageIndex = EmptyImageIndex; 183 return listViewItem; 184 } 185 186 listViewItem.Text = run.Name; 187 listViewItem.ToolTipText = tooltipText; 188 listViewItem.ImageIndex = RunImageIndex; 189 listViewItem.Tag = run; 190 191 if (run.Visible) { 192 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 193 listViewItem.ForeColor = run.Color; 174 194 } else { 175 listViewItem.Text = item.ToString(); 176 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 177 itemsListView.SmallImageList.Images.Add(item.ItemImage); 178 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 179 listViewItem.Tag = item; 180 181 if (item.Visible) { 182 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 183 listViewItem.ForeColor = item.Color; 184 } else { 185 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 186 listViewItem.ForeColor = Color.LightGray; 187 } 188 } 195 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 196 listViewItem.ForeColor = Color.LightGray; 197 } 198 199 if (!itemListViewItemMapping.ContainsKey(run)) { 200 itemListViewItemMapping.Add(run, new List<ListViewItem>()); 201 RegisterItemEvents(run); 202 } 203 itemListViewItemMapping[run].Add(listViewItem); 204 189 205 return listViewItem; 190 206 } 191 private void AddListViewItem(ListViewItem listViewItem) { 192 if (listViewItem == null) throw new ArgumentNullException(); 193 itemsListView.Items.Add(listViewItem); 194 IRun run = listViewItem.Tag as IRun; 195 if (run != null) { 196 if (!itemListViewItemMapping.ContainsKey(run)) { 197 itemListViewItemMapping.Add(run, new List<ListViewItem>()); 198 RegisterItemEvents(run); 199 } 200 itemListViewItemMapping[run].Add(listViewItem); 201 } 202 } 207 203 208 private void RemoveListViewItem(ListViewItem listViewItem) { 204 209 if (listViewItem == null) throw new ArgumentNullException(); … … 213 218 listViewItem.Remove(); 214 219 } 215 private void UpdateListViewItemImage(ListViewItem listViewItem) { 216 if (listViewItem == null) throw new ArgumentNullException(); 217 IRun item = listViewItem.Tag as IRun; 218 int i = listViewItem.ImageIndex; 219 itemsListView.SmallImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage; 220 listViewItem.ImageIndex = -1; 221 listViewItem.ImageIndex = i; 222 } 220 223 221 private void UpdateListViewItemText(ListViewItem listViewItem) { 224 222 if (listViewItem == null) throw new ArgumentNullException(); … … 239 237 return listViewItems == null ? Enumerable.Empty<ListViewItem>() : listViewItems; 240 238 } 239 } 240 241 private void UpdateGroupBoxText() { 242 if (Content == null || Content.Count == 0) itemsGroupBox.Text = "Runs"; 243 else itemsGroupBox.Text = @"Runs (" + Content.Count + @")"; 241 244 } 242 245 … … 393 396 RunCollection.UpdateOfRunsInProgress = true; 394 397 RunCollection.Modify(); 395 } finally { 398 } 399 finally { 396 400 ReadOnly = false; 397 401 RunCollection.UpdateOfRunsInProgress = false; … … 406 410 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 407 411 else { 408 foreach (IRun item in e.Items) 409 AddListViewItem(CreateListViewItem(item)); 410 412 var items = e.Items.Select(CreateListViewItem).ToArray(); 413 itemsListView.Items.AddRange(items); 411 414 AdjustListViewColumnSizes(); 412 415 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 413 416 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 414 417 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 418 UpdateGroupBoxText(); 415 419 } 416 420 } … … 425 429 if (listViewItem != null) RemoveListViewItem(listViewItem); 426 430 } 427 RebuildImageList();428 431 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 429 432 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 430 433 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 434 UpdateGroupBoxText(); 431 435 } 432 436 } … … 441 445 if (listViewItem != null) RemoveListViewItem(listViewItem); 442 446 } 443 RebuildImageList(); 444 foreach (IRun item in e.Items) 445 AddListViewItem(CreateListViewItem(item)); 447 var items = e.Items.Select(CreateListViewItem).ToArray(); 448 itemsListView.Items.AddRange(items); 446 449 447 450 AdjustListViewColumnSizes(); … … 449 452 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 450 453 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 454 UpdateGroupBoxText(); 451 455 } 452 456 } … … 456 460 suppressUpdates = RunCollection.UpdateOfRunsInProgress; 457 461 if (!suppressUpdates) { 458 foreach (IRun item in Content) { 459 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection 460 ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault(); 461 if (listViewItem != null) RemoveListViewItem(listViewItem); 462 foreach (IRun run in Content) { 463 DeregisterItemEvents(run); 462 464 } 463 RebuildImageList(); 464 foreach (IRun item in Content) 465 AddListViewItem(CreateListViewItem(item)); 465 itemsListView.Items.Clear(); 466 itemListViewItemMapping.Clear(); 467 var items = Content.Select(CreateListViewItem).ToArray(); 468 itemsListView.Items.AddRange(items); 466 469 467 470 AdjustListViewColumnSizes(); … … 469 472 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 470 473 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 474 UpdateGroupBoxText(); 471 475 } 472 476 } … … 475 479 476 480 #region Item Events 477 private void Item_ItemImageChanged(object sender, EventArgs e) {478 if (suppressUpdates) return;479 if (InvokeRequired)480 Invoke(new EventHandler(Item_ItemImageChanged), sender, e);481 else {482 IRun item = (IRun)sender;483 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))484 UpdateListViewItemImage(listViewItem);485 }486 }487 481 private void Item_ToStringChanged(object sender, EventArgs e) { 488 482 if (suppressUpdates) return; … … 528 522 } 529 523 } 530 private void RebuildImageList() {531 itemsListView.SmallImageList.Images.Clear();532 foreach (ListViewItem listViewItem in itemsListView.Items) {533 IRun item = listViewItem.Tag as IRun;534 itemsListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage);535 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;536 }537 }538 524 #endregion 539 525 } -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/Individual.cs
r14600 r15256 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Core; 24 26 … … 27 29 protected IEncoding Encoding { get; private set; } 28 30 protected IScope Scope { get; private set; } 29 30 31 public string Name { get { return Encoding.Name; } } 31 32 … … 35 36 } 36 37 37 public abstract IItem this[string name] { get; set; } 38 public IItem this[string name] { 39 get { return ExtractScopeValue(name, Scope); } 40 set { SetScopeValue(name, Scope, value); } 41 } 42 43 public IEnumerable<KeyValuePair<string, IItem>> Values { 44 get { return Scope.Variables.Select(v => new KeyValuePair<string, IItem>(v.Name, v.Value)); } 45 } 38 46 public abstract TEncoding GetEncoding<TEncoding>() where TEncoding : class, IEncoding; 39 47 40 public Individual Copy() { 41 return CopyToScope(new Scope()); 48 public abstract Individual Copy(); 49 internal void CopyToScope(IScope scope) { 50 foreach (var val in Values) 51 SetScopeValue(val.Key, scope, val.Value); 42 52 } 43 53 44 public abstract Individual CopyToScope(IScope scope); 45 46 protected static IItem ExtractScopeValue(string name, IScope scope) { 54 private static IItem ExtractScopeValue(string name, IScope scope) { 55 if (scope == null) throw new ArgumentNullException("scope"); 47 56 if (!scope.Variables.ContainsKey(name)) throw new ArgumentException(string.Format(" {0} cannot be found in the provided scope.", name)); 48 57 var value = scope.Variables[name].Value; … … 51 60 } 52 61 53 protected static void SetScopeValue(string name, IScope scope, IItem value) { 62 private static void SetScopeValue(string name, IScope scope, IItem value) { 63 if (scope == null) throw new ArgumentNullException("scope"); 54 64 if (value == null) throw new ArgumentNullException("value"); 65 55 66 if (!scope.Variables.ContainsKey(name)) scope.Variables.Add(new Variable(name, value)); 56 67 else scope.Variables[name].Value = value; -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/MultiEncodingIndividual.cs
r14600 r15256 32 32 } 33 33 34 private readonly IEnumerable<Individual> individuals; 34 public MultiEncodingIndividual(MultiEncoding encoding, IScope scope) 35 : base(encoding, scope) { } 35 36 36 public MultiEncodingIndividual(MultiEncoding encoding, IScope scope) 37 : base(encoding, scope) { 38 individuals = encoding.Encodings.Select(e => e.GetIndividual(scope)).ToArray(); 37 private MultiEncodingIndividual(MultiEncodingIndividual copy) : base(copy.Encoding, new Scope()) { 38 copy.CopyToScope(Scope); 39 39 } 40 41 private MultiEncodingIndividual(MultiEncoding encoding, IScope scope, IEnumerable<Individual> individuals) 42 : base(encoding, scope) { 43 this.individuals = individuals; 44 } 45 46 47 public override IItem this[string name] { 48 get { 49 var individual = individuals.SingleOrDefault(i => i.Name == name); 50 if (individual == null) throw new ArgumentException(string.Format("{0} is not part of the specified encoding.", name)); 51 return individual[name]; 52 } 53 set { 54 var individual = individuals.SingleOrDefault(i => i.Name == name); 55 if (individual == null) throw new ArgumentException(string.Format("{0} is not part of the specified encoding.", name)); 56 individual[name] = value; 57 } 40 public override Individual Copy() { 41 return new MultiEncodingIndividual(this); 58 42 } 59 43 … … 62 46 try { 63 47 encoding = (TEncoding)Encoding.Encodings.SingleOrDefault(e => e is TEncoding); 64 } catch (InvalidOperationException) { 48 } 49 catch (InvalidOperationException) { 65 50 throw new InvalidOperationException(string.Format("The individual uses multiple {0} .", typeof(TEncoding).GetPrettyName())); 66 51 } … … 68 53 return encoding; 69 54 } 70 71 public override Individual CopyToScope(IScope scope) {72 var copies = individuals.Select(i => i.CopyToScope(scope)).ToArray();73 return new MultiEncodingIndividual(Encoding, scope, copies);74 }75 55 } 76 56 } -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/SingleEncodingIndividual.cs
r14600 r15256 32 32 } 33 33 34 public override IItem this[string name] { 35 get { 36 if (Name != name) throw new ArgumentException(string.Format("{0} is not part of the individual.", name)); 37 return ExtractScopeValue(Name, Scope); 38 } 39 set { 40 if (Name != name) throw new ArgumentException(string.Format("{0} is not part of the individual.", name)); 41 SetScopeValue(Name, Scope, value); 42 } 34 private SingleEncodingIndividual(SingleEncodingIndividual copy) : base(copy.Encoding, new Scope()) { 35 copy.CopyToScope(Scope); 36 } 37 public override Individual Copy() { 38 return new SingleEncodingIndividual(this); 43 39 } 44 40 … … 48 44 return encoding; 49 45 } 50 51 public override Individual CopyToScope(IScope scope) {52 SetScopeValue(Name, scope, (IItem)this[Name].Clone());53 return new SingleEncodingIndividual(Encoding, scope);54 }55 46 } 56 47 -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs
r14600 r15256 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 23 25 using HeuristicLab.Common; … … 57 59 public abstract double[] Evaluate(Individual individual, IRandom random); 58 60 public virtual void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) { } 59 61 60 62 protected override void OnOperatorsChanged() { 61 63 base.OnOperatorsChanged(); … … 74 76 if (encoding != null && encoding.Operators.Any(x => x is ISingleObjectiveOperator && !(x is IMultiObjectiveOperator))) 75 77 encoding.Operators = encoding.Operators.Where(x => !(x is ISingleObjectiveOperator) || x is IMultiObjectiveOperator).ToList(); 78 79 foreach (var multiOp in Encoding.Operators.OfType<IMultiOperator>()) { 80 foreach (var soOp in multiOp.Operators.Where(x => x is ISingleObjectiveOperator).ToList()) { 81 multiOp.RemoveOperator(soOp); 82 } 83 } 76 84 } 77 85 -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r14600 r15256 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 84 85 } 85 86 87 protected Tuple<Individual, double> GetBestIndividual(Individual[] individuals, double[] qualities) { 88 return GetBestIndividual(individuals, qualities, Maximization); 89 } 90 public static Tuple<Individual, double> GetBestIndividual(Individual[] individuals, double[] qualities, bool maximization) { 91 var zipped = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }); 92 var best = (maximization ? zipped.OrderByDescending(z => z.Quality) : zipped.OrderBy(z => z.Quality)).First(); 93 return Tuple.Create(best.Individual, best.Quality); 94 } 95 86 96 protected override void OnOperatorsChanged() { 87 97 base.OnOperatorsChanged(); … … 100 110 if (encoding.Operators.Any(x => x is IMultiObjectiveOperator && !(x is ISingleObjectiveOperator))) 101 111 encoding.Operators = encoding.Operators.Where(x => !(x is IMultiObjectiveOperator) || x is ISingleObjectiveOperator).ToList(); 112 113 foreach (var multiOp in Encoding.Operators.OfType<IMultiOperator>()) { 114 foreach (var moOp in multiOp.Operators.Where(x => x is IMultiObjectiveOperator).ToList()) { 115 multiOp.RemoveOperator(moOp); 116 } 117 } 102 118 } 103 119 -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r14776 r15256 201 201 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 202 202 <Compile Include="Interfaces\IMultiObjectiveOperator.cs" /> 203 <Compile Include="MultiObjective\DominationCalculator.cs" /> 203 204 <Compile Include="Interfaces\IPreexistingSolutionCreator.cs" /> 204 205 <Compile Include="Interfaces\ISolutionModel.cs" /> … … 240 241 <Compile Include="Interfaces\IDiscreteDoubleMatrixModifier.cs" /> 241 242 <Compile Include="Algorithms\HeuristicOptimizationEngineAlgorithm.cs" /> 242 <Compile Include="Interfaces\IGlobalParticleUpdater.cs" />243 243 <Compile Include="Interfaces\ILocalImprovementOperator.cs" /> 244 <Compile Include="Interfaces\ILocalParticleUpdater.cs" />245 244 <Compile Include="Algorithms\HeuristicOptimizationAlgorithm.cs" /> 246 245 <Compile Include="Interfaces\IMultiNeighborhoodShakingOperator.cs" /> -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Interfaces/IParticleCreator.cs
r14600 r15256 27 27 /// </summary> 28 28 public interface IParticleCreator : ISolutionCreator { 29 ILookupParameter<ISolutionCreator> SolutionCreatorParameter { get; } 29 30 } 30 31 } -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
- Property svn:mergeinfo changed
-
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Results/ResultCollection.cs
r12764 r15256 75 75 } 76 76 77 public void AddOrUpdateResult(string name, IItem value) { 78 IResult res; 79 if (!TryGetValue(name, out res)) { 80 res = new Result(name, value); 81 Add(res); 82 } else res.Value = value; 83 } 77 84 } 78 85 } -
branches/PerformanceComparison/HeuristicLab.Problems.Instances.QAPLIB
-
Property
svn:mergeinfo
set to
/trunk/sources/HeuristicLab.Problems.Instances.QAPLIB merged eligible
-
Property
svn:mergeinfo
set to
Note: See TracChangeset
for help on using the changeset viewer.