Changeset 17225


Ignore:
Timestamp:
08/29/19 13:53:26 (4 weeks ago)
Author:
mkommend
Message:

#2521: Integrated changes of #2943 into problem refactoring branch.

Location:
branches/2521_ProblemRefactoring
Files:
9 added
56 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/IIndicator.cs

    r16807 r17225  
    3636    /// <param name="problem">The problem on which the front is evaluated (!! The function itself will NOT be evluated only bounds referencePoints & other metadata will be used</param>
    3737    /// <returns>the index of the least contributing point according to any type of quality criteria</returns>
    38     int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem);
     38    int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveProblemDefinition problem);
    3939  }
    4040}
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs

    r16807 r17225  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    3736    protected CrowdingIndicator(StorableConstructorFlag _) : base(_) { }
    3837    protected CrowdingIndicator(CrowdingIndicator original, Cloner cloner) : base(original, cloner) { }
    39     public override IDeepCloneable Clone(Cloner cloner) { return new CrowdingIndicator(this, cloner); }
     38    public override IDeepCloneable Clone(Cloner cloner) {
     39      return new CrowdingIndicator(this, cloner);
     40    }
    4041    public CrowdingIndicator() { }
    4142    #endregion
    4243
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
    44       var bounds = problem.Encoding.Bounds;
     44    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveProblemDefinition problem) {
    4545      var extracted = front.Select(x => x.PenalizedFitness).ToArray();
    4646      if (extracted.Length <= 2) return 0;
    47       var pointsums = new double[extracted.Length];
    48 
    49       for (var dim = 0; dim < problem.Maximization.Length; dim++) {
    50         var arr = extracted.Select(x => x[dim]).ToArray();
    51         Array.Sort(arr);
    52         var fmax = problem.Encoding.Bounds[dim % bounds.Rows, 1];
    53         var fmin = bounds[dim % bounds.Rows, 0];
    54         var pointIdx = 0;
    55         foreach (var point in extracted) {
    56           var pos = Array.BinarySearch(arr, point[dim]);
    57           var d = pos != 0 && pos != arr.Length - 1 ? (arr[pos + 1] - arr[pos - 1]) / (fmax - fmin) : double.PositiveInfinity;
    58           pointsums[pointIdx] += d;
    59           pointIdx++;
    60         }
    61       }
    62       return pointsums.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index;
     47      var pointsums = CrowdingCalculator.CalculateCrowdingDistances(extracted);
     48      return pointsums.Select((value, index) => new {value, index}).OrderBy(x => x.value).First().index;
    6349    }
    6450  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs

    r16807 r17225  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    2625using HeuristicLab.Common;
    2726using HeuristicLab.Core;
    28 using HeuristicLab.Encodings.RealVectorEncoding;
    2927using HeuristicLab.Optimization;
    3028using HeuristicLab.Problems.TestFunctions.MultiObjective;
     29
    3130namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
    32   [Item("HypervolumeIndicator", "Selection of Offspring based on contributing Hypervolume")]
     31  [Item("HypervolumeIndicator", "Selection of offspring based on contributing Hypervolume")]
    3332  [StorableType("ADF439D6-64E4-4C92-A4D3-E8C05B050406")]
    3433  internal class HypervolumeIndicator : Item, IIndicator {
     
    3736    protected HypervolumeIndicator(StorableConstructorFlag _) : base(_) { }
    3837    protected HypervolumeIndicator(HypervolumeIndicator original, Cloner cloner) : base(original, cloner) { }
    39     public override IDeepCloneable Clone(Cloner cloner) { return new HypervolumeIndicator(this, cloner); }
     38    public override IDeepCloneable Clone(Cloner cloner) {
     39      return new HypervolumeIndicator(this, cloner);
     40    }
    4041    public HypervolumeIndicator() { }
    4142    #endregion
    4243
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
     44    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveProblemDefinition problem) {
    4445      var frontCopy = front.Select(x => x.PenalizedFitness).ToList();
    4546      if (frontCopy.Count <= 1) return 0;
    4647      //TODO discuss with bwerth
    47       var p = problem as MultiObjectiveTestFunctionProblem;
    48       var refPoint = BuildReferencePoint(p != null ? frontCopy.Concat(new[] { p.ReferencePoint.CloneAsArray() }) : frontCopy, problem.Maximization);
     48      var tep = problem != null ? frontCopy.Concat(new[] {problem.ReferencePoint}) : frontCopy;
     49      var refPoint = HypervolumeCalculator.CalculateNadirPoint(tep, problem.Maximization);
    4950      var contributions = Enumerable.Range(0, frontCopy.Count).Select(i => Contribution(frontCopy, i, problem.Maximization, refPoint));
    50       return contributions.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index;
     51      return contributions.Select((value, index) => new {value, index}).OrderBy(x => x.value).First().index;
    5152    }
    5253
     
    5556      var point = front[idx];
    5657      front.RemoveAt(idx);
    57       var contribution = -Hypervolume.Calculate(front.ToArray(), refPoint, maximization);
     58      var contribution = -HypervolumeCalculator.CalculateHypervolume(front.ToArray(), refPoint, maximization);
    5859      front.Insert(idx, point);
    5960      return contribution;
    60     }
    61     private static double[] BuildReferencePoint(IEnumerable<double[]> front, IReadOnlyList<bool> maximization) {
    62       var refPoint = new double[maximization.Count];
    63       foreach (var point in front)
    64         for (var i = 0; i < maximization.Count; i++)
    65           refPoint[i] = maximization[i] ? Math.Min(refPoint[i], point[i]) : Math.Max(refPoint[i], point[i]);
    66       return refPoint;
    6761    }
    6862    #endregion
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs

    r16807 r17225  
    3333  [StorableType("FBBD4517-164C-4DEE-B87D-49B99172EDF4")]
    3434  internal class MinimalDistanceIndicator : Item, IIndicator {
    35 
    3635    #region Constructor and Cloning
    3736    [StorableConstructor]
    3837    protected MinimalDistanceIndicator(StorableConstructorFlag _) : base(_) { }
    3938    protected MinimalDistanceIndicator(MinimalDistanceIndicator original, Cloner cloner) : base(original, cloner) { }
    40     public override IDeepCloneable Clone(Cloner cloner) { return new MinimalDistanceIndicator(this, cloner); }
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new MinimalDistanceIndicator(this, cloner);
     41    }
    4142    public MinimalDistanceIndicator() { }
    4243    #endregion
    4344
    44     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
     45    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveProblemDefinition problem) {
    4546      var extracted = front.Select(x => x.PenalizedFitness).ToArray();
    4647      if (extracted.Length <= 2) return 0;
     
    8889      var res = new double[extracted.Count, extracted.Count];
    8990      for (var i = 0; i < extracted.Count; i++)
    90         for (var j = 0; j < i; j++)
    91           res[i, j] = res[j, i] = Dist(extracted[i], extracted[j]);
     91      for (var j = 0; j < i; j++)
     92        res[i, j] = res[j, i] = Dist(extracted[i], extracted[j]);
    9293      return res;
    9394    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs

    r16807 r17225  
    5252    }
    5353
     54    public RealVectorEncoding Encoding {
     55      get { return Problem.Encoding; }
     56    }
     57
    5458    #region Storable fields
    5559    [Storable]
     
    6468    private double stepSizeDampeningFactor; //d
    6569    [Storable]
    66     private double targetSuccessProbability;// p^target_succ
    67     [Storable]
    68     private double evolutionPathLearningRate;//cc
    69     [Storable]
    70     private double covarianceMatrixLearningRate;//ccov
     70    private double targetSuccessProbability; // p^target_succ
     71    [Storable]
     72    private double evolutionPathLearningRate; //cc
     73    [Storable]
     74    private double covarianceMatrixLearningRate; //ccov
    7175    [Storable]
    7276    private double covarianceMatrixUnlearningRate;
    7377    [Storable]
    7478    private double successThreshold; //ptresh
    75 
    7679    #endregion
    7780
     
    162165    }
    163166
    164     public double StepSizeLearningRate { get { return stepSizeLearningRate; } }
    165     public double StepSizeDampeningFactor { get { return stepSizeDampeningFactor; } }
    166     public double TargetSuccessProbability { get { return targetSuccessProbability; } }
    167     public double EvolutionPathLearningRate { get { return evolutionPathLearningRate; } }
    168     public double CovarianceMatrixLearningRate { get { return covarianceMatrixLearningRate; } }
    169     public double CovarianceMatrixUnlearningRate { get { return covarianceMatrixUnlearningRate; } }
    170     public double SuccessThreshold { get { return successThreshold; } }
     167    public double StepSizeLearningRate {
     168      get { return stepSizeLearningRate; }
     169    }
     170    public double StepSizeDampeningFactor {
     171      get { return stepSizeDampeningFactor; }
     172    }
     173    public double TargetSuccessProbability {
     174      get { return targetSuccessProbability; }
     175    }
     176    public double EvolutionPathLearningRate {
     177      get { return evolutionPathLearningRate; }
     178    }
     179    public double CovarianceMatrixLearningRate {
     180      get { return covarianceMatrixLearningRate; }
     181    }
     182    public double CovarianceMatrixUnlearningRate {
     183      get { return covarianceMatrixUnlearningRate; }
     184    }
     185    public double SuccessThreshold {
     186      get { return successThreshold; }
     187    }
    171188    #endregion
    172189
     
    238255      get { return ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value; }
    239256      set { ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value = value; }
    240 
    241257    }
    242258    //Solutions
     
    257273      Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    258274      Parameters.Add(new FixedValueParameter<IntValue>(PopulationSizeName, "λ (lambda) - the size of the offspring population.", new IntValue(20)));
    259       Parameters.Add(new ValueParameter<DoubleArray>(InitialSigmaName, "The initial sigma can be a single value or a value for each dimension. All values need to be > 0.", new DoubleArray(new[] { 0.5 })));
     275      Parameters.Add(new ValueParameter<DoubleArray>(InitialSigmaName, "The initial sigma can be a single value or a value for each dimension. All values need to be > 0.", new DoubleArray(new[] {0.5})));
    260276      Parameters.Add(new FixedValueParameter<IntValue>(MaximumGenerationsName, "The maximum number of generations which should be processed.", new IntValue(1000)));
    261277      Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluatedSolutionsName, "The maximum number of evaluated solutions that should be computed.", new IntValue(int.MaxValue)));
    262       var set = new ItemSet<IIndicator> { new HypervolumeIndicator(), new CrowdingIndicator(), new MinimalDistanceIndicator() };
     278      var set = new ItemSet<IIndicator> {new HypervolumeIndicator(), new CrowdingIndicator(), new MinimalDistanceIndicator()};
    263279      Parameters.Add(new ConstrainedValueParameter<IIndicator>(IndicatorName, "The selection mechanism on non-dominated solutions", set, set.First()));
    264280    }
     
    280296    }
    281297
    282     public override IDeepCloneable Clone(Cloner cloner) { return new MOCMAEvolutionStrategy(this, cloner); }
     298    public override IDeepCloneable Clone(Cloner cloner) {
     299      return new MOCMAEvolutionStrategy(this, cloner);
     300    }
    283301    #endregion
    284302
     
    309327      solutions = new Individual[PopulationSize];
    310328      for (var i = 0; i < PopulationSize; i++) {
    311         var x = new RealVector(Problem.Encoding.Length); // Uniform distibution in all dimensions assumed.
    312         var bounds = Problem.Encoding.Bounds;
    313         for (var j = 0; j < Problem.Encoding.Length; j++) {
     329        var x = new RealVector(Encoding.Length); // Uniform distibution in all dimensions assumed.
     330        var bounds = Encoding.Bounds;
     331        for (var j = 0; j < Encoding.Length; j++) {
    314332          var dim = j % bounds.Rows;
    315333          x[j] = random.NextDouble() * (bounds[dim, 1] - bounds[dim, 0]) + bounds[dim, 0];
     
    322340    private void InitStrategy() {
    323341      const int lambda = 1;
    324       double n = Problem.Encoding.Length;
     342      double n = Encoding.Length;
    325343      targetSuccessProbability = 1.0 / (5.0 + Math.Sqrt(lambda) / 2.0);
    326344      stepSizeDampeningFactor = 1.0 + n / (2.0 * lambda);
     
    355373      Results.Add(new Result(ScatterPlotResultName, "A scatterplot displaying the evaluated solutions and (if available) the analytically optimal front", new ParetoFrontScatterPlot()));
    356374
    357       var problem = Problem as MultiObjectiveTestFunctionProblem;
     375      var problem = Problem;
    358376      if (problem == null) return;
    359       if (problem.BestKnownFront != null) {
    360         ResultsBestKnownHypervolume = Hypervolume.Calculate(problem.BestKnownFront.ToJaggedArray(), problem.TestFunction.ReferencePoint(problem.Objectives), Problem.Maximization);
     377      var bkf = problem.BestKnownFront == null ? null : problem.BestKnownFront.ToArray();
     378      if (bkf != null && problem.ReferencePoint != null) {
     379        ResultsBestKnownHypervolume = HypervolumeCalculator.CalculateHypervolume(bkf, problem.ReferencePoint, Problem.Maximization);
    361380        ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume;
    362381      }
    363       ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), Problem.Objectives, Problem.Encoding.Length);
     382      ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], bkf, Problem.Objectives, Problem.Encoding.Length);
    364383    }
    365384    #endregion
     
    417436    }
    418437    private RealVector ClosestFeasible(RealVector x) {
    419       var bounds = Problem.Encoding.Bounds;
     438      var bounds = Encoding.Bounds;
    420439      var r = new RealVector(x.Length);
    421440      for (var i = 0; i < x.Length; i++) {
     
    426445    }
    427446    private bool IsFeasable(RealVector offspring) {
    428       var bounds = Problem.Encoding.Bounds;
     447      var bounds = Encoding.Bounds;
    429448      for (var i = 0; i < offspring.Length; i++) {
    430449        var dim = i % bounds.Rows;
     
    438457      //perform a nondominated sort to assign the rank to every element
    439458      int[] ranks;
    440       var fronts = DominationCalculator<Individual>.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
     459      var fronts = DominationCalculator.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
    441460
    442461      //deselect the highest rank fronts until we would end up with less or equal mu elements
     
    470489
    471490    private void Analyze() {
    472       ResultsScatterPlot = new ParetoFrontScatterPlot(solutions.Select(x => x.Fitness).ToArray(), solutions.Select(x => x.Mean.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives, ResultsScatterPlot.ProblemSize);
     491      var qualities = solutions.Select(x => x.Fitness).ToArray();
     492
     493      //to do check for side effects
     494      ResultsScatterPlot = new ParetoFrontScatterPlot(qualities, solutions.Select(x => x.Mean.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives, ResultsScatterPlot.ProblemSize);
    473495      ResultsSolutions = solutions.Select(x => x.Mean.ToArray()).ToMatrix();
    474496
    475       var problem = Problem as MultiObjectiveTestFunctionProblem;
     497      var problem = Problem as MultiObjectiveProblem<RealVectorEncoding, RealVector>;
    476498      if (problem == null) return;
    477499
    478       var front = NonDominatedSelect.GetDominatingVectors(solutions.Select(x => x.Fitness), problem.ReferencePoint.CloneAsArray(), Problem.Maximization, true).ToArray();
    479       if (front.Length == 0) return;
    480       var bounds = problem.Bounds.CloneAsMatrix();
    481       ResultsCrowding = Crowding.Calculate(front, bounds);
    482       ResultsSpacing = Spacing.Calculate(front);
    483       ResultsGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistance.Calculate(front, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;
    484       ResultsInvertedGenerationalDistance = problem.BestKnownFront != null ? InvertedGenerationalDistance.Calculate(front, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;
    485       ResultsHypervolume = Hypervolume.Calculate(front, problem.ReferencePoint.CloneAsArray(), Problem.Maximization);
     500
     501      if (qualities.Length == 0) return;
     502      ResultsCrowding = CrowdingCalculator.CalculateCrowding(qualities);
     503      ResultsSpacing = Spacing.Calculate(qualities);
     504
     505
     506      ResultsGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistance.Calculate(qualities, problem.BestKnownFront, 1) : double.NaN;
     507      ResultsInvertedGenerationalDistance = problem.BestKnownFront != null ? InvertedGenerationalDistance.Calculate(qualities, problem.BestKnownFront, 1) : double.NaN;
     508      ResultsHypervolume = problem.ReferencePoint != null ? HypervolumeCalculator.CalculateHypervolume(qualities, problem.ReferencePoint, Problem.Maximization) : double.NaN;
    486509      ResultsBestHypervolume = Math.Max(ResultsHypervolume, ResultsBestHypervolume);
    487510      ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume - ResultsBestHypervolume;
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r16723 r17225  
    150150    <Compile Include="DataVisualization\ScatterPlot.cs" />
    151151    <Compile Include="MultidimensionalScaling\MultidimensionalScaling.cs" />
     152    <Compile Include="MultiObjective\CrowdingAnalyzer.cs" />
     153    <Compile Include="MultiObjective\GenerationalDistanceAnalyzer.cs" />
     154    <Compile Include="MultiObjective\HypervolumeAnalyzer.cs" />
     155    <Compile Include="MultiObjective\InvertedGenerationalDistanceAnalyzer.cs" />
     156    <Compile Include="MultiObjective\MultiObjectiveSuccessAnalyzer.cs" />
    152157    <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" />
    153158    <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" />
     159    <Compile Include="MultiObjective\SpacingAnalyzer.cs" />
     160    <Compile Include="MultiObjective\TimelineAnalyzer.cs" />
    154161    <Compile Include="Plugin.cs" />
    155162    <Compile Include="PopulationSimilarityAnalysis\PopulationDiversityAnalyzer.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/EnumerableExtensions.cs

    r16723 r17225  
    2626namespace HeuristicLab.Common {
    2727  public static class EnumerableExtensions {
     28    public static T[,] ToMatrix<T>(this IEnumerable<IEnumerable<T>> source) {
     29      if (source == null) throw new ArgumentNullException("source");
     30      if (!source.Any()) return new T[0, 0];
     31
     32      int firstDimension = source.Count();
     33      int secondDimension = source.First().Count();
     34      var result = new T[firstDimension, secondDimension];
     35
     36      int i = 0;
     37      int j = 0;
     38      foreach (var row in source) {
     39        j = 0;
     40        foreach (var element in row) {
     41          result[i, j] = element;
     42          j++;
     43        }
     44        if (j != secondDimension) throw new InvalidOperationException("All enumerables must be of the same length.");
     45        i++;
     46      }
     47
     48      return result;
     49    }
     50
     51
    2852    /// <summary>
    2953    /// Selects all elements in the sequence that are maximal with respect to the given value.
  • branches/2521_ProblemRefactoring/HeuristicLab.Data/3.3/Interfaces/IValueTypeArray.cs

    r16723 r17225  
    11#region License Information
    2 
    32/* HeuristicLab
    43 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    1918 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    2019 */
    21 
    2220#endregion
    2321
     
    4745
    4846  [StorableType("f9db5740-1c4f-4f62-a9a8-84b32a461ea8")]
    49   public interface IValueTypeArray<T> : IValueTypeArray, IEnumerable<T> where T : struct {
    50     T this[int index] { get; set; }
     47  public interface IValueTypeArray<out T> : IValueTypeArray, IReadOnlyList<T> where T : struct {
     48    //T this[int index] { get; set; }
    5149  }
    5250}
    53 
    54 
  • branches/2521_ProblemRefactoring/HeuristicLab.Data/3.3/ValueTypeArray.cs

    r16723 r17225  
    7676    }
    7777
     78    public int Count
     79    {
     80      get { return Length; }
     81    }
     82
    7883    [Storable]
    7984    protected bool resizable = true;
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageMultiObjectiveProblem.cs

    r16948 r17225  
    6464      base.Analyze(individuals, qualities, results, random);
    6565
    66       var result = DominationCalculator<LinearLinkage>.CalculateBestParetoFront(individuals, qualities, Maximization);
     66      var result = DominationCalculator.CalculateBestParetoFront(individuals, qualities, Maximization);
    6767      // TODO: Add results
    6868    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdingDistanceAssignment.cs

    r16723 r17225  
    3434  [StorableType("F7DF8B74-F1E6-45D6-A1A8-5D381F20B382")]
    3535  public class CrowdingDistanceAssignment : SingleSuccessorOperator, IMultiObjectiveOperator {
    36 
    3736    public ScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
    3837      get { return (ScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; }
     
    6665
    6766    public static void Apply(DoubleArray[] qualities, DoubleValue[] distances) {
    68       int populationSize = qualities.Length;
    69       int objectiveCount = qualities[0].Length;
    70       for (int m = 0; m < objectiveCount; m++) {
    71         Array.Sort<DoubleArray, DoubleValue>(qualities, distances, new QualitiesComparer(m));
    72 
    73         distances[0].Value = double.MaxValue;
    74         distances[populationSize - 1].Value = double.MaxValue;
    75 
    76         double minQuality = qualities[0][m];
    77         double maxQuality = qualities[populationSize - 1][m];
    78         for (int i = 1; i < populationSize - 1; i++) {
    79           distances[i].Value += (qualities[i + 1][m] - qualities[i - 1][m]) / (maxQuality - minQuality);
    80         }
    81       }
     67      var dist = CrowdingCalculator.CalculateCrowdingDistances(qualities.Select(x => x.ToArray()).ToArray());
     68      for (var i = 0; i < distances.Length; i++) distances[i].Value = dist[i];
    8269    }
    8370
    8471    public override IOperation Apply() {
    85       DoubleArray[] qualities = QualitiesParameter.ActualValue.ToArray();
    86       int populationSize = qualities.Length;
    87       DoubleValue[] distances = new DoubleValue[populationSize];
    88       for (int i = 0; i < populationSize; i++)
    89         distances[i] = new DoubleValue(0);
    90 
    91       CrowdingDistanceParameter.ActualValue = new ItemArray<DoubleValue>(distances);
    92 
    93       Apply(qualities, distances);
    94 
     72      var dist = CrowdingCalculator.CalculateCrowdingDistances(QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray());
     73      CrowdingDistanceParameter.ActualValue = new ItemArray<DoubleValue>(dist.Select(d => new DoubleValue(d)));
    9574      return base.Apply();
    96     }
    97 
    98     private void Initialize(ItemArray<DoubleValue> distances) {
    99       for (int i = 0; i < distances.Length; i++) {
    100         if (distances[i] == null) distances[i] = new DoubleValue(0);
    101         else distances[i].Value = 0;
    102       }
    103     }
    104 
    105     [StorableType("30fd1927-b268-4ce7-8960-b04bfa83f1e6")]
    106     private class QualitiesComparer : IComparer<DoubleArray> {
    107       private int index;
    108 
    109       public QualitiesComparer(int index) {
    110         this.index = index;
    111       }
    112 
    113       #region IComparer<DoubleArray> Members
    114 
    115       public int Compare(DoubleArray x, DoubleArray y) {
    116         if (x[index] < y[index]) return -1;
    117         else if (x[index] > y[index]) return +1;
    118         else return 0;
    119       }
    120 
    121       #endregion
    12275    }
    12376
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization.Operators/3.3/MultiObjective/FastNonDominatedSort.cs

    r16723 r17225  
    7474
    7575      int[] rank;
    76       var fronts = DominationCalculator<IScope>.CalculateAllParetoFronts(scope.SubScopes.ToArray(), qualities, maximization, out rank, dominateOnEqualQualities);
     76      var fronts = DominationCalculator.CalculateAllParetoFronts(scope.SubScopes.ToArray(), qualities, maximization, out rank, dominateOnEqualQualities);
    7777
    7878      RankParameter.ActualValue = new ItemArray<IntValue>(rank.Select(x => new IntValue(x)));
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblem.cs

    r16751 r17225  
    11#region License Information
    2 
    32/* HeuristicLab
    43 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    1918 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    2019 */
    21 
    2220#endregion
    2321
     22using HeuristicLab.Core;
     23using HeuristicLab.Data;
     24
    2425namespace HeuristicLab.Optimization {
    25   public interface IMultiObjectiveProblem<TEncoding, TEncodedSolution> : IProblem<TEncoding, TEncodedSolution>, IMultiObjectiveHeuristicOptimizationProblem
    26     where TEncoding : class, IEncoding<TEncodedSolution>
    27     where TEncodedSolution : class, IEncodedSolution {
     26  public interface IMultiObjectiveProblem : IProblem, IMultiObjectiveHeuristicOptimizationProblem {
    2827
    2928  }
     29
     30  public interface IMultiObjectiveProblem<TEncoding, TEncodedSolution> : IMultiObjectiveProblem, IProblem<TEncoding, TEncodedSolution>
     31    where TEncoding : class, IEncoding<TEncodedSolution>
     32    where TEncodedSolution : class, IEncodedSolution { }
    3033}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs

    r16806 r17225  
    2020#endregion
    2121
     22using System.Collections;
     23using System.Collections.Generic;
    2224using HEAL.Attic;
    2325using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2427
    2528namespace HeuristicLab.Optimization {
     29  public interface IMultiObjectiveProblemDefinition {
     30    int Objectives { get; }
     31    bool[] Maximization { get; }
     32    IReadOnlyList<double[]> BestKnownFront { get; }
     33    double[] ReferencePoint { get; }
     34  }
     35
    2636  [StorableType("39eacdb5-80a0-425d-902a-00eb3e1d6610")]
    27   public interface IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
     37  public interface IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IMultiObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution>
    2838    where TEncoding : class, IEncoding<TEncodedSolution>
    2939    where TEncodedSolution : class, IEncodedSolution {
    30 
    31     int Objectives { get; }
    32     bool[] Maximization { get; }
    3340    double[] Evaluate(TEncodedSolution solution, IRandom random);
    3441    void Analyze(TEncodedSolution[] solutions, double[][] qualities, ResultCollection results, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs

    r16751 r17225  
    11#region License Information
    2 
    32/* HeuristicLab
    43 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    1918 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    2019 */
    21 
    2220#endregion
    2321
    2422
    2523namespace HeuristicLab.Optimization {
    26   public interface ISingleObjectiveProblem<TEncoding, TEncodedSolution> : IProblem<TEncoding, TEncodedSolution>, ISingleObjectiveHeuristicOptimizationProblem
    27     where TEncoding : class, IEncoding<TEncodedSolution>
    28     where TEncodedSolution : class, IEncodedSolution {
     24  public interface ISingleObjectiveProblem : ISingleObjectiveHeuristicOptimizationProblem {
    2925
    3026  }
     27
     28  public interface ISingleObjectiveProblem<TEncoding, TEncodedSolution> : ISingleObjectiveProblem, IProblem<TEncoding, TEncodedSolution>
     29    where TEncoding : class, IEncoding<TEncodedSolution>
     30    where TEncodedSolution : class, IEncodedSolution { }
    3131}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r16751 r17225  
    2525
    2626namespace HeuristicLab.Optimization {
     27  public interface ISingleObjectiveProblemDefinition {
     28    bool Maximization { get; }
     29    bool IsBetter(double quality, double bestQuality);
     30  }
     31
    2732  [StorableType("7ec7bf7e-aaa7-4681-828b-3401cf67e2b3")]
    28   public interface ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition<TEncoding, TEncodedSolution>
     33  public interface ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution> : ISingleObjectiveProblemDefinition, IProblemDefinition<TEncoding, TEncodedSolution>
    2934    where TEncoding : class, IEncoding<TEncodedSolution>
    3035    where TEncodedSolution : class, IEncodedSolution {
    31     bool Maximization { get; }
    3236    double Evaluate(TEncodedSolution solution, IRandom random);
    3337    void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random);
    3438    IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution solution, IRandom random);
    35     bool IsBetter(double quality, double bestQuality);
    3639  }
    3740}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r16806 r17225  
    2020#endregion
    2121
     22using System.Collections;
     23using System.Collections.Generic;
    2224using System.Linq;
    2325using HEAL.Attic;
     
    3537    where TEncoding : class, IEncoding<TEncodedSolution>
    3638    where TEncodedSolution : class, IEncodedSolution {
     39    #region Parameternames
     40    public const string MaximizationParameterName = "Maximization";
     41    public const string BestKnownFrontParameterName = "BestKnownFront";
     42    public const string ReferencePointParameterName = "ReferencePoint";
     43    #endregion
    3744
    38     protected IValueParameter<BoolArray> MaximizationParameter {
    39       get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }
     45    #region Parameterproperties
     46    public IValueParameter<BoolArray> MaximizationParameter {
     47      get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; }
    4048    }
     49    public IValueParameter<DoubleMatrix> BestKnownFrontParameter {
     50      get { return (IValueParameter<DoubleMatrix>)Parameters[BestKnownFrontParameterName]; }
     51    }
     52    public IValueParameter<DoubleArray> ReferencePointParameter {
     53      get { return (IValueParameter<DoubleArray>)Parameters[ReferencePointParameterName]; }
     54    }
     55    #endregion
     56
    4157
    4258    [StorableConstructor]
     
    4965
    5066    protected MultiObjectiveProblem() : base() {
    51       Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
    52 
     67      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
     68      Parameters.Add(new OptionalValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion."));
     69      Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem"));
    5370      Operators.Add(Evaluator);
    5471      Operators.Add(new MultiObjectiveAnalyzer<TEncodedSolution>());
    55 
    5672      ParameterizeOperators();
    5773    }
    5874
    5975    protected MultiObjectiveProblem(TEncoding encoding) : base(encoding) {
    60       Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
    61 
     76      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
     77      Parameters.Add(new OptionalValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion."));
     78      Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem"));
    6279      Operators.Add(Evaluator);
    6380      Operators.Add(new MultiObjectiveAnalyzer<TEncodedSolution>());
    64 
    6581      ParameterizeOperators();
    6682    }
     
    7187    }
    7288
    73     public int Objectives => Maximization.Length;
     89    public int Objectives {
     90      get { return Maximization.Length; }
     91    }
    7492    public abstract bool[] Maximization { get; }
     93
     94    public virtual IReadOnlyList<double[]> BestKnownFront {
     95      get {
     96        if (!Parameters.ContainsKey(BestKnownFrontParameterName)) return null;
     97        var mat = BestKnownFrontParameter.Value;
     98        if (mat == null) return null;
     99        var v = new double[mat.Rows][];
     100        for (var i = 0; i < mat.Rows; i++) {
     101          var r = v[i] = new double[mat.Columns];
     102          for (var j = 0; j < mat.Columns; j++) {
     103            r[j] = mat[i, j];
     104          }
     105        }
     106        return v;
     107      }
     108      set {
     109        if (value == null || value.Count == 0) {
     110          BestKnownFrontParameter.Value = new DoubleMatrix();
     111          return;
     112        }
     113        var mat = new DoubleMatrix(value.Count, value[0].Length);
     114        for (int i = 0; i < value.Count; i++) {
     115          for (int j = 0; j < value[i].Length; j++) {
     116            mat[i, j] = value[i][j];
     117          }
     118        }
     119
     120        BestKnownFrontParameter.Value = mat;
     121      }
     122    }
     123    public virtual double[] ReferencePoint {
     124      get { return ReferencePointParameter.Value != null ? ReferencePointParameter.Value.CloneAsArray() : null; }
     125      set { ReferencePointParameter.Value = new DoubleArray(value); }
     126    }
     127
    75128    public abstract double[] Evaluate(TEncodedSolution solution, IRandom random);
    76129    public virtual void Analyze(TEncodedSolution[] solutions, double[][] qualities, ResultCollection results, IRandom random) { }
     130
    77131
    78132    protected override void OnOperatorsChanged() {
     
    115169    #region IMultiObjectiveHeuristicOptimizationProblem Members
    116170    IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    117       get { return Parameters["Maximization"]; }
     171      get { return Parameters[MaximizationParameterName]; }
    118172    }
    119173    IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCreator.cs

    r16801 r17225  
    3535    }
    3636
    37     public override string OperatorPrefix => "Creator";
     37    public override string OperatorPrefix {
     38      get { return "Creator"; }
     39    }
    3840
    3941    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCrossover.cs

    r16801 r17225  
    3333    }
    3434
    35     public override string OperatorPrefix => "Crossover";
     35    public override string OperatorPrefix {
     36      get { return "Crossover"; }
     37    }
    3638
    3739    [StorableConstructor]
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingManipulator.cs

    r16801 r17225  
    3333    }
    3434
    35     public override string OperatorPrefix => "Manipulator";
     35    public override string OperatorPrefix {
     36      get { return "Manipulator"; }
     37    }
    3638    [StorableConstructor]
    3739    private MultiEncodingManipulator(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r16948 r17225  
    3636    where TEncodedSolution : class, IEncodedSolution
    3737    where TEvaluator : class, IEvaluator {
    38 
    3938    public string Filename { get; set; } // TODO: Really okay here? should be in Problem (non-generic)
    4039
     
    6059    }
    6160    event EventHandler IHeuristicOptimizationProblem.SolutionCreatorChanged {
    62       add { Encoding.SolutionCreatorChanged += value; }
    63       remove { Encoding.SolutionCreatorChanged -= value; }
     61      add {
     62        if (Encoding != null) Encoding.SolutionCreatorChanged += value;
     63      }
     64      remove {
     65        if (Encoding != null) Encoding.SolutionCreatorChanged -= value;
     66      }
    6467    }
    6568
     
    7275      protected set { EvaluatorParameter.Value = value; }
    7376    }
    74     IEvaluator IHeuristicOptimizationProblem.Evaluator { get { return Evaluator; } }
    75     IParameter IHeuristicOptimizationProblem.EvaluatorParameter { get { return EvaluatorParameter; } }
     77    IEvaluator IHeuristicOptimizationProblem.Evaluator {
     78      get { return Evaluator; }
     79    }
     80    IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
     81      get { return EvaluatorParameter; }
     82    }
    7683
    7784    public event EventHandler EvaluatorChanged;
     
    9097      get {
    9198        if (Encoding == null) return base.ExecutionContextItems;
    92         return base.ExecutionContextItems.Concat(new[] { Encoding });
     99        return base.ExecutionContextItems.Concat(new[] {Encoding});
    93100      }
    94101    }
     
    173180        if (!oldMultiEncoding.Encodings.SequenceEqual(newMultiEncoding.Encodings, new TypeEqualityComparer<IEncoding>())) return;
    174181
    175         var nestedEncodings = oldMultiEncoding.Encodings.Zip(newMultiEncoding.Encodings, (o, n) => new { oldEnc = o, newEnc = n });
     182        var nestedEncodings = oldMultiEncoding.Encodings.Zip(newMultiEncoding.Encodings, (o, n) => new {oldEnc = o, newEnc = n});
    176183        foreach (var multi in nestedEncodings)
    177184          AdaptEncodingOperators(multi.oldEnc, multi.newEnc);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r16751 r17225  
    158158    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    159159    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
     160    <Compile Include="MultiObjective\CrowdingCalculator.cs" />
    160161    <Compile Include="MultiObjective\DominationCalculator.cs" />
     162    <Compile Include="MultiObjective\HypervolumeCalculator.cs" />
    161163    <Compile Include="Results\IResultParameter.cs" />
    162164    <Compile Include="Interfaces\ISingleObjectiveOperator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IAnalyzer.cs

    r16723 r17225  
    2525namespace HeuristicLab.Optimization {
    2626  [StorableType("eefee3ee-96ea-41fe-af01-ef96961c99b4")]
    27   /// <summary>
    28   /// An interface which represents an analysis operator.
    29   /// </summary>
    3027  public interface IAnalyzer : IOperator {
    3128    bool EnabledByDefault { get; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r16751 r17225  
    4040  public interface IProblem<TEncoding, TEncodedSolution> : IHeuristicOptimizationProblem
    4141    where TEncoding : class, IEncoding<TEncodedSolution>
    42     where TEncodedSolution : class, IEncodedSolution {
    43   }
     42    where TEncodedSolution : class, IEncodedSolution { }
    4443}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/MultiObjective/DominationCalculator.cs

    r16723 r17225  
    2525
    2626namespace HeuristicLab.Optimization {
     27
    2728  [StorableType("d76eb753-5088-4490-ad18-e78d3629c60b")]
    2829  public enum DominationResult { Dominates, IsDominated, IsNonDominated };
    2930
    30   public static class DominationCalculator<T> {
     31  public static class DominationCalculator {
    3132    /// <summary>
    3233    /// Calculates the best pareto front only. The fast non-dominated sorting algorithm is used
     
    4546    /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param>
    4647    /// <returns>The pareto front containing the best solutions and their associated quality resp. fitness.</returns>
    47     public static List<Tuple<T, double[]>> CalculateBestParetoFront(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities = true) {
    48       int populationSize = solutions.Length;
    49 
     48    public static List<Tuple<T, double[]>> CalculateBestParetoFront<T>(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities = true) {
     49      var populationSize = solutions.Length;
    5050      Dictionary<T, List<int>> dominatedIndividuals;
    5151      int[] dominationCounter, rank;
     
    7171    /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param>
    7272    /// <returns>A sorted list of the pareto fronts from best to worst.</returns>
    73     public static List<List<Tuple<T, double[]>>> CalculateAllParetoFronts(T[] solutions, double[][] qualities, bool[] maximization, out int[] rank, bool dominateOnEqualQualities = true) {
    74       int populationSize = solutions.Length;
     73    public static List<List<Tuple<T, double[]>>> CalculateAllParetoFronts<T>(T[] solutions, double[][] qualities, bool[] maximization, out int[] rank, bool dominateOnEqualQualities = true) {
     74      var populationSize = solutions.Length;
    7575
    7676      Dictionary<T, List<int>> dominatedIndividuals;
     
    7878      var fronts = new List<List<Tuple<T, double[]>>>();
    7979      fronts.Add(CalculateBestFront(solutions, qualities, maximization, dominateOnEqualQualities, populationSize, out dominatedIndividuals, out dominationCounter, out rank));
    80       int i = 0;
     80      var i = 0;
    8181      while (i < fronts.Count && fronts[i].Count > 0) {
    8282        var nextFront = new List<Tuple<T, double[]>>();
     
    8484          List<int> dominatedIndividualsByp;
    8585          if (dominatedIndividuals.TryGetValue(p.Item1, out dominatedIndividualsByp)) {
    86             for (int k = 0; k < dominatedIndividualsByp.Count; k++) {
    87               int dominatedIndividual = dominatedIndividualsByp[k];
     86            for (var k = 0; k < dominatedIndividualsByp.Count; k++) {
     87              var dominatedIndividual = dominatedIndividualsByp[k];
    8888              dominationCounter[dominatedIndividual] -= 1;
    8989              if (dominationCounter[dominatedIndividual] == 0) {
     
    100100    }
    101101
    102     private static List<Tuple<T, double[]>> CalculateBestFront(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities, int populationSize, out Dictionary<T, List<int>> dominatedIndividuals, out int[] dominationCounter, out int[] rank) {
     102    private static List<Tuple<T, double[]>> CalculateBestFront<T>(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities, int populationSize, out Dictionary<T, List<int>> dominatedIndividuals, out int[] dominationCounter, out int[] rank) {
    103103      var front = new List<Tuple<T, double[]>>();
    104104      dominatedIndividuals = new Dictionary<T, List<int>>();
    105105      dominationCounter = new int[populationSize];
    106106      rank = new int[populationSize];
    107       for (int pI = 0; pI < populationSize - 1; pI++) {
     107      for (var pI = 0; pI < populationSize - 1; pI++) {
    108108        var p = solutions[pI];
    109109        List<int> dominatedIndividualsByp;
    110110        if (!dominatedIndividuals.TryGetValue(p, out dominatedIndividualsByp))
    111111          dominatedIndividuals[p] = dominatedIndividualsByp = new List<int>();
    112         for (int qI = pI + 1; qI < populationSize; qI++) {
     112        for (var qI = pI + 1; qI < populationSize; qI++) {
    113113          var test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities);
    114114          if (test == DominationResult.Dominates) {
     
    149149      if (dominateOnEqualQualities) {
    150150        var equal = true;
    151         for (int i = 0; i < left.Length; i++) {
     151        for (var i = 0; i < left.Length; i++) {
    152152          if (left[i] != right[i]) {
    153153            equal = false;
     
    159159
    160160      bool leftIsBetter = false, rightIsBetter = false;
    161       for (int i = 0; i < left.Length; i++) {
     161      for (var i = 0; i < left.Length; i++) {
    162162        if (IsDominated(left[i], right[i], maximizations[i])) rightIsBetter = true;
    163163        else if (IsDominated(right[i], left[i], maximizations[i])) leftIsBetter = true;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r16806 r17225  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Optimization;
    2627
     
    5152    where TEncoding : class, IEncoding<TEncodedSolution>
    5253    where TEncodedSolution : class, IEncodedSolution {
    53 
    5454    protected CompiledSingleObjectiveProblemDefinition() : base() { }
    5555
     
    7272    where TEncoding : class, IEncoding<TEncodedSolution>
    7373    where TEncodedSolution : class, IEncodedSolution {
    74 
    7574    protected CompiledMultiObjectiveProblemDefinition() : base() { }
    7675
     
    7978
    8079    #region ISingleObjectiveProblemDefinition<TEncoding,TEncodedSolution> Members
    81 
    8280    public int Objectives => Maximization.Length;
    8381    public abstract bool[] Maximization { get; }
     82    public abstract IReadOnlyList<double[]> BestKnownFront { get; }
     83    public abstract double[] ReferencePoint { get; }
    8484    public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
    8585    public abstract void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r16806 r17225  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2527using HeuristicLab.Optimization;
    2628
     
    4749    }
    4850
    49     int IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Objectives => CompiledProblemDefinition.Objectives;
     51    public int Objectives => CompiledProblemDefinition.Objectives;
     52    public IReadOnlyList<double[]> BestKnownFront => CompiledProblemDefinition.BestKnownFront;
     53    public double[] ReferencePoint => CompiledProblemDefinition.ReferencePoint;
     54    public bool[] Maximization => CompiledProblemDefinition.Maximization;
    5055
    51     bool[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    52       get { return CompiledProblemDefinition.Maximization; }
    53     }
    5456
    5557    double[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r16815 r17225  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Drawing;
    2324using HEAL.Attic;
     
    5960    }
    6061
     62
    6163    [StorableConstructor]
    6264    protected MultiObjectiveProgrammableProblem(StorableConstructorFlag _) : base(_) { }
     
    6971      : base(encoding) {
    7072      Parameters.Add(new FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>("ProblemScript", "Defines the problem.",
    71         new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() { Name = Name }));
     73        new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() {Name = Name}));
    7274      ProblemScript.Encoding = (TEncoding)encoding.Clone();
    7375
     
    9395    private void OnProblemDefinitionChanged() {
    9496      Parameters.Remove("Maximization");
    95       Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) { Hidden = true });
     97      Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) {Hidden = true});
    9698      Encoding = (TEncoding)ProblemScript.Encoding.Clone();
    9799
     
    108110
    109111    public override bool[] Maximization {
    110       get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.Maximization : new[] { false }; }
     112      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.Maximization : new[] {false}; }
     113    }
     114
     115    public override IReadOnlyList<double[]> BestKnownFront {
     116      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.BestKnownFront : null; }
     117    }
     118
     119    public override double[] ReferencePoint {
     120      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.ReferencePoint : null; }
    111121    }
    112122
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r16751 r17225  
    4848    }
    4949
    50     bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    51       get { return CompiledProblemDefinition.Maximization; }
    52     }
     50    public bool Maximization => CompiledProblemDefinition.Maximization;
    5351
    5452    double ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
     
    6361    }
    6462
    65     bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.IsBetter(double quality, double bestQuality) {
     63    public bool IsBetter(double quality, double bestQuality) {
    6664      return CompiledProblemDefinition.IsBetter(quality, bestQuality);
    6765    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs

    r16812 r17225  
    1717  public class CompiledMultiObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<CombinedEncoding, CombinedSolution> {
    1818    public override bool[] Maximization { get { return new[] { true, false }; } }
     19    public override double[] ReferencePoint { get { return null; } }
     20    public override IReadOnlyList<double[]> BestKnownFront { get { return null; } }
    1921
    2022    public override void Initialize() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveProblem_Template.cs

    r16812 r17225  
    1212  public class CompiledMultiObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> {
    1313    public override bool[] Maximization { get { return new[] { false, false }; } }
     14    public override double[] ReferencePoint { get { return null; } }
     15    public override IReadOnlyList<double[]> BestKnownFront { get { return null; } }
    1416
    1517    public override void Initialize() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/CrowdingAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("F06FB45C-051E-4AD8-BD82-16DA9DCBCACB")]
    32   [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("CrowdingAnalyzer", "This analyzer is functionally equivalent to the CrowdingAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class CrowdingAnalyzer : MOTFAnalyzer {
    34 
    35     public ILookupParameter<DoubleMatrix> BoundsParameter {
    36       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    37     }
    3834
    3935    public IResultParameter<DoubleValue> CrowdingResultParameter {
     
    4339    [StorableConstructor]
    4440    protected CrowdingAnalyzer(StorableConstructorFlag _) : base(_) { }
    45     public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner)
    46       : base(original, cloner) {
    47     }
     41    public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner): base(original, cloner) {}
    4842    public override IDeepCloneable Clone(Cloner cloner) {
    4943      return new CrowdingAnalyzer(this, cloner);
     
    5145
    5246    public CrowdingAnalyzer() {
    53       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds",
    54         "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound."));
    55       Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding value of all points (excluding infinities)"));
     47      Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding distance of all points (excluding infinities)"));
    5648      CrowdingResultParameter.DefaultValue = new DoubleValue(double.NaN);
    57 
    5849    }
    5950
    6051    public override IOperation Apply() {
    6152      var qualities = QualitiesParameter.ActualValue;
    62       var bounds = BoundsParameter.ActualValue;
    63 
    64       var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), bounds.CloneAsMatrix());
     53      var crowdingDistance = CrowdingCalculator.CalculateCrowding(qualities);
    6554      CrowdingResultParameter.ActualValue.Value = crowdingDistance;
    66 
    6755      return base.Apply();
    6856    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("EBC72F16-E329-4D18-800C-8642EFD0F05C")]
    32   [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("GenerationalDistanceAnalyzer", "This analyzer is functionally equivalent to the GenerationalDistanceAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class GenerationalDistanceAnalyzer : MOTFAnalyzer {
    3434
     
    6363    public override IOperation Apply() {
    6464      var qualities = QualitiesParameter.ActualValue;
    65       int objectives = qualities[0].Length;
    66 
    67       var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
     65      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    6866      if (optimalfront == null) return base.Apply();
    6967
    70       var distance = GenerationalDistance.Calculate(qualities.Select(x => x.CloneAsArray()), optimalfront, Dampening);
    71       GenerationalDistanceResultParameter.ActualValue.Value = distance;
    72 
     68      var q = qualities.Select(x => x.ToArray());
     69      GenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistance.Calculate(q, optimalfront, Dampening);
    7370      return base.Apply();
    7471    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs

    r16723 r17225  
    3232namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3333  [StorableType("13D363E4-76FF-4A5A-9B2C-767D9E880E4B")]
    34   [Item("HypervolumeAnalyzer", "Computes the enclosed Hypervolume between the current front and a given reference Point")]
     34  [Item("HypervolumeAnalyzer", "This analyzer is functionally equivalent to the HypervolumeAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3535  public class HypervolumeAnalyzer : MOTFAnalyzer {
    3636
     
    3838      get { return (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    3939    }
     40
    4041    public IResultParameter<DoubleValue> HypervolumeResultParameter {
    4142      get { return (IResultParameter<DoubleValue>)Parameters["Hypervolume"]; }
    4243    }
     44
    4345    public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter {
    4446      get { return (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"]; }
    4547    }
     48
    4649    public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter {
    4750      get { return (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"]; }
     
    5356    }
    5457
    55     protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner)
    56       : base(original, cloner) {
    57     }
     58    protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {}
     59
    5860    public override IDeepCloneable Clone(Cloner cloner) {
    5961      return new HypervolumeAnalyzer(this, cloner);
     
    6870      BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(0);
    6971      HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(0);
    70 
    71 
    7272    }
    7373
     
    7575      var qualities = QualitiesParameter.ActualValue;
    7676      var testFunction = TestFunctionParameter.ActualValue;
    77       int objectives = qualities[0].Length;
     77      var objectives = qualities[0].Length;
    7878      var referencePoint = ReferencePointParameter.ActualValue;
    7979
    80       double best = BestKnownHypervolumeResultParameter.ActualValue.Value;
     80      var best = BestKnownHypervolumeResultParameter.ActualValue.Value;
    8181      if (referencePoint.SequenceEqual(testFunction.ReferencePoint(objectives))) {
    8282        best = Math.Max(best, testFunction.OptimalHypervolume(objectives));
    8383      }
    8484
    85       IEnumerable<double[]> front = NonDominatedSelect.SelectNonDominatedVectors(qualities.Select(q => q.ToArray()), testFunction.Maximization(objectives), true);
    86 
    87       double hv = Hypervolume.Calculate(front, referencePoint.ToArray(), testFunction.Maximization(objectives));
     85      var hv = HypervolumeCalculator.CalculateHypervolume(qualities.Select(x=>x.CloneAsArray()).ToArray(), referencePoint.ToArray(), testFunction.Maximization(objectives));
    8886
    8987      if (hv > best) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("EC99F3C1-D8D2-4738-9523-0D07438647A5")]
    32   [Item("InvertedGenerationalDistanceAnalyzer", "The inverted generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("InvertedGenerationalDistanceAnalyzer", "This analyzer is functionally equivalent to the InvertedGenerationalDistanceAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer {
    34     public override bool EnabledByDefault { get { return false; } }
     34    public override bool EnabledByDefault {
     35      get { return false; }
     36    }
    3537
    3638    private IFixedValueParameter<DoubleValue> DampeningParameter {
     
    5153      Parameters.Add(new ResultParameter<DoubleValue>("Inverted Generational Distance", "The genrational distance between the current front and the optimal front"));
    5254      InvertedGenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
    53 
    5455    }
    5556
     
    6465    public override IOperation Apply() {
    6566      var qualities = QualitiesParameter.ActualValue;
    66       var testFunction = TestFunctionParameter.ActualValue;
    67       int objectives = qualities[0].Length;
    68 
    69       var optimalfront = testFunction.OptimalParetoFront(objectives);
     67      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    7068      if (optimalfront == null) return base.Apply();
    7169
    72       var invertedGenerationalDistance = InvertedGenerationalDistance.Calculate(qualities.Select(q => q.ToArray()), optimalfront, DampeningParameter.Value.Value);
    73       InvertedGenerationalDistanceResultParameter.ActualValue.Value = invertedGenerationalDistance;
    74 
     70      var q = qualities.Select(x => x.ToArray());
     71      InvertedGenerationalDistanceResultParameter.ActualValue.Value = InvertedGenerationalDistance.Calculate(q, optimalfront, Dampening);
    7572      return base.Apply();
    7673    }
    77 
    78 
    7974  }
    8075}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/MOTFAnalyzer.cs

    r16723 r17225  
    3333  [StorableType("CFBB2CAB-C1B7-4F14-9A01-6D5624B7B681")]
    3434  public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    35     public virtual bool EnabledByDefault { get { return true; } }
     35    public virtual bool EnabledByDefault {
     36      get { return true; }
     37    }
    3638
    3739    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r16723 r17225  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
    2627using HeuristicLab.Optimization;
     
    4142    }
    4243
    43 
    4444    [StorableConstructor]
    4545    protected ScatterPlotAnalyzer(StorableConstructorFlag _) : base(_) { }
     
    5252      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem"));
    5353      Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)"));
    54 
    5554    }
    5655
     
    5958      var individuals = IndividualsParameter.ActualValue;
    6059      var testFunction = TestFunctionParameter.ActualValue;
    61       int objectives = qualities[0].Length;
    62       int problemSize = individuals[0].Length;
     60      var objectives = qualities.Length != 0 ? qualities[0].Length:0;   
     61      var problemSize = individuals.Length != 0 ? individuals[0].Length:0;
    6362
    64       double[][] optimalFront = new double[0][];
    65       var front = testFunction.OptimalParetoFront(objectives);
    66       if (front != null) optimalFront = front.ToArray();
     63      var optimalFront = new double[0][];               
     64      if (testFunction != null) {
     65        var front = testFunction.OptimalParetoFront(objectives);
     66        if (front != null) optimalFront = front.ToArray();
     67      }
     68      else {
     69        var mat = BestKnownFrontParameter.ActualValue;
     70        optimalFront = mat == null ? null : Enumerable.Range(0, mat.Rows).Select(r => Enumerable.Range(0, mat.Columns).Select(c => mat[r, c]).ToArray()).ToArray();
     71      }
    6772
    6873      var qualityClones = qualities.Select(s => s.ToArray()).ToArray();
     
    7075
    7176      ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize);
    72 
    7377      return base.Apply();
    7478    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs

    r16723 r17225  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Optimization;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3030  [StorableType("F32027A7-3116-4864-A404-820F866BFD65")]
    31   [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     31  [Item("SpacingAnalyzer", "This analyzer is functionally equivalent to the SpacingAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3232  public class SpacingAnalyzer : MOTFAnalyzer {
    3333
     
    3535      get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }
    3636    }
     37
    3738    [StorableConstructor]
    3839    protected SpacingAnalyzer(StorableConstructorFlag _) : base(_) { }
    39 
    4040
    4141    protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }
     
    5151    public override IOperation Apply() {
    5252      var qualities = QualitiesParameter.ActualValue;
    53       var spacing = Spacing.Calculate(qualities.Select(q => q.ToArray()));
    54       SpacingResultParameter.ActualValue.Value = spacing;
    55 
     53      var q = qualities.Select(x => x.ToArray());
     54      SpacingResultParameter.ActualValue.Value = Spacing.Calculate(q);
    5655      return base.Apply();
    5756    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj

    r16723 r17225  
    174174  </ItemGroup>
    175175  <ItemGroup>
     176    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     177      <Project>{887425b4-4348-49ed-a457-b7d2c26ddbf9}</Project>
     178      <Name>HeuristicLab.Analysis-3.3</Name>
     179      <Private>False</Private>
     180    </ProjectReference>
    176181    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    177182      <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project>
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Interfaces/IMultiObjectiveTestFunction.cs

    r16723 r17225  
    3434    double[,] Bounds(int objectives);
    3535
    36     IEnumerable<double[]> OptimalParetoFront(int objectives);
     36    IList<double[]> OptimalParetoFront(int objectives);
    3737    double OptimalHypervolume(int objectives);
    3838    double[] ReferencePoint(int objectives);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs

    r16950 r17225  
    2323using System.Linq;
    2424using HEAL.Attic;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    3536  [Creatable(CreatableAttribute.Categories.Problems, Priority = 95)]
    3637  [Item("Test Function (multi-objective)", "Test functions with real valued inputs and multiple objectives.")]
    37   public class MultiObjectiveTestFunctionProblem : RealVectorMultiObjectiveProblem,
    38     IProblemInstanceConsumer<MOTFData> {
    39 
     38  public class MultiObjectiveTestFunctionProblem : RealVectorMultiObjectiveProblem, IProblemInstanceConsumer<MOTFData>, IMultiObjectiveProblemDefinition<RealVectorEncoding, RealVector> {
    4039    #region Parameter Properties
    4140    public IFixedValueParameter<IntValue> ProblemSizeParameter {
     
    5150      get { return (IValueParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    5251    }
    53     public IValueParameter<DoubleArray> ReferencePointParameter {
    54       get { return (IValueParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    55     }
    56     public OptionalValueParameter<DoubleMatrix> BestKnownFrontParameter {
    57       get { return (OptionalValueParameter<DoubleMatrix>)Parameters["BestKnownFront"]; }
    58     }
    59 
    6052    #endregion
    6153
     
    8577      set { TestFunctionParameter.Value = value; }
    8678    }
    87     public DoubleArray ReferencePoint {
    88       get { return ReferencePointParameter.Value; }
    89       set { ReferencePointParameter.Value = value; }
    90     }
    91     public DoubleMatrix BestKnownFront {
    92       get { return BestKnownFrontParameter.Value; }
    93       set { BestKnownFrontParameter.Value = value; }
    94     }
    9579    #endregion
    9680
     
    10286    }
    10387
    104     protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner)
    105       : base(original, cloner) {
     88    protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner) : base(original, cloner) {
    10689      RegisterEventHandlers();
    10790    }
     
    11093    }
    11194
    112     public MultiObjectiveTestFunctionProblem()
    113       : base() {
     95    public MultiObjectiveTestFunctionProblem() : base() {
    11496      Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2)));
    11597      Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2)));
    11698      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -4, 4 } })));
    117       Parameters.Add(new ValueParameter<DoubleArray>("ReferencePoint", "The reference point used for hypervolume calculation."));
    11899      Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca()));
    119       Parameters.Add(new OptionalValueParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
    120100
    121101      Encoding.LengthParameter = ProblemSizeParameter;
     
    137117    public override void Analyze(RealVector[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
    138118      base.Analyze(solutions, qualities, results, random);
    139       if (results.ContainsKey("Pareto Front")) {
     119      if (results.ContainsKey("Pareto Front"))
    140120        ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true;
    141       }
    142121    }
    143122
     
    149128    public double[] CheckContraints(RealVector individual) {
    150129      var constrainedTestFunction = (IConstrainedTestFunction)TestFunction;
    151       if (constrainedTestFunction != null) {
    152         return constrainedTestFunction.CheckConstraints(individual, Objectives);
    153       }
    154       return new double[0];
     130      return constrainedTestFunction != null ? constrainedTestFunction.CheckConstraints(individual, Objectives) : new double[0];
    155131    }
    156132
     
    166142    #region Events
    167143    private void UpdateParameterValues() {
    168       MaximizationParameter.Value = (BoolArray)new BoolArray(TestFunction.Maximization(Objectives)).AsReadOnly();
    169 
     144      Parameters.Remove(MaximizationParameterName);
     145      Parameters.Add(new FixedValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(TestFunction.Maximization(Objectives)).AsReadOnly()));
     146
     147      Parameters.Remove(BestKnownFrontParameterName);
    170148      var front = TestFunction.OptimalParetoFront(Objectives);
    171       if (front != null) {
    172         BestKnownFrontParameter.Value = (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly();
    173       } else BestKnownFrontParameter.Value = null;
    174 
     149      var bkf = front != null ? (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly() : null;
     150      Parameters.Add(new FixedValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.", bkf));
     151
     152      Parameters.Remove(ReferencePointParameterName);
     153      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    175154
    176155      BoundsParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));
    177       ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));
    178156    }
    179157
     
    183161      ParameterizeAnalyzers();
    184162    }
     163
    185164    protected override void OnEvaluatorChanged() {
    186165      base.OnEvaluatorChanged();
     
    192171      ProblemSize = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(ProblemSize, TestFunction.MaximumSolutionLength));
    193172      Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives));
    194       ReferencePointParameter.ActualValue = new DoubleArray(TestFunction.ReferencePoint(Objectives));
     173      Parameters.Remove(ReferencePointParameterName);
     174      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    195175      ParameterizeAnalyzers();
    196176      UpdateParameterValues();
     
    207187      UpdateParameterValues();
    208188    }
    209 
    210189    #endregion
    211190
     
    217196      Operators.Add(new HypervolumeAnalyzer());
    218197      Operators.Add(new SpacingAnalyzer());
     198      Operators.Add(new TimelineAnalyzer());
    219199      Operators.Add(new ScatterPlotAnalyzer());
    220 
    221200      ParameterizeAnalyzers();
    222201    }
     
    232211        analyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name;
    233212        analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
    234 
    235         var crowdingAnalyzer = analyzer as CrowdingAnalyzer;
    236         if (crowdingAnalyzer != null) {
    237           crowdingAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
    238         }
    239 
    240213        var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer;
    241         if (scatterPlotAnalyzer != null) {
     214        if (scatterPlotAnalyzer != null)
    242215          scatterPlotAnalyzer.IndividualsParameter.ActualName = Encoding.Name;
    243         }
    244216      }
    245217    }
    246 
    247218    #endregion
    248219  }
    249220}
    250 
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ.cs

    r16723 r17225  
    2828  [StorableType("3ED6C22E-EA6E-4336-BC49-884CE151E514")]
    2929  public abstract class DTLZ : MultiObjectiveTestFunction {
    30     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     30    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3131      if (objectives == 2) return ParetoFrontStore.GetParetoFront("DTLZ.ParetoFronts." + this.ItemName + ".2D");
    3232      return null;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR1.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3031  [StorableType("16DF9415-9D12-4FB9-A985-7EEAE05A24CA")]
    3132  public class IHR1 : IHR {
    32     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     33    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3334      List<double[]> res = new List<double[]>();
    3435      for (int i = 0; i <= 500; i++) {
     
    4142
    4243    protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     44      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4445    }
    4546
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR2.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3031  [StorableType("3E06E73F-61CD-4B99-99A8-84E6E9C0EFC9")]
    3132  public class IHR2 : IHR {
    32     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     33    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3334      List<double[]> res = new List<double[]>();
    3435      for (int i = 0; i <= 500; i++) {
     
    4243
    4344    protected override double GetBestKnownHypervolume(int objectives) {
    44       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     45      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4546    }
    4647
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR3.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3031  [StorableType("316D5351-762D-4883-ACEF-06F4EAFA73AE")]
    3132  public class IHR3 : IHR {
    32     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     33    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3334      List<double[]> res = new List<double[]>();
    3435      for (int i = 0; i <= 500; i++) {
     
    4243
    4344    protected override double GetBestKnownHypervolume(int objectives) {
    44       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     45      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4546    }
    4647
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR4.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3031  [StorableType("E83A9E6E-F7B3-4B27-B5CA-A323D89844F5")]
    3132  public class IHR4 : IHR {
    32     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     33    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3334      List<double[]> res = new List<double[]>();
    3435      for (int i = 0; i <= 500; i++) {
     
    4142
    4243    protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     44      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4445    }
    4546
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR6.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3031  [StorableType("5C0A4163-831B-4507-997F-A70B59E3A445")]
    3132  public class IHR6 : IHR {
    32     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     33    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3334      List<double[]> res = new List<double[]>();
    3435      for (int i = 0; i <= 500; i++) {
     
    4142
    4243    protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     44      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4445    }
    4546
     
    4748    protected IHR6(StorableConstructorFlag _) : base(_) { }
    4849    protected IHR6(IHR6 original, Cloner cloner) : base(original, cloner) { }
    49     public IHR6() : base() {
    50     }
     50    public IHR6() : base() { }
    5151
    5252    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3132  public class CIGTAB : MultiObjectiveTestFunction {
    3233    protected override double[,] GetBounds(int objectives) {
    33       return new double[,] { { -10, 10 } };
     34      return new double[,] {{-10, 10}};
    3435    }
    3536
     
    3940
    4041    protected override double[] GetReferencePoint(int objecitves) {
    41       return new double[] { 11, 11 };
     42      return new double[] {11, 11};
    4243    }
    4344
    44     protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
     45    protected override IList<double[]> GetOptimalParetoFront(int objecitves) {
    4546      List<double[]> res = new List<double[]>();
    4647      for (int i = 0; i <= 500; i++) {
     
    5455
    5556    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     57      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    5758    }
    5859
     
    8990      double f1 = 1 / (a * a * r.Length) * sum;
    9091
    91       return new double[] { f0, f1 };
     92      return new double[] {f0, f1};
    9293    }
    9394  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/ELLI1.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3132  public class ELLI : MultiObjectiveTestFunction {
    3233    protected override double[,] GetBounds(int objectives) {
    33       return new double[,] { { -10, 10 } };
     34      return new double[,] {{-10, 10}};
    3435    }
    3536
     
    3940
    4041    protected override double[] GetReferencePoint(int objecitves) {
    41       return new double[] { 11, 11 };
     42      return new double[] {11, 11};
    4243    }
    4344
    44     protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
     45    protected override IList<double[]> GetOptimalParetoFront(int objecitves) {
    4546      List<double[]> res = new List<double[]>();
    4647      for (int i = 0; i <= 500; i++) {
     
    5455
    5556    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     57      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    5758    }
    5859
     
    8485      double f1 = 1 / (a * a * r.Length) * sum;
    8586
    86       return new double[] { f0, f1 };
     87      return new double[] {f0, f1};
    8788    }
    8889  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs

    r16807 r17225  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.RealVectorEncoding;
     29using HeuristicLab.Optimization;
    2830
    2931namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     
    3234  public class Fonseca : MultiObjectiveTestFunction {
    3335    protected override double[,] GetBounds(int objectives) {
    34       return new double[,] { { -4, 4 } };
     36      return new double[,] {{-4, 4}};
    3537    }
    3638
     
    3941    }
    4042
    41     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    42       return ParetoFrontStore.GetParetoFront("Misc.ParetoFronts." + this.ItemName);
     43    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
     44      return ParetoFrontStore.GetParetoFront("Misc.ParetoFronts." + this.ItemName).ToList();
    4345    }
    4446
    4547    protected override double GetBestKnownHypervolume(int objectives) {
    46       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     48      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4749    }
    4850
    4951    protected override double[] GetReferencePoint(int objectives) {
    50       return new double[] { 11, 11 };
     52      return new double[] {11, 11};
    5153    }
    5254
     
    7981      f1 = 1 - Math.Exp(-f1);
    8082
    81       double[] res = { f0, f1 };
     83      double[] res = {f0, f1};
    8284      return res;
    8385    }
    84 
    8586  }
    8687}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Kursawe.cs

    r16723 r17225  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HEAL.Attic;
    2729
     
    3133  public class Kursawe : MultiObjectiveTestFunction {
    3234    protected override double[,] GetBounds(int objectives) {
    33       return new double[,] { { -5, 5 } };
     35      return new double[,] {{-5, 5}};
    3436    }
    3537
     
    3840    }
    3941
    40     protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
     42    protected override IList<double[]> GetOptimalParetoFront(int objecitves) {
    4143      return ParetoFrontStore.GetParetoFront("Misc.ParetoFronts." + this.ItemName);
    4244    }
    4345
    4446    protected override double GetBestKnownHypervolume(int objectives) {
    45       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     47      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4648    }
    4749
    4850    protected override double[] GetReferencePoint(int objectives) {
    49       return new double[] { 11, 11 };
     51      return new double[] {11, 11};
    5052    }
    5153
     
    5759    }
    5860    public Kursawe() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 3, maximumSolutionLength: int.MaxValue) { }
    59 
    60 
    61 
    6261
    6362
     
    7574      }
    7675
    77       return new double[] { f0, f1 };
     76      return new double[] {f0, f1};
    7877    }
    7978  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN1.cs

    r16723 r17225  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
     26using HeuristicLab.Optimization;
    2627using HEAL.Attic;
    2728
     
    3132  public class SchafferN1 : MultiObjectiveTestFunction {
    3233    protected override double[,] GetBounds(int objectives) {
    33       return new double[,] { { -1e5, 1e5 } };
     34      return new double[,] {{-1e5, 1e5}};
    3435    }
    3536
     
    3940
    4041    protected override double[] GetReferencePoint(int objectives) {
    41       return new double[] { 1e5, 1e5 };
     42      return new double[] {1e5, 1e5};
    4243    }
    4344
    4445
    45     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     46    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    4647      return ParetoFrontStore.GetParetoFront("Misc.ParetoFronts." + "SchafferN1");
    4748    }
    4849
    4950    protected override double GetBestKnownHypervolume(int objectives) {
    50       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     51      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    5152    }
    5253
     
    7273      f1 *= f1;
    7374
    74       return new double[] { f0, f1 };
     75      return new double[] {f0, f1};
    7576    }
    7677  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN2.cs

    r16723 r17225  
    3131  public class SchafferN2 : MultiObjectiveTestFunction {
    3232    protected override double[,] GetBounds(int objectives) {
    33       return new double[,] { { -5, 10 } };
     33      return new double[,] {{-5, 10}};
    3434    }
    3535
     
    3939
    4040    protected override double[] GetReferencePoint(int objecitves) {
    41       return new double[] { 100, 100 };
     41      return new double[] {100, 100};
    4242    }
    4343
    4444
    45     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     45    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    4646      return null;
    4747    }
     
    7272      f1 *= f1;
    7373
    74       return new double[] { f0, f1 };
     74      return new double[] {f0, f1};
    7575    }
    7676  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/MultiObjectiveTestFunction.cs

    r16950 r17225  
    8787    /// retrieves the optimal pareto front (if known from a file)
    8888    /// </summary>
    89     public IEnumerable<double[]> OptimalParetoFront(int objectives) {
     89    public IList<double[]> OptimalParetoFront(int objectives) {
    9090      ThrowIfObjectivesOutOfRange(objectives);
    9191      return GetOptimalParetoFront(objectives);
    9292    }
    93     protected abstract IEnumerable<double[]> GetOptimalParetoFront(int objectives);
     93    protected abstract IList<double[]> GetOptimalParetoFront(int objectives);
    9494
    9595    /// <summary>
     
    132132      Parameters.Add(new FixedValueParameter<IntValue>("Minimum Objectives",
    133133        "The dimensionality of the problem instance (number of variables in the function).",
    134         (IntValue)new IntValue(minimumObjectives).AsReadOnly()) { GetsCollected = false });
    135       Parameters.Add(new FixedValueParameter<IntValue>("Maximum Objectives", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumObjectives).AsReadOnly()) { GetsCollected = false });
    136       Parameters.Add(new FixedValueParameter<IntValue>("Minimum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(minimumSolutionLength).AsReadOnly()) { GetsCollected = false });
    137       Parameters.Add(new FixedValueParameter<IntValue>("Maximum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumSolutionLength).AsReadOnly()) { GetsCollected = false });
     134        (IntValue)new IntValue(minimumObjectives).AsReadOnly()) {GetsCollected = false});
     135      Parameters.Add(new FixedValueParameter<IntValue>("Maximum Objectives", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumObjectives).AsReadOnly()) {GetsCollected = false});
     136      Parameters.Add(new FixedValueParameter<IntValue>("Minimum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(minimumSolutionLength).AsReadOnly()) {GetsCollected = false});
     137      Parameters.Add(new FixedValueParameter<IntValue>("Maximum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumSolutionLength).AsReadOnly()) {GetsCollected = false});
    138138
    139139      MinimumObjectives = minimumObjectives;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ParetoFrontStore.cs

    r16723 r17225  
    2828namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    2929  internal class ParetoFrontStore {
    30     internal static IEnumerable<double[]> GetParetoFront(String filename) {
     30    internal static IList<double[]> GetParetoFront(String filename) {
    3131      List<double[]> data = new List<double[]>();
    3232      var assembly = Assembly.GetExecutingAssembly();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT.cs

    r16723 r17225  
    2828  [StorableType("A8192C08-A1DA-479A-9381-9B634761B521")]
    2929  public abstract class ZDT : MultiObjectiveTestFunction {
    30     protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
     30    protected override IList<double[]> GetOptimalParetoFront(int objectives) {
    3131      return ParetoFrontStore.GetParetoFront("ZDT.ParetoFronts." + this.ItemName);
    3232    }
    3333
    3434    protected override double[,] GetBounds(int objectives) {
    35       return new double[,] { { 0, 1 } };
     35      return new double[,] {{0, 1}};
    3636    }
    3737
     
    4141
    4242    protected override double[] GetReferencePoint(int objecitives) {
    43       return new double[] { 11.0, 11.0 };
     43      return new double[] {11.0, 11.0};
    4444    }
    4545
     
    5151    protected ZDT(StorableConstructorFlag _) : base(_) { }
    5252    protected ZDT(MultiObjectiveTestFunction original, Cloner cloner)
    53       : base(original, cloner) {
    54     }
     53      : base(original, cloner) { }
    5554    protected ZDT() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 1, maximumSolutionLength: int.MaxValue) { }
    5655
Note: See TracChangeset for help on using the changeset viewer.