Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16171


Ignore:
Timestamp:
09/21/18 09:18:49 (6 years ago)
Author:
bwerth
Message:

#2943 worked on MOBasicProblem - added Interfaces;reworked MOCalculators; several minor changes

Location:
branches/2943_MOBasicProblem_MOCMAES
Files:
7 added
56 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/HeuristicLab.Algorithms.MOCMAEvolutionStrategy-3.3.csproj

    r16123 r16171  
    1717    <DebugType>full</DebugType>
    1818    <Optimize>false</Optimize>
    19     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     19    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    2020    <DefineConstants>DEBUG;TRACE</DefineConstants>
    2121    <ErrorReport>prompt</ErrorReport>
     
    8080      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.ALGLIB-3.7.0.dll</HintPath>
    8181    </Reference>
    82     <Reference Include="HeuristicLab.Collections-3.3">
     82    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     83      <SpecificVersion>False</SpecificVersion>
    8384      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
    8485    </Reference>
     
    8889    <Reference Include="HeuristicLab.Core-3.3">
    8990      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
    90     </Reference>
    91     <Reference Include="HeuristicLab.Data-3.3">
    92       <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
    9391    </Reference>
    9492    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
     
    131129      <Name>HeuristicLab.Analysis-3.3</Name>
    132130    </ProjectReference>
     131    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     132      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     133      <Name>HeuristicLab.Data-3.3</Name>
     134    </ProjectReference>
    133135    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    134136      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/IIndicator.cs

    r15583 r16171  
    3434    /// <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>
    3535    /// <returns>the index of the least contributing point according to any type of quality criteria</returns>
    36     int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem);
     36    int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem problem);
    3737  }
    3838}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs

    r15583 r16171  
    2828using HeuristicLab.Optimization;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3031
    3132namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
     
    4142    #endregion
    4243
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
    44       var bounds = problem.Encoding.Bounds;
     44    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem 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       }
     47      var pointsums = CrowdingCalculator.CalculateCrowdingDistances(extracted);
    6248      return pointsums.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index;
    6349    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs

    r15583 r16171  
    3030using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3131namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
    32   [Item("HypervolumeIndicator", "Selection of Offspring based on contributing Hypervolume")]
     32  [Item("HypervolumeIndicator", "Selection of offspring based on contributing Hypervolume")]
    3333  [StorableClass]
    3434  internal class HypervolumeIndicator : Item, IIndicator {
     
    4141    #endregion
    4242
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
     43    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem problem) {
    4444      var frontCopy = front.Select(x => x.PenalizedFitness).ToList();
    4545      if (frontCopy.Count <= 1) return 0;
    4646      var p = problem as MultiObjectiveTestFunctionProblem;
    47       var refPoint = BuildReferencePoint(p != null ? frontCopy.Concat(new[] { p.ReferencePoint.CloneAsArray() }) : frontCopy, problem.Maximization);
     47      var tep = p != null ? frontCopy.Concat(new[] {p.ReferencePoint.CloneAsArray()}) : frontCopy;
     48      var refPoint = HypervolumeCalculator.CalculateNadirPoint(tep, problem.Maximization);
    4849      var contributions = Enumerable.Range(0, frontCopy.Count).Select(i => Contribution(frontCopy, i, problem.Maximization, refPoint));
    4950      return contributions.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index;
     
    5455      var point = front[idx];
    5556      front.RemoveAt(idx);
    56       var contribution = -Hypervolume.Calculate(front.ToArray(), refPoint, maximization);
     57      var contribution = -HypervolumeCalculator.CalculateHypervolume(front.ToArray(), refPoint, maximization);
    5758      front.Insert(idx, point);
    5859      return contribution;
    59     }
    60     private static double[] BuildReferencePoint(IEnumerable<double[]> front, IReadOnlyList<bool> maximization) {
    61       var refPoint = new double[maximization.Count];
    62       foreach (var point in front)
    63         for (var i = 0; i < maximization.Count; i++)
    64           refPoint[i] = maximization[i] ? Math.Min(refPoint[i], point[i]) : Math.Max(refPoint[i], point[i]);
    65       return refPoint;
    6660    }
    6761    #endregion
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs

    r15583 r16171  
    4242    #endregion
    4343
    44     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
     44    public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem problem) {
    4545      var extracted = front.Select(x => x.PenalizedFitness).ToArray();
    4646      if (extracted.Length <= 2) return 0;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs

    r16071 r16171  
    4242  public class MOCMAEvolutionStrategy : BasicAlgorithm {
    4343    public override Type ProblemType {
    44       get { return typeof(MultiObjectiveBasicProblem<RealVectorEncoding>); }
    45     }
    46     public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem {
    47       get { return (MultiObjectiveBasicProblem<RealVectorEncoding>)base.Problem; }
     44      get { return typeof(IMultiObjectiveBasicProblem); }
     45    }
     46    public new IMultiObjectiveBasicProblem Problem {
     47      get { return (IMultiObjectiveBasicProblem)base.Problem; }
    4848      set { base.Problem = value; }
    4949    }
    5050    public override bool SupportsPause {
    5151      get { return true; }
     52    }
     53
     54    private RealVectorEncoding Encoding {
     55      get {
     56        if(Problem == null || !(Problem.Encoding is RealVectorEncoding))
     57          throw new ArgumentException("Multiobjective CMA-ES is only applicable to problems with RealVectorEncodings");
     58        return (RealVectorEncoding)Problem.Encoding;
     59      }
    5260    }
    5361
     
    309317      solutions = new Individual[PopulationSize];
    310318      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++) {
     319        var x = new RealVector(Encoding.Length); // Uniform distibution in all dimensions assumed.
     320        var bounds = Encoding.Bounds;
     321        for (var j = 0; j < Encoding.Length; j++) {
    314322          var dim = j % bounds.Rows;
    315323          x[j] = random.NextDouble() * (bounds[dim, 1] - bounds[dim, 0]) + bounds[dim, 0];
     
    322330    private void InitStrategy() {
    323331      const int lambda = 1;
    324       double n = Problem.Encoding.Length;
     332      double n = Encoding.Length;
    325333      targetSuccessProbability = 1.0 / (5.0 + Math.Sqrt(lambda) / 2.0);
    326334      stepSizeDampeningFactor = 1.0 + n / (2.0 * lambda);
     
    358366      if (problem == null) return;
    359367      if (problem.BestKnownFront != null) {
    360         ResultsBestKnownHypervolume = Hypervolume.Calculate(problem.BestKnownFront.ToJaggedArray(), problem.TestFunction.ReferencePoint(problem.Objectives), Problem.Maximization);
     368        ResultsBestKnownHypervolume = HypervolumeCalculator.CalculateHypervolume(problem.BestKnownFront.ToJaggedArray(), problem.TestFunction.ReferencePoint(problem.Objectives), Problem.Maximization);
    361369        ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume;
    362370      }
     
    417425    }
    418426    private RealVector ClosestFeasible(RealVector x) {
    419       var bounds = Problem.Encoding.Bounds;
     427      var bounds = Encoding.Bounds;
    420428      var r = new RealVector(x.Length);
    421429      for (var i = 0; i < x.Length; i++) {
     
    426434    }
    427435    private bool IsFeasable(RealVector offspring) {
    428       var bounds = Problem.Encoding.Bounds;
     436      var bounds = Encoding.Bounds;
    429437      for (var i = 0; i < offspring.Length; i++) {
    430438        var dim = i % bounds.Rows;
     
    438446      //perform a nondominated sort to assign the rank to every element
    439447      int[] ranks;
    440       var fronts = DominationCalculator<Individual>.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
     448      var fronts = DominationCalculator.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
    441449
    442450      //deselect the highest rank fronts until we would end up with less or equal mu elements
     
    470478
    471479    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);
     480      var qualities = solutions.Select(x => x.Fitness).ToArray();
     481
     482      //to do check for side effects
     483      ResultsScatterPlot = new ParetoFrontScatterPlot(qualities, solutions.Select(x => x.Mean.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives, ResultsScatterPlot.ProblemSize);
    473484      ResultsSolutions = solutions.Select(x => x.Mean.ToArray()).ToMatrix();
    474485
     
    476487      if (problem == null) return;
    477488
    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);
     489     
     490      if (qualities.Length == 0) return;
     491      ResultsCrowding = CrowdingCalculator.CalculateCrowding(qualities);
     492      ResultsSpacing = SpacingCalculator.CalculateSpacing(qualities);
     493      ResultsGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistanceCalculator.CalculateGenerationalDistance(qualities, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;
     494      ResultsInvertedGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistanceCalculator.CalculateInverseGenerationalDistance(qualities, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;
     495      ResultsHypervolume = HypervolumeCalculator.CalculateHypervolume(qualities, problem.ReferencePoint.CloneAsArray(), Problem.Maximization);
    486496      ResultsBestHypervolume = Math.Max(ResultsHypervolume, ResultsBestHypervolume);
    487497      ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume - ResultsBestHypervolume;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r16123 r16171  
    4141    <DebugType>full</DebugType>
    4242    <Optimize>false</Optimize>
    43     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4444    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4545    <ErrorReport>prompt</ErrorReport>
     
    111111      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.ALGLIB-3.7.0.dll</HintPath>
    112112    </Reference>
    113     <Reference Include="HeuristicLab.Collections-3.3">
     113    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     114      <SpecificVersion>False</SpecificVersion>
    114115      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
    115116    </Reference>
     
    123124      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
    124125    </Reference>
    125     <Reference Include="HeuristicLab.Data-3.3">
    126       <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
    127     </Reference>
    128126    <Reference Include="HeuristicLab.Operators-3.3">
    129127      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Operators-3.3.dll</HintPath>
    130     </Reference>
    131     <Reference Include="HeuristicLab.Optimization.Operators-3.3">
    132       <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
    133128    </Reference>
    134129    <Reference Include="HeuristicLab.Parameters-3.3">
     
    235230  </ItemGroup>
    236231  <ItemGroup>
     232    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     233      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     234      <Name>HeuristicLab.Data-3.3</Name>
     235    </ProjectReference>
     236    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     237      <Project>{25087811-f74c-4128-bc86-8324271da13e}</Project>
     238      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
     239    </ProjectReference>
    237240    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    238241      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r15934 r16171  
    4141    <DebugType>full</DebugType>
    4242    <Optimize>false</Optimize>
    43     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4444    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4545    <ErrorReport>prompt</ErrorReport>
     
    108108  </PropertyGroup>
    109109  <ItemGroup>
     110    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     111      <SpecificVersion>False</SpecificVersion>
     112      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     113    </Reference>
     114    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     115      <SpecificVersion>False</SpecificVersion>
     116      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath>
     117    </Reference>
     118    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     119      <SpecificVersion>False</SpecificVersion>
     120      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     121    </Reference>
     122    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     123      <SpecificVersion>False</SpecificVersion>
     124      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
     125    </Reference>
     126    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     127      <SpecificVersion>False</SpecificVersion>
     128      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     129    </Reference>
     130    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     131      <SpecificVersion>False</SpecificVersion>
     132      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     133    </Reference>
    110134    <Reference Include="System" />
    111135    <Reference Include="System.Core">
     
    160184  </ItemGroup>
    161185  <ItemGroup>
    162     <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
    163       <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    164       <Name>HeuristicLab.Common.Resources-3.3</Name>
    165       <Private>False</Private>
    166     </ProjectReference>
    167     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    168       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    169       <Name>HeuristicLab.Common-3.3</Name>
    170       <Private>False</Private>
    171     </ProjectReference>
    172     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    173       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    174       <Name>HeuristicLab.Core-3.3</Name>
    175       <Private>False</Private>
    176     </ProjectReference>
    177     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    178       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    179       <Name>HeuristicLab.Persistence-3.3</Name>
    180       <Private>False</Private>
    181     </ProjectReference>
    182     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    183       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    184       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    185       <Private>False</Private>
    186     </ProjectReference>
    187   </ItemGroup>
    188   <ItemGroup>
    189186    <None Include="HeuristicLab.snk" />
    190187    <None Include="Properties\AssemblyInfo.cs.frame" />
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/Interfaces/IValueTypeArray.cs

    r15583 r16171  
    4444  }
    4545
    46   public interface IValueTypeArray<T> : IValueTypeArray, IEnumerable<T> where T : struct {
    47     T this[int index] { get; set; }
     46  public interface IValueTypeArray<T> : IValueTypeArray, IReadOnlyList<T> where T : struct {
     47    new T this[int index] { get; set; }
    4848  }
    4949}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/ValueTypeArray.cs

    r15583 r16171  
    7676    }
    7777
     78    public int Count
     79    {
     80      get { return Length; }
     81    }
     82
    7883    [Storable]
    7984    protected bool resizable = true;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj

    r13164 r16171  
    4141    <DebugType>full</DebugType>
    4242    <Optimize>false</Optimize>
    43     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4444    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4545    <ErrorReport>prompt</ErrorReport>
     
    106106  </PropertyGroup>
    107107  <ItemGroup>
     108    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     109      <SpecificVersion>False</SpecificVersion>
     110      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     111    </Reference>
     112    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     113      <SpecificVersion>False</SpecificVersion>
     114      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath>
     115    </Reference>
     116    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     117      <SpecificVersion>False</SpecificVersion>
     118      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
     119    </Reference>
     120    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     121      <SpecificVersion>False</SpecificVersion>
     122      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     123    </Reference>
     124    <Reference Include="HeuristicLab.Operators.Programmable-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     125      <SpecificVersion>False</SpecificVersion>
     126      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Operators.Programmable-3.3.dll</HintPath>
     127    </Reference>
     128    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     129      <SpecificVersion>False</SpecificVersion>
     130      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     131    </Reference>
     132    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     133      <SpecificVersion>False</SpecificVersion>
     134      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     135    </Reference>
     136    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     137      <SpecificVersion>False</SpecificVersion>
     138      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     139    </Reference>
     140    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     141      <SpecificVersion>False</SpecificVersion>
     142      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Selection-3.3.dll</HintPath>
     143    </Reference>
    108144    <Reference Include="System" />
    109145    <Reference Include="System.Core">
     
    158194  </ItemGroup>
    159195  <ItemGroup>
    160     <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    161       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    162       <Name>HeuristicLab.Collections-3.3</Name>
    163       <Private>False</Private>
    164     </ProjectReference>
    165     <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    166       <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    167       <Name>HeuristicLab.Common-3.3</Name>
    168       <Private>False</Private>
    169     </ProjectReference>
    170     <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    171       <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
    172       <Name>HeuristicLab.Core-3.3</Name>
    173       <Private>False</Private>
    174     </ProjectReference>
    175     <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
    176       <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    177       <Name>HeuristicLab.Data-3.3</Name>
    178       <Private>False</Private>
    179     </ProjectReference>
    180     <ProjectReference Include="..\..\HeuristicLab.Operators.Programmable\3.3\HeuristicLab.Operators.Programmable-3.3.csproj">
    181       <Project>{6A5F8C2D-B0C3-4B36-BC20-9B1A91EE6DB6}</Project>
    182       <Name>HeuristicLab.Operators.Programmable-3.3</Name>
    183       <Private>False</Private>
    184     </ProjectReference>
    185     <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    186       <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    187       <Name>HeuristicLab.Operators-3.3</Name>
    188       <Private>False</Private>
    189     </ProjectReference>
    190     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    191       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    192       <Name>HeuristicLab.Optimization-3.3</Name>
    193       <Private>False</Private>
    194     </ProjectReference>
    195     <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    196       <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
    197       <Name>HeuristicLab.Parameters-3.3</Name>
    198       <Private>False</Private>
    199     </ProjectReference>
    200     <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    201       <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
    202       <Name>HeuristicLab.Persistence-3.3</Name>
    203       <Private>False</Private>
    204     </ProjectReference>
    205     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    206       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    207       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    208       <Private>False</Private>
    209     </ProjectReference>
    210     <ProjectReference Include="..\..\HeuristicLab.Selection\3.3\HeuristicLab.Selection-3.3.csproj">
    211       <Project>{2C36CD4F-E5F5-43A4-801A-201EA895FE17}</Project>
    212       <Name>HeuristicLab.Selection-3.3</Name>
    213       <Private>False</Private>
    214     </ProjectReference>
    215   </ItemGroup>
    216   <ItemGroup>
    217196    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
    218197      <Visible>False</Visible>
     
    230209      <Install>true</Install>
    231210    </BootstrapperPackage>
     211  </ItemGroup>
     212  <ItemGroup>
     213    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     214      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     215      <Name>HeuristicLab.Data-3.3</Name>
     216    </ProjectReference>
     217    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     218      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
     219      <Name>HeuristicLab.Optimization-3.3</Name>
     220    </ProjectReference>
    232221  </ItemGroup>
    233222  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdingDistanceAssignment.cs

    r15583 r16171  
    6666
    6767    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       }
     68      var dist = CrowdingCalculator.CalculateCrowdingDistances(qualities);
     69      for (var i = 0; i < distances.Length; i++) distances[i].Value = dist[i];
    8270    }
    8371
    8472    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 
     73      var dist = CrowdingCalculator.CalculateCrowdingDistances(QualitiesParameter.ActualValue.ToArray());
     74      CrowdingDistanceParameter.ActualValue = new ItemArray<DoubleValue>(dist.Select(d => new DoubleValue(d)));
    9575      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     private class QualitiesComparer : IComparer<DoubleArray> {
    106       private int index;
    107 
    108       public QualitiesComparer(int index) {
    109         this.index = index;
    110       }
    111 
    112       #region IComparer<DoubleArray> Members
    113 
    114       public int Compare(DoubleArray x, DoubleArray y) {
    115         if (x[index] < y[index]) return -1;
    116         else if (x[index] > y[index]) return +1;
    117         else return 0;
    118       }
    119 
    120       #endregion
    12176    }
    12277
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/MultiObjective/FastNonDominatedSort.cs

    r15583 r16171  
    7575
    7676      int[] rank;
    77       var fronts = DominationCalculator<IScope>.CalculateAllParetoFronts(scope.SubScopes.ToArray(), qualities, maximization, out rank, dominateOnEqualQualities);
     77      var fronts = DominationCalculator.CalculateAllParetoFronts(scope.SubScopes.ToArray(), qualities, maximization, out rank, dominateOnEqualQualities);
    7878
    7979      RankParameter.ActualValue = new ItemArray<IntValue>(rank.Select(x => new IntValue(x)));
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/BasicProblem.cs

    r15583 r16171  
    3030namespace HeuristicLab.Optimization {
    3131  [StorableClass]
    32   public abstract class BasicProblem<TEncoding, TEvaluator> : HeuristicOptimizationProblem<TEvaluator, ISolutionCreator>, IProblemDefinition, IStorableContent
     32  public abstract class BasicProblem<TEncoding, TEvaluator> : HeuristicOptimizationProblem<TEvaluator, ISolutionCreator>, IBasicProblem
    3333    where TEncoding : class, IEncoding
    3434    where TEvaluator : class, IEvaluator {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs

    r15583 r16171  
    3131namespace HeuristicLab.Optimization {
    3232  [StorableClass]
    33   public abstract class MultiObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, MultiObjectiveEvaluator>, IMultiObjectiveHeuristicOptimizationProblem, IMultiObjectiveProblemDefinition
     33  public abstract class MultiObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, MultiObjectiveEvaluator>, IMultiObjectiveBasicProblem
    3434  where TEncoding : class, IEncoding {
     35
     36    #region Parameternames
     37    public const string MaximizationParameterName = "Maximization";
     38    public const string BestKnownFrontParameterName = "BestKnownFront";
     39    public const string ReferencePointParameterName = "ReferencePoint";
     40    #endregion
     41
     42    #region Parameterproperties
     43    public IValueParameter<BoolArray> MaximizationParameter {
     44      get { return (IValueParameter<BoolArray>) Parameters[MaximizationParameterName]; }
     45    }
     46    public IValueParameter<DoubleMatrix> BestKnownFrontParameter {
     47      get { return (IValueParameter<DoubleMatrix>)Parameters[BestKnownFrontParameterName]; }
     48    }
     49    public IValueParameter<DoubleArray> ReferencePointParameter {
     50      get { return (IValueParameter<DoubleArray>)Parameters[ReferencePointParameterName]; }
     51    }
     52    #endregion
     53
     54    #region Properties
     55
     56    public abstract bool[] Maximization { get; }
     57
     58    public DoubleMatrix BestKnownFront {
     59      get { return Parameters.ContainsKey(BestKnownFrontParameterName) ? BestKnownFrontParameter.Value : null; }
     60      set { BestKnownFrontParameter.Value = value; }
     61    }
     62    public DoubleArray ReferencePoint {
     63      get { return Parameters.ContainsKey(ReferencePointParameterName) ? ReferencePointParameter.Value : null; }
     64      set { ReferencePointParameter.Value = value; }
     65    }
     66    #endregion
     67
    3568    [StorableConstructor]
    3669    protected MultiObjectiveBasicProblem(bool deserializing) : base(deserializing) { }
     
    4376    protected MultiObjectiveBasicProblem()
    4477      : base() {
    45       Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
    46 
     78      Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
     79      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."));
     80      Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem"));
    4781      Operators.Add(Evaluator);
    4882      Operators.Add(new MultiObjectiveAnalyzer());
     
    5690    }
    5791
    58     public abstract bool[] Maximization { get; }
     92   
    5993    public abstract double[] Evaluate(Individual individual, IRandom random);
    6094    public virtual void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) { }
     
    96130    }
    97131
    98 
    99132    #region IMultiObjectiveHeuristicOptimizationProblem Members
    100133    IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter {
    101       get { return Parameters["Maximization"]; }
     134      get { return Parameters[MaximizationParameterName]; }
    102135    }
    103136    IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs

    r15583 r16171  
    3131namespace HeuristicLab.Optimization {
    3232  [StorableClass]
    33   public abstract class SingleObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, SingleObjectiveEvaluator>,
    34     ISingleObjectiveProblemDefinition, ISingleObjectiveHeuristicOptimizationProblem
     33  public abstract class SingleObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, SingleObjectiveEvaluator>, ISingleObjectiveBasicProblem
    3534  where TEncoding : class, IEncoding {
    3635
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r16123 r16171  
    4141    <DebugType>full</DebugType>
    4242    <Optimize>false</Optimize>
    43     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     43    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4444    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4545    <ErrorReport>prompt</ErrorReport>
     
    105105  </PropertyGroup>
    106106  <ItemGroup>
     107    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     108      <SpecificVersion>False</SpecificVersion>
     109      <HintPath>..\..\..\..\trunk\bin\ALGLIB-3.7.0.dll</HintPath>
     110    </Reference>
     111    <Reference Include="HeuristicLab.ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     112      <SpecificVersion>False</SpecificVersion>
     113      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.ALGLIB-3.7.0.dll</HintPath>
     114    </Reference>
    107115    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    108116      <SpecificVersion>False</SpecificVersion>
     
    120128      <SpecificVersion>False</SpecificVersion>
    121129      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
    122     </Reference>
    123     <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    124       <SpecificVersion>False</SpecificVersion>
    125       <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
    126130    </Reference>
    127131    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     
    162166    <Compile Include="BasicProblems\Individuals\MultiEncodingIndividual.cs" />
    163167    <Compile Include="BasicProblems\Individuals\SingleEncodingIndividual.cs" />
     168    <Compile Include="BasicProblems\Interfaces\IBasicProblem.cs" />
    164169    <Compile Include="BasicProblems\Interfaces\IEncoding.cs" />
    165170    <Compile Include="BasicProblems\Interfaces\IEncodingOperator.cs" />
    166171    <Compile Include="BasicProblems\Interfaces\IMultiEncodingOperator.cs" />
     172    <Compile Include="BasicProblems\Interfaces\IMultiObjectiveBasicProblem.cs" />
    167173    <Compile Include="BasicProblems\Interfaces\IMultiObjectiveProblemDefinition.cs" />
    168174    <Compile Include="BasicProblems\Interfaces\internal\IMultiObjectiveAnalysisOperator.cs" />
     
    172178    <Compile Include="BasicProblems\Interfaces\internal\ISingleObjectiveEvaluationOperator.cs" />
    173179    <Compile Include="BasicProblems\Interfaces\IProblemDefinition.cs" />
     180    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveBasicProblem.cs" />
    174181    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveMoveOperator.cs" />
    175182    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveProblemDefinition.cs" />
     
    192199    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    193200    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
     201    <Compile Include="MultiObjective\CrowdingCalculator.cs" />
    194202    <Compile Include="MultiObjective\DominationCalculator.cs" />
     203    <Compile Include="MultiObjective\GenerationalDistanceCalculator.cs" />
     204    <Compile Include="MultiObjective\HypervolumeCalculator.cs" />
     205    <Compile Include="MultiObjective\SpacingCalculator.cs" />
    195206    <Compile Include="Results\IResultParameter.cs" />
    196207    <Compile Include="Interfaces\ISingleObjectiveOperator.cs" />
     
    319330    </BootstrapperPackage>
    320331  </ItemGroup>
    321   <ItemGroup />
     332  <ItemGroup>
     333    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     334      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     335      <Name>HeuristicLab.Data-3.3</Name>
     336    </ProjectReference>
     337  </ItemGroup>
    322338  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    323339  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/DominationCalculator.cs

    r15583 r16171  
    2424
    2525namespace HeuristicLab.Optimization {
     26
    2627  public enum DominationResult { Dominates, IsDominated, IsNonDominated };
    2728
    28   public static class DominationCalculator<T> {
     29  public static class DominationCalculator {
    2930    /// <summary>
    3031    /// Calculates the best pareto front only. The fast non-dominated sorting algorithm is used
     
    4344    /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param>
    4445    /// <returns>The pareto front containing the best solutions and their associated quality resp. fitness.</returns>
    45     public static List<Tuple<T, double[]>> CalculateBestParetoFront(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities = true) {
    46       int populationSize = solutions.Length;
     46    public static List<Tuple<T, double[]>> CalculateBestParetoFront<T>(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities = true) {
     47      var populationSize = solutions.Length;
    4748
    4849      Dictionary<T, List<int>> dominatedIndividuals;
     
    6970    /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param>
    7071    /// <returns>A sorted list of the pareto fronts from best to worst.</returns>
    71     public static List<List<Tuple<T, double[]>>> CalculateAllParetoFronts(T[] solutions, double[][] qualities, bool[] maximization, out int[] rank, bool dominateOnEqualQualities = true) {
    72       int populationSize = solutions.Length;
     72    public static List<List<Tuple<T, double[]>>> CalculateAllParetoFronts<T>(T[] solutions, double[][] qualities, bool[] maximization, out int[] rank, bool dominateOnEqualQualities = true) {
     73      var populationSize = solutions.Length;
    7374
    7475      Dictionary<T, List<int>> dominatedIndividuals;
     
    7677      var fronts = new List<List<Tuple<T, double[]>>>();
    7778      fronts.Add(CalculateBestFront(solutions, qualities, maximization, dominateOnEqualQualities, populationSize, out dominatedIndividuals, out dominationCounter, out rank));
    78       int i = 0;
     79      var i = 0;
    7980      while (i < fronts.Count && fronts[i].Count > 0) {
    8081        var nextFront = new List<Tuple<T, double[]>>();
     
    8283          List<int> dominatedIndividualsByp;
    8384          if (dominatedIndividuals.TryGetValue(p.Item1, out dominatedIndividualsByp)) {
    84             for (int k = 0; k < dominatedIndividualsByp.Count; k++) {
    85               int dominatedIndividual = dominatedIndividualsByp[k];
     85            for (var k = 0; k < dominatedIndividualsByp.Count; k++) {
     86              var dominatedIndividual = dominatedIndividualsByp[k];
    8687              dominationCounter[dominatedIndividual] -= 1;
    8788              if (dominationCounter[dominatedIndividual] == 0) {
     
    9899    }
    99100
    100     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) {
     101    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) {
    101102      var front = new List<Tuple<T, double[]>>();
    102103      dominatedIndividuals = new Dictionary<T, List<int>>();
    103104      dominationCounter = new int[populationSize];
    104105      rank = new int[populationSize];
    105       for (int pI = 0; pI < populationSize - 1; pI++) {
     106      for (var pI = 0; pI < populationSize - 1; pI++) {
    106107        var p = solutions[pI];
    107108        List<int> dominatedIndividualsByp;
    108109        if (!dominatedIndividuals.TryGetValue(p, out dominatedIndividualsByp))
    109110          dominatedIndividuals[p] = dominatedIndividualsByp = new List<int>();
    110         for (int qI = pI + 1; qI < populationSize; qI++) {
     111        for (var qI = pI + 1; qI < populationSize; qI++) {
    111112          var test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities);
    112113          if (test == DominationResult.Dominates) {
     
    147148      if (dominateOnEqualQualities) {
    148149        var equal = true;
    149         for (int i = 0; i < left.Length; i++) {
     150        for (var i = 0; i < left.Length; i++) {
    150151          if (left[i] != right[i]) {
    151152            equal = false;
     
    157158
    158159      bool leftIsBetter = false, rightIsBetter = false;
    159       for (int i = 0; i < left.Length; i++) {
     160      for (var i = 0; i < left.Length; i++) {
    160161        if (IsDominated(left[i], right[i], maximizations[i])) rightIsBetter = true;
    161162        else if (IsDominated(right[i], left[i], maximizations[i])) leftIsBetter = true;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/CrowdingAnalyzer.cs

    r15583 r16171  
    3333  public class CrowdingAnalyzer : MOTFAnalyzer {
    3434
    35     public ILookupParameter<DoubleMatrix> BoundsParameter {
    36       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    37     }
    38 
    3935    public IResultParameter<DoubleValue> CrowdingResultParameter {
    4036      get { return (IResultParameter<DoubleValue>)Parameters["Crowding"]; }
     
    5147
    5248    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)"));
     49      Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding distance of all points (excluding infinities)"));
    5650      CrowdingResultParameter.DefaultValue = new DoubleValue(double.NaN);
    57 
    5851    }
    5952
    6053    public override IOperation Apply() {
    6154      var qualities = QualitiesParameter.ActualValue;
    62       var bounds = BoundsParameter.ActualValue;
    63 
    64       var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), bounds.CloneAsMatrix());
     55      var crowdingDistance = CrowdingCalculator.CalculateCrowding(qualities);
    6556      CrowdingResultParameter.ActualValue.Value = crowdingDistance;
    66 
    6757      return base.Apply();
    6858    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs

    r15583 r16171  
    6464    public override IOperation Apply() {
    6565      var qualities = QualitiesParameter.ActualValue;
    66       int objectives = qualities[0].Length;
    67 
    68       var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
     66      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    6967      if (optimalfront == null) return base.Apply();
    70 
    71       var distance = GenerationalDistance.Calculate(qualities.Select(x => x.CloneAsArray()), optimalfront, Dampening);
    72       GenerationalDistanceResultParameter.ActualValue.Value = distance;
    73 
     68      GenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistanceCalculator.CalculateGenerationalDistance(qualities, optimalfront, Dampening);
    7469      return base.Apply();
    7570    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs

    r15583 r16171  
    7676      var qualities = QualitiesParameter.ActualValue;
    7777      var testFunction = TestFunctionParameter.ActualValue;
    78       int objectives = qualities[0].Length;
     78      var objectives = qualities[0].Length;
    7979      var referencePoint = ReferencePointParameter.ActualValue;
    8080
    81       double best = BestKnownHypervolumeResultParameter.ActualValue.Value;
     81      var best = BestKnownHypervolumeResultParameter.ActualValue.Value;
    8282      if (referencePoint.SequenceEqual(testFunction.ReferencePoint(objectives))) {
    8383        best = Math.Max(best, testFunction.OptimalHypervolume(objectives));
    8484      }
    8585
    86       IEnumerable<double[]> front = NonDominatedSelect.SelectNonDominatedVectors(qualities.Select(q => q.ToArray()), testFunction.Maximization(objectives), true);
    87 
    88       double hv = Hypervolume.Calculate(front, referencePoint.ToArray(), testFunction.Maximization(objectives));
     86      var hv = HypervolumeCalculator.CalculateHypervolume(qualities.Select(x=>x.CloneAsArray()).ToArray(), referencePoint.ToArray(), testFunction.Maximization(objectives));
    8987
    9088      if (hv > best) {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs

    r15583 r16171  
    4747    }
    4848
    49     public InvertedGenerationalDistanceAnalyzer() {
    50       Parameters.Add(new FixedValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
    51       Parameters.Add(new ResultParameter<DoubleValue>("Inverted Generational Distance", "The genrational distance between the current front and the optimal front"));
    52       InvertedGenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
    53 
    54     }
    55 
    56 
    5749    [StorableConstructor]
    5850    protected InvertedGenerationalDistanceAnalyzer(bool deserializing) : base(deserializing) { }
     
    6254    }
    6355
     56    public InvertedGenerationalDistanceAnalyzer() {
     57      Parameters.Add(new FixedValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
     58      Parameters.Add(new ResultParameter<DoubleValue>("Inverted Generational Distance", "The genrational distance between the current front and the optimal front"));
     59      InvertedGenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
     60    }
     61
    6462    public override IOperation Apply() {
    6563      var qualities = QualitiesParameter.ActualValue;
    66       var testFunction = TestFunctionParameter.ActualValue;
    67       int objectives = qualities[0].Length;
    68 
    69       var optimalfront = testFunction.OptimalParetoFront(objectives);
     64      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    7065      if (optimalfront == null) return base.Apply();
    71 
    72       var invertedGenerationalDistance = InvertedGenerationalDistance.Calculate(qualities.Select(q => q.ToArray()), optimalfront, DampeningParameter.Value.Value);
    73       InvertedGenerationalDistanceResultParameter.ActualValue.Value = invertedGenerationalDistance;
    74 
     66      InvertedGenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistanceCalculator.CalculateInverseGenerationalDistance(qualities, optimalfront, Dampening);
    7567      return base.Apply();
    7668    }
    77 
    78 
    7969  }
    8070}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r15583 r16171  
    5959      var individuals = IndividualsParameter.ActualValue;
    6060      var testFunction = TestFunctionParameter.ActualValue;
    61       int objectives = qualities[0].Length;
    62       int problemSize = individuals[0].Length;
     61      var objectives = qualities[0].Length;
     62      var problemSize = individuals[0].Length;
    6363
    64       double[][] optimalFront = new double[0][];
     64      var optimalFront = new double[0][];
    6565      var front = testFunction.OptimalParetoFront(objectives);
    6666      if (front != null) optimalFront = front.ToArray();
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs

    r15583 r16171  
    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      SpacingResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities);
    5654      return base.Apply();
    5755    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj

    r16123 r16171  
    1717    <DebugType>full</DebugType>
    1818    <Optimize>false</Optimize>
    19     <OutputPath>..\..\bin\</OutputPath>
     19    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    2020    <DefineConstants>DEBUG;TRACE</DefineConstants>
    2121    <ErrorReport>prompt</ErrorReport>
     
    9090    <Reference Include="HeuristicLab.Core-3.3">
    9191      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
    92     </Reference>
    93     <Reference Include="HeuristicLab.Data-3.3">
    94       <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
    9592    </Reference>
    9693    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
     
    134131    <Compile Include="Interfaces\IConstrainedTestFunction.cs" />
    135132    <Compile Include="Interfaces\IMultiObjectiveTestFunctionAnalyzer.cs" />
    136     <Compile Include="Calculators\Crowding.cs" />
    137     <Compile Include="Calculators\Spacing.cs" />
    138     <Compile Include="Calculators\HyperVolume.cs" />
    139     <Compile Include="Calculators\InvertedGenerationalDistance.cs" />
    140     <Compile Include="Calculators\GenerationalDistance.cs" />
    141133    <Compile Include="ParetoFrontScatterPlot.cs" />
    142134    <Compile Include="Utilities.cs" />
     
    206198      <Name>HeuristicLab.Analysis-3.3</Name>
    207199    </ProjectReference>
     200    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     201      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     202      <Name>HeuristicLab.Data-3.3</Name>
     203    </ProjectReference>
    208204    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    209205      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs

    r15583 r16171  
    3838
    3939    #region Parameter Properties
    40     public IValueParameter<BoolArray> MaximizationParameter {
     40    public new IValueParameter<BoolArray> MaximizationParameter {
    4141      get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }
    4242    }
     
    5353      get { return (IValueParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    5454    }
    55     public IValueParameter<DoubleArray> ReferencePointParameter {
    56       get { return (IValueParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    57     }
    58     public OptionalValueParameter<DoubleMatrix> BestKnownFrontParameter {
    59       get { return (OptionalValueParameter<DoubleMatrix>)Parameters["BestKnownFront"]; }
    60     }
    6155
    6256    #endregion
     
    6458    #region Properties
    6559    public override bool[] Maximization {
    66       get {
    67         if (!Parameters.ContainsKey("Maximization")) return new bool[2];
    68         return MaximizationParameter.Value.ToArray();
    69       }
     60      get{ return Parameters.ContainsKey(MaximizationParameterName) ? MaximizationParameter.Value.CloneAsArray() : new Fonseca().Maximization(2); }
    7061    }
    7162
     
    8576      get { return TestFunctionParameter.Value; }
    8677      set { TestFunctionParameter.Value = value; }
    87     }
    88     public DoubleArray ReferencePoint {
    89       get { return ReferencePointParameter.Value; }
    90       set { ReferencePointParameter.Value = value; }
    91     }
    92     public DoubleMatrix BestKnownFront {
    93       get { return BestKnownFrontParameter.Value; }
    94       set { BestKnownFrontParameter.Value = value; }
    9578    }
    9679    #endregion
     
    11699      Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2)));
    117100      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 } })));
    118       Parameters.Add(new ValueParameter<DoubleArray>("ReferencePoint", "The reference point used for hypervolume calculation."));
    119101      Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca()));
    120       Parameters.Add(new OptionalValueParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
    121102
    122103      Encoding.LengthParameter = ProblemSizeParameter;
     
    138119    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    139120      base.Analyze(individuals, qualities, results, random);
    140       if (results.ContainsKey("Pareto Front")) {
     121      if (results.ContainsKey("Pareto Front"))
    141122        ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true;
    142       }
    143123    }
    144124
     
    170150    #region Events
    171151    private void UpdateParameterValues() {
    172       MaximizationParameter.Value = (BoolArray)new BoolArray(TestFunction.Maximization(Objectives)).AsReadOnly();
    173 
     152      Parameters.Remove(MaximizationParameterName);
     153      Parameters.Add(new FixedValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(TestFunction.Maximization(Objectives)).AsReadOnly()));
     154
     155      Parameters.Remove(BestKnownFrontParameterName);
    174156      var front = TestFunction.OptimalParetoFront(Objectives);
    175       if (front != null) {
    176         BestKnownFrontParameter.Value = (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly();
    177       } else BestKnownFrontParameter.Value = null;
    178 
     157      var bkf = front != null ? (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly() : null;
     158      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));
     159
     160      Parameters.Remove(ReferencePointParameterName);
     161      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    179162
    180163      BoundsParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));
    181       ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));
    182164    }
    183165
     
    196178      ProblemSize = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(ProblemSize, TestFunction.MaximumSolutionLength));
    197179      Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives));
    198       ReferencePointParameter.ActualValue = new DoubleArray(TestFunction.ReferencePoint(Objectives));
     180      Parameters.Remove(ReferencePointParameterName);
     181      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    199182      ParameterizeAnalyzers();
    200183      UpdateParameterValues();
     
    237220        analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
    238221
    239         var crowdingAnalyzer = analyzer as CrowdingAnalyzer;
    240         if (crowdingAnalyzer != null) {
    241           crowdingAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
    242         }
    243 
    244222        var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer;
    245223        if (scatterPlotAnalyzer != null) {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/NonDominatedSelect.cs

    r15583 r16171  
    2525
    2626  public static class NonDominatedSelect {
    27     public enum DominationResult { Dominates, IsDominated, IsNonDominated };
    28 
    29     public static IEnumerable<double[]> SelectNonDominatedVectors(IEnumerable<double[]> qualities, bool[] maximization, bool dominateOnEqualQualities) {
    30 
    31       List<double[]> front = new List<double[]>();
    32       foreach (double[] row in qualities) {
    33         bool insert = true;
    34         for (int i = 0; i < front.Count; i++) {
    35           DominationResult res = Dominates(front[i], row, maximization, dominateOnEqualQualities);
    36           if (res == DominationResult.Dominates) { insert = false; break; }           //Vector domiates Row
    37           else if (res == DominationResult.IsDominated) {   //Row dominates Vector
    38             front.RemoveAt(i);
    39           }
    40         }
    41         if (insert) {
    42           front.Add(row);
    43         }
    44       }
    45 
    46       return front;
    47     }
    48 
    49     public static IEnumerable<double[]> GetDominatingVectors(IEnumerable<double[]> qualities, double[] reference, bool[] maximization, bool dominateOnEqualQualities) {
    50       List<double[]> front = new List<double[]>();
    51       foreach (double[] vec in qualities) {
    52         if (Dominates(vec, reference, maximization, dominateOnEqualQualities) == DominationResult.Dominates) {
    53           front.Add(vec);
    54         }
    55       }
    56       return front;
    57     }
    58 
    59     public static DominationResult Dominates(double[] left, double[] right, bool[] maximizations, bool dominateOnEqualQualities) {
    60       //mkommend Caution: do not use LINQ.SequenceEqual for comparing the two quality arrays (left and right) due to performance reasons
    61       if (dominateOnEqualQualities) {
    62         var equal = true;
    63         for (int i = 0; i < left.Length; i++) {
    64           if (left[i] != right[i]) {
    65             equal = false;
    66             break;
    67           }
    68         }
    69         if (equal) return DominationResult.Dominates;
    70       }
    71 
    72       bool leftIsBetter = false, rightIsBetter = false;
    73       for (int i = 0; i < left.Length; i++) {
    74         if (IsDominated(left[i], right[i], maximizations[i])) rightIsBetter = true;
    75         else if (IsDominated(right[i], left[i], maximizations[i])) leftIsBetter = true;
    76         if (leftIsBetter && rightIsBetter) break;
    77       }
    78 
    79       if (leftIsBetter && !rightIsBetter) return DominationResult.Dominates;
    80       if (!leftIsBetter && rightIsBetter) return DominationResult.IsDominated;
    81       return DominationResult.IsNonDominated;
    82     }
    83 
    84     private static bool IsDominated(double left, double right, bool maximization) {
    85       return maximization && left < right
    86         || !maximization && left > right;
    87     }
    88 
     27   
    8928  }
    9029}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ.cs

    r15583 r16171  
    4242
    4343    protected override double[] GetReferencePoint(int objectives) {
    44       double[] rp = new double[objectives];
    45       for (int i = 0; i < objectives; i++) {
     44      var rp = new double[objectives];
     45      for (var i = 0; i < objectives; i++) {
    4646        rp[i] = 11;
    4747      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ1.cs

    r15583 r16171  
    4848        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4949      }
    50       double[] res = new double[objectives];
    51       int k = r.Length - objectives + 1;
     50      var res = new double[objectives];
     51      var k = r.Length - objectives + 1;
    5252      double g = 0;
    5353
    54       for (int i = r.Length - k; i < r.Length; i++) {
     54      for (var i = r.Length - k; i < r.Length; i++) {
    5555        g += (r[i] - 0.5) * (r[i] - 0.5) - Math.Cos(20.0 * Math.PI * (r[i] - 0.5));
    5656      };
     
    5858      g *= 100;
    5959
    60       for (int i = 0; i < objectives; i++) {
     60      for (var i = 0; i < objectives; i++) {
    6161        res[i] = 0.5 * (1.0 + g);
    62         for (int j = 0; j < objectives - i - 1; ++j)
     62        for (var j = 0; j < objectives - i - 1; ++j)
    6363          res[i] *= (r[j]);
    6464        if (i > 0)
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ2.cs

    r15583 r16171  
    4848      }
    4949
    50       double[] res = new double[objectives];
     50      var res = new double[objectives];
    5151
    5252      //calculate g(Xm)
    5353      double g = 0;
    54       for (int i = objectives; i < r.Length; i++) {
    55         double d = r[i] - 0.5;
     54      for (var i = objectives; i < r.Length; i++) {
     55        var d = r[i] - 0.5;
    5656        g += d * d;
    5757      }
    5858
    5959      //calculating f0...fM-1
    60       for (int i = 0; i < objectives; i++) {
    61         double f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
    62         for (int j = 0; j < objectives - i - 1; j++) {
     60      for (var i = 0; i < objectives; i++) {
     61        var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
     62        for (var j = 0; j < objectives - i - 1; j++) {
    6363          f *= Math.Cos(r[j] * Math.PI / 2);
    6464        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ3.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double sum = 0;
    53       int length = r.Length - objectives + 1;
    54       for (int i = r.Length - length; i < r.Length; i++) {
    55         double d = r[i] - 0.5;
     53      var length = r.Length - objectives + 1;
     54      for (var i = r.Length - length; i < r.Length; i++) {
     55        var d = r[i] - 0.5;
    5656        sum += d * d - Math.Cos(20 * Math.PI * d);
    5757      }
    58       double g = 100 * (length + sum);
     58      var g = 100 * (length + sum);
    5959
    6060      //calculating f0...fM-1
    61       for (int i = 0; i < objectives; i++) {
    62         double f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
    63         for (int j = 0; j < objectives - i - 1; j++) {
     61      for (var i = 0; i < objectives; i++) {
     62        var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
     63        for (var j = 0; j < objectives - i - 1; j++) {
    6464          f *= Math.Cos(r[j] * Math.PI / 2);
    6565        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ4.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double g = 0;
    53       for (int i = objectives; i < r.Length; i++) {
    54         double d = r[i] - 0.5;
     53      for (var i = objectives; i < r.Length; i++) {
     54        var d = r[i] - 0.5;
    5555        g += d * d;
    5656      }
    5757
    5858      //calculating f0...fM-1
    59       for (int i = 0; i < objectives; i++) {
    60         double f = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);
    61         for (int j = 0; j < objectives - i - 1; j++) {
     59      for (var i = 0; i < objectives; i++) {
     60        var f = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);
     61        for (var j = 0; j < objectives - i - 1; j++) {
    6262          f *= Math.Cos(Math.Pow(r[j], 100) * Math.PI / 2);
    6363        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ5.cs

    r15583 r16171  
    4242        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4343      }
    44       double[] res = new double[objectives];
     44      var res = new double[objectives];
    4545
    4646      //calculate g(Xm)
    4747      double g = 0;
    48       for (int i = objectives; i < r.Length; i++) {
    49         double d = r[i] - 0.5;
     48      for (var i = objectives; i < r.Length; i++) {
     49        var d = r[i] - 0.5;
    5050        g += d * d;
    5151      }
     
    5656
    5757      //calculating f0...fM-1
    58       for (int i = 0; i < objectives; i++) {
    59         double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
    60         for (int j = 0; j < objectives - i - 1; j++) {
     58      for (var i = 0; i < objectives; i++) {
     59        var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
     60        for (var j = 0; j < objectives - i - 1; j++) {
    6161          f *= Math.Cos(phi(r[j]) * Math.PI / 2);
    6262        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ6.cs

    r15583 r16171  
    4242        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4343      }
    44       double[] res = new double[objectives];
     44      var res = new double[objectives];
    4545
    4646      //calculate g(Xm)
    4747      double g = 0;
    48       for (int i = objectives; i < r.Length; i++) {
     48      for (var i = objectives; i < r.Length; i++) {
    4949        g += Math.Pow(r[i], 0.1);
    5050      }
     
    5555
    5656      //calculating f0...fM-1
    57       for (int i = 0; i < objectives; i++) {
    58         double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
    59         for (int j = 0; j < objectives - i - 1; j++) {
     57      for (var i = 0; i < objectives; i++) {
     58        var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
     59        for (var j = 0; j < objectives - i - 1; j++) {
    6060          f *= Math.Cos(phi(r[j]) * Math.PI / 2);
    6161        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ7.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double g = 0, length = length = r.Length - objectives + 1;
    53       for (int i = objectives; i < r.Length; i++) {
     53      for (var i = objectives; i < r.Length; i++) {
    5454        g += r[i];
    5555      }
     
    5858
    5959      //calculating f0...fM-2
    60       for (int i = 0; i < objectives - 1; i++) {
     60      for (var i = 0; i < objectives - 1; i++) {
    6161        res[i] = r[i];
    6262      }
    6363      //calculate fM-1
    6464      double h = objectives;
    65       for (int i = 0; i < objectives - 1; i++) {
     65      for (var i = 0; i < objectives - 1; i++) {
    6666        h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i]));
    6767      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ8.cs

    r15583 r16171  
    3030  public class DTLZ8 : DTLZ, IConstrainedTestFunction {
    3131    public static double[] IllegalValue(int size, bool[] maximization) {
    32       double[] res = new double[size];
    33       for (int i = 0; i < size; i++) {
     32      var res = new double[size];
     33      for (var i = 0; i < size; i++) {
    3434        res[i] = maximization[i] ? Double.MinValue : Double.MaxValue;
    3535      }
     
    4949      double n = r.Length;
    5050      double M = objectives;
    51       double ratio = n / M;
    52       double[] res = new double[objectives];
    53       for (int j = 0; j < objectives; j++) {
     51      var ratio = n / M;
     52      var res = new double[objectives];
     53      for (var j = 0; j < objectives; j++) {
    5454        double sum = 0;
    55         for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
     55        for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
    5656          sum += r[i];
    5757        }
     
    5959        res[j] = sum;
    6060      }
    61       for (int j = 0; j < M - 1; j++) {
     61      for (var j = 0; j < M - 1; j++) {
    6262        if (res[objectives - 1] + 4 * res[j] - 1 < 0) return IllegalValue(objectives, GetMaximization(objectives));
    6363      }
    64       double min = Double.PositiveInfinity;
    65       for (int i = 0; i < res.Length - 1; i++) {
    66         for (int j = 0; j < i; j++) {
    67           double d = res[i] + res[j];
     64      var min = Double.PositiveInfinity;
     65      for (var i = 0; i < res.Length - 1; i++) {
     66        for (var j = 0; j < i; j++) {
     67          var d = res[i] + res[j];
    6868          if (min < d) min = d;
    6969        }
     
    7878      double n = r.Length;
    7979      double M = objectives;
    80       double ratio = n / M;
    81       double[] res = new double[objectives];
    82       double[] constraints = new double[objectives];
    83       for (int j = 0; j < objectives; j++) {
     80      var ratio = n / M;
     81      var res = new double[objectives];
     82      var constraints = new double[objectives];
     83      for (var j = 0; j < objectives; j++) {
    8484        double sum = 0;
    85         for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
     85        for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
    8686          sum += r[i];
    8787        }
     
    8989        res[j] = sum;
    9090      }
    91       for (int j = 0; j < M - 1; j++) {
    92         double d1 = res[objectives - 1] + 4 * res[j] - 1;
     91      for (var j = 0; j < M - 1; j++) {
     92        var d1 = res[objectives - 1] + 4 * res[j] - 1;
    9393        constraints[j] = d1 < 0 ? -d1 : 0;
    9494      }
    95       double min = Double.PositiveInfinity;
    96       for (int i = 0; i < res.Length - 1; i++) {
    97         for (int j = 0; j < i; j++) {
    98           double d2 = res[i] + res[j];
     95      var min = Double.PositiveInfinity;
     96      for (var i = 0; i < res.Length - 1; i++) {
     97        for (var j = 0; j < i; j++) {
     98          var d2 = res[i] + res[j];
    9999          if (min < d2) min = d2;
    100100        }
    101101      }
    102       double d = 2 * res[objectives - 1] + min - 1;
     102      var d = 2 * res[objectives - 1] + min - 1;
    103103      constraints[constraints.Length - 1] = d < 0 ? -d : 0;
    104104      return constraints;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR.cs

    r15583 r16171  
    2020#endregion
    2121using System;
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Encodings.RealVectorEncoding;
     25using HeuristicLab.Optimization;
    2426using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2527
     
    3638
    3739    protected override double[] GetReferencePoint(int objectives) {
    38       double[] rp = new double[objectives];
    39       for (int i = 0; i < objectives; i++) {
     40      var rp = new double[objectives];
     41      for (var i = 0; i < objectives; i++) {
    4042        rp[i] = 11;
    4143      }
     
    5860    protected abstract double G(RealVector y);
    5961
     62    protected override double GetBestKnownHypervolume(int objectives) {
     63      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
     64    }
    6065
    6166    protected double H(double x, RealVector r) {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR1.cs

    r15583 r16171  
    3131  public class IHR1 : IHR {
    3232    protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    33       List<double[]> res = new List<double[]>();
    34       for (int i = 0; i <= 500; i++) {
    35         RealVector r = new RealVector(objectives);
     33      var res = new List<double[]>();
     34      for (var i = 0; i <= 500; i++) {
     35        var r = new RealVector(objectives);
    3636        r[0] = 1 / 500.0 * i;
    3737        res.Add(this.Evaluate(r, objectives));
    3838      }
    3939      return res;
    40     }
    41 
    42     protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4440    }
    4541
     
    6460
    6561    protected override double G(RealVector y) {
    66       double sum = 0.0;
    67       for (int i = 1; i < y.Length; i++) {
     62      var sum = 0.0;
     63      for (var i = 1; i < y.Length; i++) {
    6864        sum += HG(y[i]);
    6965      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR2.cs

    r15583 r16171  
    3131  public class IHR2 : IHR {
    3232    protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    33       List<double[]> res = new List<double[]>();
    34       for (int i = 0; i <= 500; i++) {
    35         RealVector r = new RealVector(objectives);
     33      var res = new List<double[]>();
     34      for (var i = 0; i <= 500; i++) {
     35        var r = new RealVector(objectives);
    3636        r[0] = 1 / 500.0 * i;
    3737
     
    3939      }
    4040      return res;
    41     }
    42 
    43     protected override double GetBestKnownHypervolume(int objectives) {
    44       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4541    }
    4642
     
    6662
    6763    protected override double G(RealVector y) {
    68       double sum = 0.0;
    69       for (int i = 1; i < y.Length; i++) {
     64      var sum = 0.0;
     65      for (var i = 1; i < y.Length; i++) {
    7066        sum += HG(y[i]);
    7167      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR3.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3132  public class IHR3 : IHR {
    3233    protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    33       List<double[]> res = new List<double[]>();
    34       for (int i = 0; i <= 500; i++) {
    35         RealVector r = new RealVector(objectives);
     34      var res = new List<double[]>();
     35      for (var i = 0; i <= 500; i++) {
     36        var r = new RealVector(objectives);
    3637        r[0] = 1 / 500.0 * i;
    3738
     
    3940      }
    4041      return res;
    41     }
    42 
    43     protected override double GetBestKnownHypervolume(int objectives) {
    44       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4542    }
    4643
     
    6663
    6764    protected override double G(RealVector y) {
    68       double sum = 0.0;
    69       for (int i = 1; i < y.Length; i++) {
     65      var sum = 0.0;
     66      for (var i = 1; i < y.Length; i++) {
    7067        sum += HG(y[i]);
    7168      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR4.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3132  public class IHR4 : IHR {
    3233    protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    33       List<double[]> res = new List<double[]>();
    34       for (int i = 0; i <= 500; i++) {
    35         RealVector r = new RealVector(objectives);
     34      var res = new List<double[]>();
     35      for (var i = 0; i <= 500; i++) {
     36        var r = new RealVector(objectives);
    3637        r[0] = 1 / 500.0 * i;
    3738        res.Add(this.Evaluate(r, objectives));
    3839      }
    3940      return res;
    40     }
    41 
    42     protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4441    }
    4542
     
    6966
    7067    protected override double G(RealVector y) {
    71       double sum = 0.0;
    72       for (int i = 1; i < y.Length; i++) {
     68      var sum = 0.0;
     69      for (var i = 1; i < y.Length; i++) {
    7370        sum += y[i] * y[i] - 10 * Math.Cos(4 * Math.PI * y[i]);
    7471      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR6.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3132  public class IHR6 : IHR {
    3233    protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) {
    33       List<double[]> res = new List<double[]>();
    34       for (int i = 0; i <= 500; i++) {
    35         RealVector r = new RealVector(objectives);
     34      var res = new List<double[]>();
     35      for (var i = 0; i <= 500; i++) {
     36        var r = new RealVector(objectives);
    3637        r[0] = 1 / 500.0 * i;
    3738        res.Add(this.Evaluate(r, objectives));
    3839      }
    3940      return res;
    40     }
    41 
    42     protected override double GetBestKnownHypervolume(int objectives) {
    43       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
    4441    }
    4542
     
    6562
    6663    protected override double G(RealVector y) {
    67       double sum = 0.0;
    68       for (int i = 1; i < y.Length; i++) {
     64      var sum = 0.0;
     65      for (var i = 1; i < y.Length; i++) {
    6966        sum += HG(y[i]);
    7067      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
    45       List<double[]> res = new List<double[]>();
    46       for (int i = 0; i <= 500; i++) {
    47         RealVector r = new RealVector(2);
     47      var res = new List<double[]>();
     48      for (var i = 0; i <= 500; i++) {
     49        var r = new RealVector(2);
    4850        r[0] = 2 / 500.0 * i;
    4951        r[1] = 2 / 500.0 * i;
     
    5456
    5557    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     58      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5759    }
    5860
     
    6870    public override double[] Evaluate(RealVector r, int objectives) {
    6971      if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives");
    70       double x = r[0];
     72      var x = r[0];
    7173      double a = 1000;
    72       double sum = x * x;
    73       for (int i = 1; i < r.Length - 1; i++) {
     74      var sum = x * x;
     75      for (var i = 1; i < r.Length - 1; i++) {
    7476        sum += a * r[i] * r[i];
    7577      }
     
    7779
    7880      //objective1
    79       double f0 = 1 / (a * a * r.Length) * sum;
     81      var f0 = 1 / (a * a * r.Length) * sum;
    8082
    8183      x = x - 2;
    8284      sum = x * x;
    83       for (int i = 1; i < r.Length - 1; i++) {
     85      for (var i = 1; i < r.Length - 1; i++) {
    8486        sum += a * (r[i] - 2) * (r[i] - 2);
    8587      }
     
    8789      sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2);
    8890      //objective0
    89       double f1 = 1 / (a * a * r.Length) * sum;
     91      var f1 = 1 / (a * a * r.Length) * sum;
    9092
    9193      return new double[] { f0, f1 };
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/ELLI1.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
    45       List<double[]> res = new List<double[]>();
    46       for (int i = 0; i <= 500; i++) {
    47         RealVector r = new RealVector(2);
     47      var res = new List<double[]>();
     48      for (var i = 0; i <= 500; i++) {
     49        var r = new RealVector(2);
    4850        r[0] = 2 / 500.0 * i;
    4951        r[1] = 2 / 500.0 * i;
     
    5456
    5557    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     58      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5759    }
    5860
     
    6971      if (objectives != 2) throw new ArgumentException("The ELLI problem must always have 2 objectives");
    7072      double a = 1000;
    71       double sum = 0.0;
    72       for (int i = 0; i < r.Length; i++) {
     73      var sum = 0.0;
     74      for (var i = 0; i < r.Length; i++) {
    7375        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * r[i] * r[i];
    7476      }
    7577
    7678      //objective1
    77       double f0 = 1 / (a * a * r.Length) * sum;
     79      var f0 = 1 / (a * a * r.Length) * sum;
    7880
    7981      sum = 0.0;
    80       for (int i = 0; i < r.Length; i++) {
     82      for (var i = 0; i < r.Length; i++) {
    8183        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * (r[i] - 2) * (r[i] - 2);
    8284      }
    8385      //objective0
    84       double f1 = 1 / (a * a * r.Length) * sum;
     86      var f1 = 1 / (a * a * r.Length) * sum;
    8587
    8688      return new double[] { f0, f1 };
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs

    r15583 r16171  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Encodings.RealVectorEncoding;
     28using HeuristicLab.Optimization;
    2729using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
     
    4446
    4547    protected override double GetBestKnownHypervolume(int objectives) {
    46       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     48      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    4749    }
    4850
     
    6567
    6668      //objective1
    67       for (int i = 0; i < r.Length; i++) {
    68         double d = r[i] - aux;
     69      for (var i = 0; i < r.Length; i++) {
     70        var d = r[i] - aux;
    6971        f0 += d * d;
    7072      }
     
    7274
    7375      //objective2
    74       double f1 = 0.0;
    75       for (int i = 0; i < r.Length; i++) {
    76         double d = r[i] + aux;
     76      var f1 = 0.0;
     77      for (var i = 0; i < r.Length; i++) {
     78        var d = r[i] + aux;
    7779        f1 += d * d;
    7880      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Kursawe.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override double GetBestKnownHypervolume(int objectives) {
    45       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     47      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    4648    }
    4749
     
    6567      if (objectives != 2) throw new ArgumentException("The Kursawe problem must always have 2 objectives");
    6668      //objective 1
    67       double f0 = 0.0;
    68       for (int i = 0; i < r.Length - 1; i++) {
     69      var f0 = 0.0;
     70      for (var i = 0; i < r.Length - 1; i++) {
    6971        f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1]));
    7072      }
    7173      //objective2
    72       double f1 = 0.0;
    73       for (int i = 0; i < r.Length; i++) {
     74      var f1 = 0.0;
     75      for (var i = 0; i < r.Length; i++) {
    7476        f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3));
    7577      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN1.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4850
    4951    protected override double GetBestKnownHypervolume(int objectives) {
    50       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     52      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5153    }
    5254
     
    6365      if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives");
    6466      if (r.Length != 1) return null;
    65       double x = r[0];
     67      var x = r[0];
    6668
    6769      //objective1
    68       double f0 = x * x;
     70      var f0 = x * x;
    6971
    7072      //objective0
    71       double f1 = x - 2;
     73      var f1 = x - 2;
    7274      f1 *= f1;
    7375
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN2.cs

    r15583 r16171  
    5959    public override double[] Evaluate(RealVector r, int objectives) {
    6060      if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives");
    61       double x = r[0];
     61      var x = r[0];
    6262
    6363      //objective1
     
    6969
    7070      //objective0
    71       double f1 = x - 5;
     71      var f1 = x - 5;
    7272      f1 *= f1;
    7373
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ParetoFrontStore.cs

    r15583 r16171  
    2929  internal class ParetoFrontStore {
    3030    internal static IEnumerable<double[]> GetParetoFront(String filename) {
    31       List<double[]> data = new List<double[]>();
     31      var data = new List<double[]>();
    3232      var assembly = Assembly.GetExecutingAssembly();
    33       String ressourcename = typeof(ParetoFrontStore).Namespace + ".TestFunctions." + filename + ".pf";
     33      var ressourcename = typeof(ParetoFrontStore).Namespace + ".TestFunctions." + filename + ".pf";
    3434
    3535      //check if file is listed
     
    4242      while ((s = ressourceReader.ReadLine()) != null) {
    4343        var tokens = s.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
    44         double[] point = new double[tokens.Length];
    45         for (int i = 0; i < point.Length; i++) {
     44        var point = new double[tokens.Length];
     45        for (var i = 0; i < point.Length; i++) {
    4646          point[i] = Double.Parse(tokens[i], CultureInfo.InvariantCulture);
    4747        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT1.cs

    r15583 r16171  
    4444    public override double[] Evaluate(RealVector r) {
    4545      double g = 0;
    46       for (int i = 1; i < r.Length; i++) g += r[i];
     46      for (var i = 1; i < r.Length; i++) g += r[i];
    4747      g = 1.0 + 9.0 * g / (r.Length - 1);
    48       double f0 = r[0];
    49       double f1 = g * (1.0 - Math.Sqrt(r[0] / g));
     48      var f0 = r[0];
     49      var f1 = g * (1.0 - Math.Sqrt(r[0] / g));
    5050      return new double[] { f0, f1 };
    5151    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT2.cs

    r15583 r16171  
    4242    public override double[] Evaluate(RealVector r) {
    4343      double g = 0;
    44       for (int i = 1; i < r.Length; i++) g += r[i];
     44      for (var i = 1; i < r.Length; i++) g += r[i];
    4545      g = 1.0 + 9.0 * g / (r.Length - 1);
    46       double d = r[0] / g;
    47       double f0 = r[0];
    48       double f1 = g * (1.0 - d * d);
     46      var d = r[0] / g;
     47      var f0 = r[0];
     48      var f1 = g * (1.0 - d * d);
    4949      return new double[] { f0, f1 };
    5050    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT3.cs

    r15583 r16171  
    4444    public override double[] Evaluate(RealVector r) {
    4545      double g = 0;
    46       for (int i = 1; i < r.Length; i++) g += r[i];
     46      for (var i = 1; i < r.Length; i++) g += r[i];
    4747      g = 1.0 + 9.0 * g / (r.Length - 1);
    48       double d = r[0] / g;
    49       double f0 = r[0];
    50       double f1 = g * (1.0 - Math.Sqrt(d) - d * Math.Sin(10 * Math.PI * r[0]));
     48      var d = r[0] / g;
     49      var f0 = r[0];
     50      var f1 = g * (1.0 - Math.Sqrt(d) - d * Math.Sin(10 * Math.PI * r[0]));
    5151      return new double[] { f0, f1 };
    5252    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT4.cs

    r15583 r16171  
    3030  public class ZDT4 : ZDT {
    3131    protected override double[,] GetBounds(int objectives) {
    32       double[,] bounds = new double[objectives, 2];
     32      var bounds = new double[objectives, 2];
    3333      bounds[0, 0] = 0; bounds[0, 1] = 1;
    34       for (int i = 1; i < objectives; i++) {
     34      for (var i = 1; i < objectives; i++) {
    3535        bounds[i, 0] = -5;
    3636        bounds[i, 1] = 5;
     
    5353    public override double[] Evaluate(RealVector r) {
    5454      double g = 0;
    55       for (int i = 1; i < r.Length; i++) {
    56         double v = r[i];
     55      for (var i = 1; i < r.Length; i++) {
     56        var v = r[i];
    5757        g += v * v - 10 * Math.Cos(4 * Math.PI * v);
    5858      }
    5959      g = 1.0 + 10.0 * (r.Length - 1) + g;
    60       double d = r[0] / g;
    61       double f0 = r[0];
    62       double f1 = 1 - Math.Sqrt(d);
     60      var d = r[0] / g;
     61      var f0 = r[0];
     62      var f1 = 1 - Math.Sqrt(d);
    6363      return new double[] { f0, f1 };
    6464    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT6.cs

    r15583 r16171  
    4343    public override double[] Evaluate(RealVector r) {
    4444      double g = 0;
    45       for (int i = 1; i < r.Length; i++) g += r[i];
     45      for (var i = 1; i < r.Length; i++) g += r[i];
    4646      g = 1.0 + 9.0 * Math.Pow(g / (r.Length - 1), 0.25);
    47       double f1 = 1 - Math.Exp(-4 * r[0]) * Math.Pow(Math.Sin(6 * Math.PI * r[0]), 6);
    48       double d = f1 / g;
    49       double f2 = g * (1.0 - d * d);
     47      var f1 = 1 - Math.Exp(-4 * r[0]) * Math.Pow(Math.Sin(6 * Math.PI * r[0]), 6);
     48      var d = f1 / g;
     49      var f2 = g * (1.0 - d * d);
    5050      return new double[] { f1, f2 };
    5151    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Utilities.cs

    r15583 r16171  
    2626namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    2727  internal static class Utilities {
    28     internal static double MinimumDistance(double[] point, IEnumerable<double[]> points) {
    29       if (point == null) throw new ArgumentNullException("Point must not be null.");
    30       if (points == null) throw new ArgumentNullException("Points must not be null.");
    31       if (!points.Any()) throw new ArgumentException("Points must not be empty.");
    32 
    33       double minDistance = double.MaxValue;
    34       foreach (double[] r in points) {
    35         if (r.Length != point.Length) throw new ArgumentException("Dimensions of Points and Point do not match.");
    36 
    37         double squaredDistance = 0;
    38         for (int i = 0; i < r.Length; i++) {
    39           squaredDistance += (point[i] - r[i]) * (point[i] - r[i]);
    40         }
    41         minDistance = Math.Min(squaredDistance, minDistance);
    42       }
    43 
    44       return Math.Sqrt(minDistance);
    45     }
    46 
    4728    internal static DoubleMatrix ToMatrix(IEnumerable<double[]> source) {
    4829      try {
    49         int firstDimension = source.Count();
    50         int secondDimension = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular
     30        var firstDimension = source.Count();
     31        var secondDimension = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular
    5132
    5233        var result = new DoubleMatrix(firstDimension, secondDimension);
    5334        var enumarator = source.GetEnumerator();
    54         for (int i = 0; i < firstDimension && enumarator.MoveNext(); ++i)
    55           for (int j = 0; j < secondDimension; ++j)
     35        for (var i = 0; i < firstDimension && enumarator.MoveNext(); ++i)
     36          for (var j = 0; j < secondDimension; ++j)
    5637            result[i, j] = enumarator.Current[j];
    5738        return result;
     
    6243    }
    6344
    64     internal class DimensionComparer : IComparer<double[]> {
    65       private readonly int dim;
    66       private readonly int descending;
    67 
    68       public DimensionComparer(int dimension, bool descending) {
    69         this.dim = dimension;
    70         this.descending = descending ? -1 : 1;
    71       }
    72 
    73       public int Compare(double[] x, double[] y) {
    74         if (x[dim] < y[dim]) return -descending;
    75         else if (x[dim] > y[dim]) return descending;
    76         else return 0;
    77       }
    78     }
     45   
    7946  }
    8047}
  • branches/2943_MOBasicProblem_MOCMAES/MOCMAES-TestProblem-Rework.sln

    r16123 r16171  
    1111EndProject
    1212Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.TestFunctions.MultiObjective-3.3", "HeuristicLab.Problems.TestFunctions.MultiObjective\3.3\HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj", "{D53E8E48-CFAA-4F57-AC35-63BEF4476159}"
     13EndProject
     14Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Optimization.Operators-3.3", "HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj", "{25087811-F74C-4128-BC86-8324271DA13E}"
     15EndProject
     16Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Data-3.3", "HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj", "{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}"
    1317EndProject
    1418Global
     
    7074    {D53E8E48-CFAA-4F57-AC35-63BEF4476159}.Release|x86.ActiveCfg = Release|x86
    7175    {D53E8E48-CFAA-4F57-AC35-63BEF4476159}.Release|x86.Build.0 = Release|x86
     76    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     77    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|Any CPU.Build.0 = Debug|Any CPU
     78    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|x64.ActiveCfg = Debug|x64
     79    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|x64.Build.0 = Debug|x64
     80    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|x86.ActiveCfg = Debug|x86
     81    {25087811-F74C-4128-BC86-8324271DA13E}.Debug|x86.Build.0 = Debug|x86
     82    {25087811-F74C-4128-BC86-8324271DA13E}.Release|Any CPU.ActiveCfg = Release|Any CPU
     83    {25087811-F74C-4128-BC86-8324271DA13E}.Release|Any CPU.Build.0 = Release|Any CPU
     84    {25087811-F74C-4128-BC86-8324271DA13E}.Release|x64.ActiveCfg = Release|x64
     85    {25087811-F74C-4128-BC86-8324271DA13E}.Release|x64.Build.0 = Release|x64
     86    {25087811-F74C-4128-BC86-8324271DA13E}.Release|x86.ActiveCfg = Release|x86
     87    {25087811-F74C-4128-BC86-8324271DA13E}.Release|x86.Build.0 = Release|x86
     88    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     89    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|Any CPU.Build.0 = Debug|Any CPU
     90    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|x64.ActiveCfg = Debug|x64
     91    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|x64.Build.0 = Debug|x64
     92    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|x86.ActiveCfg = Debug|x86
     93    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Debug|x86.Build.0 = Debug|x86
     94    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|Any CPU.ActiveCfg = Release|Any CPU
     95    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|Any CPU.Build.0 = Release|Any CPU
     96    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|x64.ActiveCfg = Release|x64
     97    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|x64.Build.0 = Release|x64
     98    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|x86.ActiveCfg = Release|x86
     99    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}.Release|x86.Build.0 = Release|x86
    72100  EndGlobalSection
    73101  GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset for help on using the changeset viewer.