Changeset 15256


Ignore:
Timestamp:
07/15/17 14:25:44 (9 days ago)
Author:
abeham
Message:

#2457: merged trunk into branch

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  
    120120      var groupItems = new List<int>();
    121121      var lleb = current.ToBackLinks();
    122       Move bestOfTheRest = null;
     122      EMSSMove bestOfTheRest = null;
    123123      var bestOfTheRestF = double.NaN;
    124124      var lastAppliedMove = -1;
     
    161161            break;
    162162          } else {
    163             foreach (var move in MoveGenerator.GenerateForItem(i, groupItems, current, lleb)) {
     163            foreach (var move in ExhaustiveEMSSMoveGenerator.GenerateForItem(i, groupItems, current, lleb)) {
    164164              // we intend to break link i -> next
    165165              var qualityToBreak = tabu[i, next];
     
    289289      ISingleObjectiveSolutionScope<LinearLinkage> best = null;
    290290      while (true) {
    291         Move bestMove = null;
     291        EMSSMove bestMove = null;
    292292        var bestMoveQ = double.NaN;
    293293        // 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)) {
    295295          var distBefore = Dist(probe, b);
    296296          m.Apply(probe.Solution);
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LocalSearch/StaticAPI/ExhaustiveLocalSearch.cs

    r14552 r15256  
    4242        var groupItems = new List<int>();
    4343        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()) {
    4545            move.Apply(solution);
    4646            var moveF = eval(solution, token);
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding

  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEqualityComparer.cs

    r14659 r15256  
    1919 */
    2020#endregion
    21  
     21
     22using System;
    2223using System.Collections.Generic;
    23 using System.Linq;
     24using HeuristicLab.PluginInfrastructure;
    2425
    2526namespace HeuristicLab.Encodings.BinaryVectorEncoding {
     27  [NonDiscoverableType]
    2628  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;
    2936    }
     37
    3038    public override int GetHashCode(BinaryVector obj) {
     39      if (obj == null) throw new ArgumentNullException("obj", "BinaryVectorEqualityComparer: Cannot compute hash value of null.");
    3140      unchecked {
    3241        int hash = 17;
    33         foreach (var bit in obj) {
     42        foreach (var bit in obj)
    3443          hash = hash * 29 + (bit ? 1231 : 1237);
    35         }
    3644        return hash;
    3745      }
  • branches/PerformanceComparison/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs

    r14659 r15256  
    4545    public static double CalculateSimilarity(BinaryVector left, BinaryVector right) {
    4646      if (left == null || right == null)
    47         throw new ArgumentException("Cannot calculate similarity because one or both of the provided scopes is null.");
     47        throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null.");
    4848      if (left.Length != right.Length)
    4949        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;
    5153
    5254      double similarity = 0.0;
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding

  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj

    r14776 r15256  
    155155    <Compile Include="Crossovers\SinglePointCrossover.cs" />
    156156    <Compile Include="Interfaces\ILinearLinkageMoveOperator.cs" />
     157    <Compile Include="Interfaces\ILinearLinkageEMSSMoveOperator.cs" />
    157158    <Compile Include="Interfaces\ILinearLinkageSwap2MoveOperator.cs" />
    158159    <Compile Include="Interfaces\ILinearLinkageCreator.cs" />
     
    167168    <Compile Include="Manipulators\MergeGroupManipulator.cs" />
    168169    <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" />
    175180    <Compile Include="Moves\Swap\ExhaustiveSwap2MoveGenerator.cs" />
    176181    <Compile Include="Moves\Swap\StochasticSwap2MultiMoveGenerator.cs" />
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEqualityComparer.cs

    r14659 r15256  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
     24using HeuristicLab.PluginInfrastructure;
    2325
    2426namespace HeuristicLab.Encodings.LinearLinkageEncoding {
     27  [NonDiscoverableType]
    2528  public class LinearLinkageEqualityComparer : EqualityComparer<LinearLinkage> {
    2629    public override bool Equals(LinearLinkage x, LinearLinkage y) {
    27       if (x == null && y == null) return true;
     30      if (ReferenceEquals(x, y)) return true;
    2831      if (x == null || y == null) return false;
    2932      if (x.Length != y.Length) return false;
     
    3437
    3538    public override int GetHashCode(LinearLinkage obj) {
     39      if (obj == null) throw new ArgumentNullException("obj", "LinearLinkageEqualityComparer: Cannot compute hash value of null.");
    3640      unchecked {
    3741        int hash = 17;
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Moves/Swap/ExhaustiveSwap2MoveGenerator.cs

    r14185 r15256  
    2929
    3030namespace 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.")]
    3232  [StorableClass]
    3333  public class ExhaustiveSwap2MoveGenerator : Swap2MoveGenerator, IExhaustiveMoveGenerator {
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Moves/Swap/StochasticSwap2SingleMoveGenerator.cs

    r14185 r15256  
    2929
    3030namespace 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.")]
    3232  [StorableClass]
    3333  public class StochasticSwap2SingleMoveGenerator : Swap2MoveGenerator, IStochasticOperator, ISingleMoveGenerator {
  • branches/PerformanceComparison/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/SimilarityCalculators/HammingSimilarityCalculator.cs

    r14659 r15256  
    3030  [StorableClass]
    3131  public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    32 
    33     protected override bool IsCommutative {
    34       get { return true; }
    35     }
     32    protected override bool IsCommutative { get { return true; } }
    3633
    3734    [StorableConstructor]
    3835    private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3936    private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
    40     public HammingSimilarityCalculator() { }
     37    public HammingSimilarityCalculator() : base() { }
    4138
    4239    public override IDeepCloneable Clone(Cloner cloner) {
     
    4542
    4643    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
    4852      var similarity = 0;
    4953      for (var i = 0; i < left.Length; i++) {
  • branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding

  • branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs

    r14600 r15256  
    3030  public class PermutationEqualityComparer : EqualityComparer<Permutation> {
    3131    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;
    3235      if (x.PermutationType != y.PermutationType) return false;
    33       if (x.Length != y.Length) return false;
    3436      switch (x.PermutationType) {
    3537        case PermutationTypes.Absolute:
     
    6769
    6870    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.");
    7072      return GenerateHashString(obj).GetHashCode();
    7173    }
  • branches/PerformanceComparison/HeuristicLab.Encodings.PermutationEncoding/3.3/SimilarityCalculators/HammingSimilarityCalculator.cs

    r14659 r15256  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Optimization.Operators;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627
    2728namespace HeuristicLab.Encodings.PermutationEncoding {
    2829  [Item("Hamming Similarity Calculator for Permutation", "An operator that performs similarity calculation between two permutation-encoded solutions.")]
     30  [StorableClass]
    2931  public sealed class HammingSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3032    protected override bool IsCommutative { get { return true; } }
    3133
     34    [StorableConstructor]
    3235    private HammingSimilarityCalculator(bool deserializing) : base(deserializing) { }
    3336    private HammingSimilarityCalculator(HammingSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
     
    4043    public static double CalculateSimilarity(Permutation left, Permutation right) {
    4144      if (left == null || right == null)
    42         throw new ArgumentException("Cannot calculate similarity because one of the provided solutions or both are null.");
     45        throw new ArgumentException("Cannot calculate similarity because one or both of the provided solutions is null.");
    4346      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.");
    4548      if (left.Length != right.Length)
    4649        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;
    4853
    4954      switch (left.PermutationType) {
  • branches/PerformanceComparison/HeuristicLab.Optimization

  • branches/PerformanceComparison/HeuristicLab.Optimization.Views

  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs

    r14600 r15256  
    463463    }
    464464
     465  public bool StatisticsVisible {
     466    get { return splitContainer.Panel2Collapsed; }
     467    set { splitContainer.Panel2Collapsed = value; }
     468  }
     469 
    465470    public void SetXAxis(string axisName) {
    466471      xAxisComboBox.SelectedItem = axisName;
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs

    r14600 r15256  
    139139      this.xAxisComboBox.Size = new System.Drawing.Size(400, 21);
    140140      this.xAxisComboBox.TabIndex = 7;
     141      this.xAxisComboBox.Sorted = false;
    141142      this.xAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged);
    142143      //
     
    160161      this.yAxisComboBox.Size = new System.Drawing.Size(400, 21);
    161162      this.yAxisComboBox.TabIndex = 5;
     163      this.yAxisComboBox.Sorted = false;
    162164      this.yAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged);
    163165      //
     
    183185      this.sizeComboBox.Name = "sizeComboBox";
    184186      this.sizeComboBox.Size = new System.Drawing.Size(300, 21);
     187      this.sizeComboBox.Sorted = false;
    185188      this.sizeComboBox.TabIndex = 14;
    186189      this.sizeComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged);
     
    264267      this.radioButtonGroup.Controls.Add(this.zoomButton);
    265268      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);
    267270      this.radioButtonGroup.Name = "radioButtonGroup";
    268271      this.radioButtonGroup.Size = new System.Drawing.Size(122, 32);
     
    275278      this.colorRunsButton.Enabled = false;
    276279      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);
    278281      this.colorRunsButton.Name = "colorRunsButton";
    279282      this.colorRunsButton.Size = new System.Drawing.Size(21, 21);
     
    317320      this.transparencyTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    318321      this.transparencyTrackBar.LargeChange = 16;
    319       this.transparencyTrackBar.Location = new System.Drawing.Point(302, 715);
     322      this.transparencyTrackBar.Location = new System.Drawing.Point(177, 717);
    320323      this.transparencyTrackBar.Maximum = 254;
    321324      this.transparencyTrackBar.Name = "transparencyTrackBar";
     
    331334      this.hideRunsButton.Enabled = false;
    332335      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);
    334337      this.hideRunsButton.Name = "hideRunsButton";
    335338      this.hideRunsButton.Size = new System.Drawing.Size(43, 21);
     
    347350      this.colorDialogButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    348351      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);
    350353      this.colorDialogButton.Name = "colorDialogButton";
    351354      this.colorDialogButton.Size = new System.Drawing.Size(14, 21);
     
    390393      this.transparencyLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    391394      this.transparencyLabel.AutoSize = true;
    392       this.transparencyLabel.Location = new System.Drawing.Point(233, 717);
     395      this.transparencyLabel.Location = new System.Drawing.Point(108, 719);
    393396      this.transparencyLabel.Name = "transparencyLabel";
    394397      this.transparencyLabel.Size = new System.Drawing.Size(75, 13);
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r14600 r15256  
    9393    }
    9494
     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
    95112    protected override void RegisterContentEvents() {
    96113      base.RegisterContentEvents();
     
    227244        string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension));
    228245        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);
    230250        this.yAxisComboBox.Items.AddRange(additionalAxisDimension);
    231         this.yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
     251        this.yAxisComboBox.Items.AddRange(sortedColumnNames);
    232252        string[] additionalSizeDimension = Enum.GetNames(typeof(SizeDimension));
    233253        this.sizeComboBox.Items.AddRange(additionalSizeDimension);
    234         this.sizeComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
     254        this.sizeComboBox.Items.AddRange(sortedColumnNames);
    235255        this.sizeComboBox.SelectedItem = SizeDimension.Constant.ToString();
    236256
     
    726746    }
    727747    private void hideRunsToolStripMenuItem_Click(object sender, EventArgs e) {
    728       //ToList is necessary to prevent lazy evaluation
    729       HideRuns(selectedRuns.ToList());
     748      HideRuns(selectedRuns);
    730749      //could not use ClearSelectedRuns as the runs are not visible anymore
    731750      selectedRuns.Clear();
    732751    }
    733752    private void hideRunsButton_Click(object sender, EventArgs e) {
    734       //ToList is necessary to prevent lazy evaluation
    735       HideRuns(selectedRuns.ToList());
     753      HideRuns(selectedRuns);
    736754      //could not use ClearSelectedRuns as the runs are not visible anymore
    737755      selectedRuns.Clear();
     
    739757
    740758    private void HideRuns(IEnumerable<IRun> runs) {
     759      Content.UpdateOfRunsInProgress = true;
    741760      visibilityConstraint.Active = false;
    742761      if (!Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Add(visibilityConstraint);
     
    745764      }
    746765      visibilityConstraint.Active = true;
     766      Content.UpdateOfRunsInProgress = false;
    747767    }
    748768
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs

    r14665 r15256  
    4545    private void InitializeComponent() {
    4646      this.components = new System.ComponentModel.Container();
    47       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    48       System.Windows.Forms.DataVisualization.Charting.Legend legend1 = 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();
    4949      this.dataTableComboBox = new System.Windows.Forms.ComboBox();
    5050      this.dataTableLabel = new System.Windows.Forms.Label();
     
    6666      this.relativeOrAbsoluteComboBox = new System.Windows.Forms.ComboBox();
    6767      this.targetChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     68      this.showLabelsCheckBox = new System.Windows.Forms.CheckBox();
    6869      this.markerCheckBox = new System.Windows.Forms.CheckBox();
    6970      this.boundShadingCheckBox = new System.Windows.Forms.CheckBox();
     
    7172      this.byCostViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    7273      this.budgetLogScalingCheckBox = new System.Windows.Forms.CheckBox();
    73       this.aggregateBudgetsCheckBox = new System.Windows.Forms.CheckBox();
    7474      this.generateBudgetsButton = new System.Windows.Forms.Button();
    7575      this.byTableTabPage = new System.Windows.Forms.TabPage();
     
    202202      this.budgetsTextBox.Location = new System.Drawing.Point(59, 8);
    203203      this.budgetsTextBox.Name = "budgetsTextBox";
    204       this.budgetsTextBox.Size = new System.Drawing.Size(309, 20);
     204      this.budgetsTextBox.Size = new System.Drawing.Size(391, 20);
    205205      this.budgetsTextBox.TabIndex = 6;
    206206      this.budgetsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.budgetsTextBox_Validating);
     
    249249      this.byTargetTabPage.Controls.Add(this.relativeOrAbsoluteComboBox);
    250250      this.byTargetTabPage.Controls.Add(this.targetChart);
     251      this.byTargetTabPage.Controls.Add(this.showLabelsCheckBox);
    251252      this.byTargetTabPage.Controls.Add(this.markerCheckBox);
    252253      this.byTargetTabPage.Controls.Add(this.boundShadingCheckBox);
     
    284285            | System.Windows.Forms.AnchorStyles.Left)
    285286            | System.Windows.Forms.AnchorStyles.Right)));
    286       chartArea1.AxisX.IsStartedFromZero = false;
    287       chartArea1.AxisX.MinorGrid.Enabled = true;
    288       chartArea1.AxisX.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke;
    289       chartArea1.AxisX.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
    290       chartArea1.AxisY.Maximum = 1D;
    291       chartArea1.AxisY.Minimum = 0D;
    292       chartArea1.AxisY.MinorGrid.Enabled = true;
    293       chartArea1.AxisY.MinorGrid.LineColor = System.Drawing.Color.WhiteSmoke;
    294       chartArea1.AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
    295       chartArea1.Name = "ChartArea1";
    296       this.targetChart.ChartAreas.Add(chartArea1);
    297       legend1.Alignment = System.Drawing.StringAlignment.Center;
    298       legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
    299       legend1.Name = "Legend1";
    300       this.targetChart.Legends.Add(legend1);
     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);
    301302      this.targetChart.Location = new System.Drawing.Point(6, 34);
    302303      this.targetChart.Name = "targetChart";
     
    308309      this.targetChart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    309310      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);
    310325      //
    311326      // markerCheckBox
     
    339354      this.byCostTabPage.Controls.Add(this.byCostViewHost);
    340355      this.byCostTabPage.Controls.Add(this.budgetLogScalingCheckBox);
    341       this.byCostTabPage.Controls.Add(this.aggregateBudgetsCheckBox);
    342356      this.byCostTabPage.Controls.Add(this.generateBudgetsButton);
    343357      this.byCostTabPage.Controls.Add(this.budgetsLabel);
     
    379393      this.budgetLogScalingCheckBox.UseVisualStyleBackColor = true;
    380394      this.budgetLogScalingCheckBox.CheckedChanged += new System.EventHandler(this.logScalingCheckBox_CheckedChanged);
    381       //
    382       // aggregateBudgetsCheckBox
    383       //
    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);
    395395      //
    396396      // generateBudgetsButton
     
    496496    private System.Windows.Forms.TabPage byCostTabPage;
    497497    private System.Windows.Forms.TabPage byTableTabPage;
    498     private System.Windows.Forms.CheckBox aggregateBudgetsCheckBox;
    499498    private System.Windows.Forms.Button generateBudgetsButton;
    500499    private System.Windows.Forms.CheckBox budgetLogScalingCheckBox;
     
    507506    private System.Windows.Forms.CheckBox markerCheckBox;
    508507    private System.Windows.Forms.ComboBox relativeOrAbsoluteComboBox;
     508    private System.Windows.Forms.CheckBox showLabelsCheckBox;
    509509  }
    510510}
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r14776 r15256  
    8181    private double[] budgets;
    8282    private bool targetsAreRelative = true;
     83    private bool showLabelsInTargetChart = true;
    8384    private readonly BindingList<ProblemInstance> problems;
    8485
     
    9697      targetChart.ChartAreas[0].CursorX.Interval = 1;
    9798      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).") {
    99100        VisualProperties = {
    100           YAxisTitle = "Proportion of unused budgets",
     101          YAxisTitle = "Proportion of runs",
    101102          YAxisMinimumFixedValue = 0,
    102103          YAxisMinimumAuto = false,
     
    284285      addTargetsAsResultButton.Enabled = Content != null && targets != null && dataTableComboBox.SelectedIndex >= 0;
    285286      addBudgetsAsResultButton.Enabled = Content != null && budgets != null && dataTableComboBox.SelectedIndex >= 0;
     287      generateTargetsButton.Enabled = targets != null;
    286288    }
    287289
     
    314316      targetChart.Series.Clear();
    315317      invisibleTargetSeries.Clear();
    316 
     318     
    317319      var table = (string)dataTableComboBox.SelectedItem;
    318320      if (string.IsNullOrEmpty(table)) return;
     
    424426            if (!labelPrinted && row.Points.Count > 0) {
    425427              var point = row.Points.Last();
    426               point.Label = row.Name;
     428              if (showLabelsInTargetChart)
     429                point.Label = row.Name;
    427430              point.MarkerStyle = MarkerStyle.Cross;
    428431              point.MarkerBorderWidth = 1;
     
    456459            if (!labelPrinted) {
    457460              var point = row.Points.Last();
    458               point.Label = row.Name;
     461              if (showLabelsInTargetChart)
     462                point.Label = row.Name;
    459463              point.MarkerStyle = MarkerStyle.Cross;
    460464              point.MarkerBorderWidth = 1;
     
    504508          if (!labelPrinted && row.Points.Count > 0) {
    505509            var point = row.Points.Last();
    506             point.Label = row.Name;
     510            if (showLabelsInTargetChart)
     511              point.Label = row.Name;
    507512            point.MarkerStyle = MarkerStyle.Cross;
    508513            point.MarkerBorderWidth = 1;
     
    514519        if (!labelPrinted) {
    515520          var point = row.Points.Last();
    516           point.Label = row.Name;
     521          if (showLabelsInTargetChart)
     522            point.Label = row.Name;
    517523          point.MarkerStyle = MarkerStyle.Cross;
    518524          point.MarkerBorderWidth = 1;
     
    572578    private void GenerateDefaultTargets() {
    573579      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();
    577581    }
    578582
    579583    private Tuple<bool, double> GetEffortToHitTarget(
    580         IEnumerable<Tuple<double, double>> convergenceGraph,
     584        ObservableList<Tuple<double, double>> convergenceGraph,
    581585        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      }
    591598    }
    592599
    593600    private void UpdateErtTables(List<AlgorithmInstance> algorithmInstances) {
    594601      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();
    597608      var rowCount = 0;
    598609
     
    604615      foreach (var problem in problems) {
    605616        var max = problem.IsMaximization();
    606         matrix[rowCount, 0] = problem.ToString();
     617        rowNames.Add(problem.ToString());
    607618        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        }
    612625        rowCount++;
    613626
    614627        foreach (var alg in algorithmInstances) {
    615           matrix[rowCount, 0] = alg.Name;
     628          rowNames.Add(alg.Name);
    616629          var runs = alg.GetRuns(problem).ToList();
    617630          if (runs.Count == 0) {
     
    623636          for (var i = 0; i < absTargets.Length; i++) {
    624637            result = ExpectedRuntimeHelper.CalculateErt(runs, tableName, absTargets[i], max);
    625             matrix[rowCount, i + 1] = result.ToString();
     638            matrix[rowCount, i] = result.ToString();
    626639          }
    627640          matrix[rowCount, columns - 1] = targets.Length > 0 ? result.SuccessfulRuns + "/" + result.TotalRuns : "-";
     
    629642        }
    630643      }
    631       ertTableView.Content = new StringMatrix(matrix);
     644      matrix.RowNames = rowNames;
     645      ertTableView.Content = matrix;
    632646      ertTableView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
    633647    }
     
    658672            var resultsTable = (IndexedDataTable<double>)run.Results[table];
    659673
    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);
    665675          }
    666676        }
     
    678688
    679689          var total = 0.0;
     690          var count = list.Value.Count;
    680691          foreach (var h in list.Value) {
    681692            total += h.Value;
    682             row.Values.Add(Tuple.Create(h.Key, total));
     693            row.Values.Add(Tuple.Create(h.Key, total / (double)count));
    683694          }
    684695
     
    697708      var min = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Min()).Min();
    698709      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;
    700711      budgets = Enumerable.Range(1, points).Select(x => min + (x / (double)points) * (max - min)).ToArray();
    701712      suppressBudgetsEvents = true;
     
    704715    }
    705716
    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) {
    707718      var max = problem.IsMaximization();
     719      var prevIndex = 0;
    708720      foreach (var b in budgets) {
    709721        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        }
    710727        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;
    758734      }
    759735    }
     
    762738    private void UpdateCaption() {
    763739      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      }
    764752    }
    765753
     
    814802      errorProvider.SetError(targetsTextBox, null);
    815803      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();
    823806      UpdateResultsByTarget();
    824807      SetEnabledStateOfControls();
     
    848831      }
    849832      targetsAreRelative = (string)relativeOrAbsoluteComboBox.SelectedItem == "relative";
    850       SuspendRepaint();
    851       suppressTargetsEvents = true;
     833      SynchronizeTargetTextBox();
     834
    852835      try {
    853         if (targetsAreRelative)
    854           targetsTextBox.Text = string.Join("% ; ", targets.Select(x => x * 100)) + "%";
    855         else targetsTextBox.Text = string.Join(" ; ", targets);
    856 
     836        SuspendRepaint();
    857837        UpdateResultsByTarget();
    858       } finally { suppressTargetsEvents = false; ResumeRepaint(true); }
     838      } finally { ResumeRepaint(true); }
    859839    }
    860840
    861841    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;
    872850      }
    873851      using (var dialog = new DefineArithmeticProgressionDialog(false, min, max, (max - min) / count)) {
    874852        if (dialog.ShowDialog() == DialogResult.OK) {
    875853          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();
    883859            UpdateResultsByTarget();
    884860            SetEnabledStateOfControls();
     
    896872        var resultsTable = (IndexedDataTable<double>)run.Results[table];
    897873        var values = resultsTable.Rows.First().Values;
    898         var i = 0;
    899         var j = 0;
    900874        var pd = new ProblemInstance(run);
     875        pd = problems.Single(x => x.Equals(pd));
    901876        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;
    912890        }
    913891      }
     
    915893
    916894    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;
    917903      SuspendRepaint();
    918904      try {
     
    931917        double b;
    932918        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);
    934920          e.Cancel = true;
    935921          return;
     
    938924      }
    939925      if (budgetList.Count == 0) {
    940         errorProvider.SetError(budgetsTextBox, "Give at least one target value!");
     926        errorProvider.SetError(budgetsTextBox, "Give at least one budget value!");
    941927        e.Cancel = true;
    942928        return;
     
    944930      e.Cancel = false;
    945931      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; }
    947937      UpdateResultsByCost();
    948938      SetEnabledStateOfControls();
    949     }
    950 
    951     private void aggregateBudgetsCheckBox_CheckedChanged(object sender, EventArgs e) {
    952       SuspendRepaint();
    953       try {
    954         UpdateResultsByCost();
    955       } finally { ResumeRepaint(true); }
    956939    }
    957940
     
    966949        min = (decimal)Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item1)).Min();
    967950        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;
    969952      }
    970953      using (var dialog = new DefineArithmeticProgressionDialog(false, min, max, (max - min) / count)) {
     
    973956            budgets = dialog.Values.OrderBy(x => x).Select(x => (double)x).ToArray();
    974957
    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; }
    978962
    979963            UpdateResultsByCost();
     
    986970    private void addBudgetsAsResultButton_Click(object sender, EventArgs e) {
    987971      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();
    1003972
    1004973      foreach (var run in Content) {
     
    1006975        var resultsTable = (IndexedDataTable<double>)run.Results[table];
    1007976        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;
    1023991        }
    1024992      }
     
    10801048        else pd.BestKnownQuality = double.NaN;
    10811049      }
    1082       //problemComboBox.ResetBindings();
    10831050    }
    10841051    #endregion
    10851052
    10861053    private void ConfigureSeries(Series series) {
    1087       series.SmartLabelStyle.Enabled = true;
     1054      series.SmartLabelStyle.Enabled = showLabelsInTargetChart;
    10881055      series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.No;
    10891056      series.SmartLabelStyle.CalloutLineAnchorCapStyle = LineAnchorCapStyle.None;
     
    14181385      }
    14191386    }
     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    }
    14201404  }
    14211405}
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r14600 r15256  
    5252    }
    5353
    54     public ListView ItemsListView {
    55       get { return itemsListView; }
    56     }
     54    private int EmptyImageIndex { get { return 0; } }
     55    private int RunImageIndex { get { return 1; } }
    5756
    5857    public RunCollectionView() {
    5958      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
    6164      itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>();
    6265      runCollectionModifiersListView.Evaluator = EvaluateModifications;
     
    8386    }
    8487    private void DeregisterItemEvents(IRun item) {
    85       item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
    8688      item.ToStringChanged -= new EventHandler(Item_ToStringChanged);
    8789      item.PropertyChanged -= Item_PropertyChanged;
    8890    }
    8991    private void RegisterItemEvents(IRun item) {
    90       item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);
    9192      item.ToStringChanged += new EventHandler(Item_ToStringChanged);
    9293      item.PropertyChanged += Item_PropertyChanged;
     
    116117      itemsListView.Items.Clear();
    117118      itemListViewItemMapping.Clear();
    118       RebuildImageList();
    119119      viewHost.Content = null;
     120
     121      UpdateGroupBoxText();
    120122
    121123      if (Content != null) {
     
    129131          runCollectionModifiersListView.Content = RunCollection.Modifiers;
    130132        }
     133
     134        ListViewItem[] items = new ListViewItem[Content.Count];
     135        int count = 0;
    131136        foreach (IRun item in Content) {
    132137          ListViewItem listViewItem = CreateListViewItem(item);
    133           AddListViewItem(listViewItem);
     138
    134139          if ((selectedName != null) && item.Name.Equals(selectedName))
    135140            listViewItem.Selected = true;
    136         }
     141          items[count] = listViewItem;
     142          count++;
     143        }
     144        itemsListView.Items.AddRange(items);
    137145        AdjustListViewColumnSizes();
    138146      } else {
     
    166174    }
    167175
    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) {
    169179      ListViewItem listViewItem = new ListViewItem();
    170       if (item == null) {
     180      if (run == null) {
    171181        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;
    174194      } 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
    189205      return listViewItem;
    190206    }
    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
    203208    private void RemoveListViewItem(ListViewItem listViewItem) {
    204209      if (listViewItem == null) throw new ArgumentNullException();
     
    213218      listViewItem.Remove();
    214219    }
    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
    223221    private void UpdateListViewItemText(ListViewItem listViewItem) {
    224222      if (listViewItem == null) throw new ArgumentNullException();
     
    239237        return listViewItems == null ? Enumerable.Empty<ListViewItem>() : listViewItems;
    240238      }
     239    }
     240
     241    private void UpdateGroupBoxText() {
     242      if (Content == null || Content.Count == 0) itemsGroupBox.Text = "Runs";
     243      else itemsGroupBox.Text = @"Runs (" + Content.Count + @")";
    241244    }
    242245
     
    393396        RunCollection.UpdateOfRunsInProgress = true;
    394397        RunCollection.Modify();
    395       } finally {
     398      }
     399      finally {
    396400        ReadOnly = false;
    397401        RunCollection.UpdateOfRunsInProgress = false;
     
    406410        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
    407411      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);
    411414        AdjustListViewColumnSizes();
    412415        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
    413416        clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
    414417        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     418        UpdateGroupBoxText();
    415419      }
    416420    }
     
    425429          if (listViewItem != null) RemoveListViewItem(listViewItem);
    426430        }
    427         RebuildImageList();
    428431        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
    429432        clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
    430433        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     434        UpdateGroupBoxText();
    431435      }
    432436    }
     
    441445          if (listViewItem != null) RemoveListViewItem(listViewItem);
    442446        }
    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);
    446449
    447450        AdjustListViewColumnSizes();
     
    449452        clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
    450453        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     454        UpdateGroupBoxText();
    451455      }
    452456    }
     
    456460        suppressUpdates = RunCollection.UpdateOfRunsInProgress;
    457461        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);
    462464          }
    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);
    466469
    467470          AdjustListViewColumnSizes();
     
    469472          clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
    470473          runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     474          UpdateGroupBoxText();
    471475        }
    472476      }
     
    475479
    476480    #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     }
    487481    private void Item_ToStringChanged(object sender, EventArgs e) {
    488482      if (suppressUpdates) return;
     
    528522      }
    529523    }
    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     }
    538524    #endregion
    539525  }
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/Individual.cs

    r14600 r15256  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Core;
    2426
     
    2729    protected IEncoding Encoding { get; private set; }
    2830    protected IScope Scope { get; private set; }
    29 
    3031    public string Name { get { return Encoding.Name; } }
    3132
     
    3536    }
    3637
    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    }
    3846    public abstract TEncoding GetEncoding<TEncoding>() where TEncoding : class, IEncoding;
    3947
    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);
    4252    }
    4353
    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");
    4756      if (!scope.Variables.ContainsKey(name)) throw new ArgumentException(string.Format(" {0} cannot be found in the provided scope.", name));
    4857      var value = scope.Variables[name].Value;
     
    5160    }
    5261
    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");
    5464      if (value == null) throw new ArgumentNullException("value");
     65
    5566      if (!scope.Variables.ContainsKey(name)) scope.Variables.Add(new Variable(name, value));
    5667      else scope.Variables[name].Value = value;
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/MultiEncodingIndividual.cs

    r14600 r15256  
    3232    }
    3333
    34     private readonly IEnumerable<Individual> individuals;
     34    public MultiEncodingIndividual(MultiEncoding encoding, IScope scope)
     35      : base(encoding, scope) { }
    3536
    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);
    3939    }
    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);
    5842    }
    5943
     
    6246      try {
    6347        encoding = (TEncoding)Encoding.Encodings.SingleOrDefault(e => e is TEncoding);
    64       } catch (InvalidOperationException) {
     48      }
     49      catch (InvalidOperationException) {
    6550        throw new InvalidOperationException(string.Format("The individual uses multiple {0} .", typeof(TEncoding).GetPrettyName()));
    6651      }
     
    6853      return encoding;
    6954    }
    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     }
    7555  }
    7656}
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/SingleEncodingIndividual.cs

    r14600 r15256  
    3232    }
    3333
    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);
    4339    }
    4440
     
    4844      return encoding;
    4945    }
    50 
    51     public override Individual CopyToScope(IScope scope) {
    52       SetScopeValue(Name, scope, (IItem)this[Name].Clone());
    53       return new SingleEncodingIndividual(Encoding, scope);
    54     }
    5546  }
    5647
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs

    r14600 r15256  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.Linq;
    2325using HeuristicLab.Common;
     
    5759    public abstract double[] Evaluate(Individual individual, IRandom random);
    5860    public virtual void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) { }
    59 
     61   
    6062    protected override void OnOperatorsChanged() {
    6163      base.OnOperatorsChanged();
     
    7476      if (encoding != null && encoding.Operators.Any(x => x is ISingleObjectiveOperator && !(x is IMultiObjectiveOperator)))
    7577        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      }
    7684    }
    7785
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs

    r14600 r15256  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    8485    }
    8586
     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
    8696    protected override void OnOperatorsChanged() {
    8797      base.OnOperatorsChanged();
     
    100110      if (encoding.Operators.Any(x => x is IMultiObjectiveOperator && !(x is ISingleObjectiveOperator)))
    101111        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      }
    102118    }
    103119
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r14776 r15256  
    201201    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    202202    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
     203    <Compile Include="MultiObjective\DominationCalculator.cs" />
    203204    <Compile Include="Interfaces\IPreexistingSolutionCreator.cs" />
    204205    <Compile Include="Interfaces\ISolutionModel.cs" />
     
    240241    <Compile Include="Interfaces\IDiscreteDoubleMatrixModifier.cs" />
    241242    <Compile Include="Algorithms\HeuristicOptimizationEngineAlgorithm.cs" />
    242     <Compile Include="Interfaces\IGlobalParticleUpdater.cs" />
    243243    <Compile Include="Interfaces\ILocalImprovementOperator.cs" />
    244     <Compile Include="Interfaces\ILocalParticleUpdater.cs" />
    245244    <Compile Include="Algorithms\HeuristicOptimizationAlgorithm.cs" />
    246245    <Compile Include="Interfaces\IMultiNeighborhoodShakingOperator.cs" />
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Interfaces/IParticleCreator.cs

    r14600 r15256  
    2727  /// </summary>
    2828  public interface IParticleCreator : ISolutionCreator {
     29    ILookupParameter<ISolutionCreator> SolutionCreatorParameter { get; }
    2930  }
    3031}
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs

  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Results/ResultCollection.cs

    r12764 r15256  
    7575    }
    7676
     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    }
    7784  }
    7885}
  • branches/PerformanceComparison/HeuristicLab.Problems.Instances.QAPLIB

Note: See TracChangeset for help on using the changeset viewer.