Changeset 16171
- Timestamp:
- 09/21/18 09:18:49 (6 years ago)
- 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 17 17 <DebugType>full</DebugType> 18 18 <Optimize>false</Optimize> 19 <OutputPath> $(SolutionDir)\bin\</OutputPath>19 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 20 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 21 21 <ErrorReport>prompt</ErrorReport> … … 80 80 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.ALGLIB-3.7.0.dll</HintPath> 81 81 </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> 83 84 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath> 84 85 </Reference> … … 88 89 <Reference Include="HeuristicLab.Core-3.3"> 89 90 <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>93 91 </Reference> 94 92 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3"> … … 131 129 <Name>HeuristicLab.Analysis-3.3</Name> 132 130 </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> 133 135 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 134 136 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/IIndicator.cs
r15583 r16171 34 34 /// <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> 35 35 /// <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); 37 37 } 38 38 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs
r15583 r16171 28 28 using HeuristicLab.Optimization; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Problems.TestFunctions.MultiObjective; 30 31 31 32 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { … … 41 42 #endregion 42 43 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) { 45 45 var extracted = front.Select(x => x.PenalizedFitness).ToArray(); 46 46 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); 62 48 return pointsums.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index; 63 49 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs
r15583 r16171 30 30 using HeuristicLab.Problems.TestFunctions.MultiObjective; 31 31 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { 32 [Item("HypervolumeIndicator", "Selection of Offspring based on contributing Hypervolume")]32 [Item("HypervolumeIndicator", "Selection of offspring based on contributing Hypervolume")] 33 33 [StorableClass] 34 34 internal class HypervolumeIndicator : Item, IIndicator { … … 41 41 #endregion 42 42 43 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding>problem) {43 public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem problem) { 44 44 var frontCopy = front.Select(x => x.PenalizedFitness).ToList(); 45 45 if (frontCopy.Count <= 1) return 0; 46 46 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); 48 49 var contributions = Enumerable.Range(0, frontCopy.Count).Select(i => Contribution(frontCopy, i, problem.Maximization, refPoint)); 49 50 return contributions.Select((value, index) => new { value, index }).OrderBy(x => x.value).First().index; … … 54 55 var point = front[idx]; 55 56 front.RemoveAt(idx); 56 var contribution = -Hypervolume .Calculate(front.ToArray(), refPoint, maximization);57 var contribution = -HypervolumeCalculator.CalculateHypervolume(front.ToArray(), refPoint, maximization); 57 58 front.Insert(idx, point); 58 59 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;66 60 } 67 61 #endregion -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs
r15583 r16171 42 42 #endregion 43 43 44 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding>problem) {44 public int LeastContributer(IReadOnlyList<Individual> front, IMultiObjectiveBasicProblem problem) { 45 45 var extracted = front.Select(x => x.PenalizedFitness).ToArray(); 46 46 if (extracted.Length <= 2) return 0; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs
r16071 r16171 42 42 public class MOCMAEvolutionStrategy : BasicAlgorithm { 43 43 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; } 48 48 set { base.Problem = value; } 49 49 } 50 50 public override bool SupportsPause { 51 51 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 } 52 60 } 53 61 … … 309 317 solutions = new Individual[PopulationSize]; 310 318 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++) { 314 322 var dim = j % bounds.Rows; 315 323 x[j] = random.NextDouble() * (bounds[dim, 1] - bounds[dim, 0]) + bounds[dim, 0]; … … 322 330 private void InitStrategy() { 323 331 const int lambda = 1; 324 double n = Problem.Encoding.Length;332 double n = Encoding.Length; 325 333 targetSuccessProbability = 1.0 / (5.0 + Math.Sqrt(lambda) / 2.0); 326 334 stepSizeDampeningFactor = 1.0 + n / (2.0 * lambda); … … 358 366 if (problem == null) return; 359 367 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); 361 369 ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume; 362 370 } … … 417 425 } 418 426 private RealVector ClosestFeasible(RealVector x) { 419 var bounds = Problem.Encoding.Bounds;427 var bounds = Encoding.Bounds; 420 428 var r = new RealVector(x.Length); 421 429 for (var i = 0; i < x.Length; i++) { … … 426 434 } 427 435 private bool IsFeasable(RealVector offspring) { 428 var bounds = Problem.Encoding.Bounds;436 var bounds = Encoding.Bounds; 429 437 for (var i = 0; i < offspring.Length; i++) { 430 438 var dim = i % bounds.Rows; … … 438 446 //perform a nondominated sort to assign the rank to every element 439 447 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); 441 449 442 450 //deselect the highest rank fronts until we would end up with less or equal mu elements … … 470 478 471 479 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); 473 484 ResultsSolutions = solutions.Select(x => x.Mean.ToArray()).ToMatrix(); 474 485 … … 476 487 if (problem == null) return; 477 488 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); 486 496 ResultsBestHypervolume = Math.Max(ResultsHypervolume, ResultsBestHypervolume); 487 497 ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume - ResultsBestHypervolume; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r16123 r16171 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 111 111 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.ALGLIB-3.7.0.dll</HintPath> 112 112 </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> 114 115 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath> 115 116 </Reference> … … 123 124 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath> 124 125 </Reference> 125 <Reference Include="HeuristicLab.Data-3.3">126 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>127 </Reference>128 126 <Reference Include="HeuristicLab.Operators-3.3"> 129 127 <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>133 128 </Reference> 134 129 <Reference Include="HeuristicLab.Parameters-3.3"> … … 235 230 </ItemGroup> 236 231 <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> 237 240 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 238 241 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r15934 r16171 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 108 108 </PropertyGroup> 109 109 <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> 110 134 <Reference Include="System" /> 111 135 <Reference Include="System.Core"> … … 160 184 </ItemGroup> 161 185 <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>189 186 <None Include="HeuristicLab.snk" /> 190 187 <None Include="Properties\AssemblyInfo.cs.frame" /> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/Interfaces/IValueTypeArray.cs
r15583 r16171 44 44 } 45 45 46 public interface IValueTypeArray<T> : IValueTypeArray, I Enumerable<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; } 48 48 } 49 49 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/ValueTypeArray.cs
r15583 r16171 76 76 } 77 77 78 public int Count 79 { 80 get { return Length; } 81 } 82 78 83 [Storable] 79 84 protected bool resizable = true; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj
r13164 r16171 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 106 106 </PropertyGroup> 107 107 <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> 108 144 <Reference Include="System" /> 109 145 <Reference Include="System.Core"> … … 158 194 </ItemGroup> 159 195 <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>217 196 <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> 218 197 <Visible>False</Visible> … … 230 209 <Install>true</Install> 231 210 </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> 232 221 </ItemGroup> 233 222 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdingDistanceAssignment.cs
r15583 r16171 66 66 67 67 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]; 82 70 } 83 71 84 72 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))); 95 75 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> Members113 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 #endregion121 76 } 122 77 -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators/3.3/MultiObjective/FastNonDominatedSort.cs
r15583 r16171 75 75 76 76 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); 78 78 79 79 RankParameter.ActualValue = new ItemArray<IntValue>(rank.Select(x => new IntValue(x))); -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/BasicProblem.cs
r15583 r16171 30 30 namespace HeuristicLab.Optimization { 31 31 [StorableClass] 32 public abstract class BasicProblem<TEncoding, TEvaluator> : HeuristicOptimizationProblem<TEvaluator, ISolutionCreator>, I ProblemDefinition, IStorableContent32 public abstract class BasicProblem<TEncoding, TEvaluator> : HeuristicOptimizationProblem<TEvaluator, ISolutionCreator>, IBasicProblem 33 33 where TEncoding : class, IEncoding 34 34 where TEvaluator : class, IEvaluator { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs
r15583 r16171 31 31 namespace HeuristicLab.Optimization { 32 32 [StorableClass] 33 public abstract class MultiObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, MultiObjectiveEvaluator>, IMultiObjective HeuristicOptimizationProblem, IMultiObjectiveProblemDefinition33 public abstract class MultiObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, MultiObjectiveEvaluator>, IMultiObjectiveBasicProblem 34 34 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 35 68 [StorableConstructor] 36 69 protected MultiObjectiveBasicProblem(bool deserializing) : base(deserializing) { } … … 43 76 protected MultiObjectiveBasicProblem() 44 77 : 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")); 47 81 Operators.Add(Evaluator); 48 82 Operators.Add(new MultiObjectiveAnalyzer()); … … 56 90 } 57 91 58 public abstract bool[] Maximization { get; }92 59 93 public abstract double[] Evaluate(Individual individual, IRandom random); 60 94 public virtual void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) { } … … 96 130 } 97 131 98 99 132 #region IMultiObjectiveHeuristicOptimizationProblem Members 100 133 IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter { 101 get { return Parameters[ "Maximization"]; }134 get { return Parameters[MaximizationParameterName]; } 102 135 } 103 136 IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r15583 r16171 31 31 namespace HeuristicLab.Optimization { 32 32 [StorableClass] 33 public abstract class SingleObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, SingleObjectiveEvaluator>, 34 ISingleObjectiveProblemDefinition, ISingleObjectiveHeuristicOptimizationProblem 33 public abstract class SingleObjectiveBasicProblem<TEncoding> : BasicProblem<TEncoding, SingleObjectiveEvaluator>, ISingleObjectiveBasicProblem 35 34 where TEncoding : class, IEncoding { 36 35 -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r16123 r16171 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 105 105 </PropertyGroup> 106 106 <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> 107 115 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 108 116 <SpecificVersion>False</SpecificVersion> … … 120 128 <SpecificVersion>False</SpecificVersion> 121 129 <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>126 130 </Reference> 127 131 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 162 166 <Compile Include="BasicProblems\Individuals\MultiEncodingIndividual.cs" /> 163 167 <Compile Include="BasicProblems\Individuals\SingleEncodingIndividual.cs" /> 168 <Compile Include="BasicProblems\Interfaces\IBasicProblem.cs" /> 164 169 <Compile Include="BasicProblems\Interfaces\IEncoding.cs" /> 165 170 <Compile Include="BasicProblems\Interfaces\IEncodingOperator.cs" /> 166 171 <Compile Include="BasicProblems\Interfaces\IMultiEncodingOperator.cs" /> 172 <Compile Include="BasicProblems\Interfaces\IMultiObjectiveBasicProblem.cs" /> 167 173 <Compile Include="BasicProblems\Interfaces\IMultiObjectiveProblemDefinition.cs" /> 168 174 <Compile Include="BasicProblems\Interfaces\internal\IMultiObjectiveAnalysisOperator.cs" /> … … 172 178 <Compile Include="BasicProblems\Interfaces\internal\ISingleObjectiveEvaluationOperator.cs" /> 173 179 <Compile Include="BasicProblems\Interfaces\IProblemDefinition.cs" /> 180 <Compile Include="BasicProblems\Interfaces\ISingleObjectiveBasicProblem.cs" /> 174 181 <Compile Include="BasicProblems\Interfaces\ISingleObjectiveMoveOperator.cs" /> 175 182 <Compile Include="BasicProblems\Interfaces\ISingleObjectiveProblemDefinition.cs" /> … … 192 199 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 193 200 <Compile Include="Interfaces\IMultiObjectiveOperator.cs" /> 201 <Compile Include="MultiObjective\CrowdingCalculator.cs" /> 194 202 <Compile Include="MultiObjective\DominationCalculator.cs" /> 203 <Compile Include="MultiObjective\GenerationalDistanceCalculator.cs" /> 204 <Compile Include="MultiObjective\HypervolumeCalculator.cs" /> 205 <Compile Include="MultiObjective\SpacingCalculator.cs" /> 195 206 <Compile Include="Results\IResultParameter.cs" /> 196 207 <Compile Include="Interfaces\ISingleObjectiveOperator.cs" /> … … 319 330 </BootstrapperPackage> 320 331 </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> 322 338 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 323 339 <!-- 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 24 24 25 25 namespace HeuristicLab.Optimization { 26 26 27 public enum DominationResult { Dominates, IsDominated, IsNonDominated }; 27 28 28 public static class DominationCalculator <T>{29 public static class DominationCalculator { 29 30 /// <summary> 30 31 /// Calculates the best pareto front only. The fast non-dominated sorting algorithm is used … … 43 44 /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param> 44 45 /// <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 intpopulationSize = 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; 47 48 48 49 Dictionary<T, List<int>> dominatedIndividuals; … … 69 70 /// <param name="dominateOnEqualQualities">Whether solutions of exactly equal quality should dominate one another.</param> 70 71 /// <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 intpopulationSize = 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; 73 74 74 75 Dictionary<T, List<int>> dominatedIndividuals; … … 76 77 var fronts = new List<List<Tuple<T, double[]>>>(); 77 78 fronts.Add(CalculateBestFront(solutions, qualities, maximization, dominateOnEqualQualities, populationSize, out dominatedIndividuals, out dominationCounter, out rank)); 78 inti = 0;79 var i = 0; 79 80 while (i < fronts.Count && fronts[i].Count > 0) { 80 81 var nextFront = new List<Tuple<T, double[]>>(); … … 82 83 List<int> dominatedIndividualsByp; 83 84 if (dominatedIndividuals.TryGetValue(p.Item1, out dominatedIndividualsByp)) { 84 for ( intk = 0; k < dominatedIndividualsByp.Count; k++) {85 intdominatedIndividual = dominatedIndividualsByp[k];85 for (var k = 0; k < dominatedIndividualsByp.Count; k++) { 86 var dominatedIndividual = dominatedIndividualsByp[k]; 86 87 dominationCounter[dominatedIndividual] -= 1; 87 88 if (dominationCounter[dominatedIndividual] == 0) { … … 98 99 } 99 100 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) { 101 102 var front = new List<Tuple<T, double[]>>(); 102 103 dominatedIndividuals = new Dictionary<T, List<int>>(); 103 104 dominationCounter = new int[populationSize]; 104 105 rank = new int[populationSize]; 105 for ( intpI = 0; pI < populationSize - 1; pI++) {106 for (var pI = 0; pI < populationSize - 1; pI++) { 106 107 var p = solutions[pI]; 107 108 List<int> dominatedIndividualsByp; 108 109 if (!dominatedIndividuals.TryGetValue(p, out dominatedIndividualsByp)) 109 110 dominatedIndividuals[p] = dominatedIndividualsByp = new List<int>(); 110 for ( intqI = pI + 1; qI < populationSize; qI++) {111 for (var qI = pI + 1; qI < populationSize; qI++) { 111 112 var test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities); 112 113 if (test == DominationResult.Dominates) { … … 147 148 if (dominateOnEqualQualities) { 148 149 var equal = true; 149 for ( inti = 0; i < left.Length; i++) {150 for (var i = 0; i < left.Length; i++) { 150 151 if (left[i] != right[i]) { 151 152 equal = false; … … 157 158 158 159 bool leftIsBetter = false, rightIsBetter = false; 159 for ( inti = 0; i < left.Length; i++) {160 for (var i = 0; i < left.Length; i++) { 160 161 if (IsDominated(left[i], right[i], maximizations[i])) rightIsBetter = true; 161 162 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 33 33 public class CrowdingAnalyzer : MOTFAnalyzer { 34 34 35 public ILookupParameter<DoubleMatrix> BoundsParameter {36 get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }37 }38 39 35 public IResultParameter<DoubleValue> CrowdingResultParameter { 40 36 get { return (IResultParameter<DoubleValue>)Parameters["Crowding"]; } … … 51 47 52 48 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)")); 56 50 CrowdingResultParameter.DefaultValue = new DoubleValue(double.NaN); 57 58 51 } 59 52 60 53 public override IOperation Apply() { 61 54 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); 65 56 CrowdingResultParameter.ActualValue.Value = crowdingDistance; 66 67 57 return base.Apply(); 68 58 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs
r15583 r16171 64 64 public override IOperation Apply() { 65 65 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); 69 67 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); 74 69 return base.Apply(); 75 70 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs
r15583 r16171 76 76 var qualities = QualitiesParameter.ActualValue; 77 77 var testFunction = TestFunctionParameter.ActualValue; 78 intobjectives = qualities[0].Length;78 var objectives = qualities[0].Length; 79 79 var referencePoint = ReferencePointParameter.ActualValue; 80 80 81 doublebest = BestKnownHypervolumeResultParameter.ActualValue.Value;81 var best = BestKnownHypervolumeResultParameter.ActualValue.Value; 82 82 if (referencePoint.SequenceEqual(testFunction.ReferencePoint(objectives))) { 83 83 best = Math.Max(best, testFunction.OptimalHypervolume(objectives)); 84 84 } 85 85 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)); 89 87 90 88 if (hv > best) { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs
r15583 r16171 47 47 } 48 48 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 57 49 [StorableConstructor] 58 50 protected InvertedGenerationalDistanceAnalyzer(bool deserializing) : base(deserializing) { } … … 62 54 } 63 55 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 64 62 public override IOperation Apply() { 65 63 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); 70 65 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); 75 67 return base.Apply(); 76 68 } 77 78 79 69 } 80 70 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs
r15583 r16171 59 59 var individuals = IndividualsParameter.ActualValue; 60 60 var testFunction = TestFunctionParameter.ActualValue; 61 intobjectives = qualities[0].Length;62 intproblemSize = individuals[0].Length;61 var objectives = qualities[0].Length; 62 var problemSize = individuals[0].Length; 63 63 64 double[][]optimalFront = new double[0][];64 var optimalFront = new double[0][]; 65 65 var front = testFunction.OptimalParetoFront(objectives); 66 66 if (front != null) optimalFront = front.ToArray(); -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs
r15583 r16171 51 51 public override IOperation Apply() { 52 52 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); 56 54 return base.Apply(); 57 55 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj
r16123 r16171 17 17 <DebugType>full</DebugType> 18 18 <Optimize>false</Optimize> 19 <OutputPath>..\..\ bin\</OutputPath>19 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 20 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 21 21 <ErrorReport>prompt</ErrorReport> … … 90 90 <Reference Include="HeuristicLab.Core-3.3"> 91 91 <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>95 92 </Reference> 96 93 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3"> … … 134 131 <Compile Include="Interfaces\IConstrainedTestFunction.cs" /> 135 132 <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" />141 133 <Compile Include="ParetoFrontScatterPlot.cs" /> 142 134 <Compile Include="Utilities.cs" /> … … 206 198 <Name>HeuristicLab.Analysis-3.3</Name> 207 199 </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> 208 204 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 209 205 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r15583 r16171 38 38 39 39 #region Parameter Properties 40 public IValueParameter<BoolArray> MaximizationParameter {40 public new IValueParameter<BoolArray> MaximizationParameter { 41 41 get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; } 42 42 } … … 53 53 get { return (IValueParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; } 54 54 } 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 }61 55 62 56 #endregion … … 64 58 #region Properties 65 59 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); } 70 61 } 71 62 … … 85 76 get { return TestFunctionParameter.Value; } 86 77 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; }95 78 } 96 79 #endregion … … 116 99 Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2))); 117 100 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."));119 101 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"));121 102 122 103 Encoding.LengthParameter = ProblemSizeParameter; … … 138 119 public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) { 139 120 base.Analyze(individuals, qualities, results, random); 140 if (results.ContainsKey("Pareto Front")) {121 if (results.ContainsKey("Pareto Front")) 141 122 ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true; 142 }143 123 } 144 124 … … 170 150 #region Events 171 151 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); 174 156 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)))); 179 162 180 163 BoundsParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives)); 181 ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));182 164 } 183 165 … … 196 178 ProblemSize = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(ProblemSize, TestFunction.MaximumSolutionLength)); 197 179 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)))); 199 182 ParameterizeAnalyzers(); 200 183 UpdateParameterValues(); … … 237 220 analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name; 238 221 239 var crowdingAnalyzer = analyzer as CrowdingAnalyzer;240 if (crowdingAnalyzer != null) {241 crowdingAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;242 }243 244 222 var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer; 245 223 if (scatterPlotAnalyzer != null) { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/NonDominatedSelect.cs
r15583 r16171 25 25 26 26 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 89 28 } 90 29 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ.cs
r15583 r16171 42 42 43 43 protected override double[] GetReferencePoint(int objectives) { 44 double[]rp = new double[objectives];45 for ( inti = 0; i < objectives; i++) {44 var rp = new double[objectives]; 45 for (var i = 0; i < objectives; i++) { 46 46 rp[i] = 11; 47 47 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ1.cs
r15583 r16171 48 48 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 49 49 } 50 double[]res = new double[objectives];51 intk = r.Length - objectives + 1;50 var res = new double[objectives]; 51 var k = r.Length - objectives + 1; 52 52 double g = 0; 53 53 54 for ( inti = r.Length - k; i < r.Length; i++) {54 for (var i = r.Length - k; i < r.Length; i++) { 55 55 g += (r[i] - 0.5) * (r[i] - 0.5) - Math.Cos(20.0 * Math.PI * (r[i] - 0.5)); 56 56 }; … … 58 58 g *= 100; 59 59 60 for ( inti = 0; i < objectives; i++) {60 for (var i = 0; i < objectives; i++) { 61 61 res[i] = 0.5 * (1.0 + g); 62 for ( intj = 0; j < objectives - i - 1; ++j)62 for (var j = 0; j < objectives - i - 1; ++j) 63 63 res[i] *= (r[j]); 64 64 if (i > 0) -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ2.cs
r15583 r16171 48 48 } 49 49 50 double[]res = new double[objectives];50 var res = new double[objectives]; 51 51 52 52 //calculate g(Xm) 53 53 double g = 0; 54 for ( inti = objectives; i < r.Length; i++) {55 doubled = r[i] - 0.5;54 for (var i = objectives; i < r.Length; i++) { 55 var d = r[i] - 0.5; 56 56 g += d * d; 57 57 } 58 58 59 59 //calculating f0...fM-1 60 for ( inti = 0; i < objectives; i++) {61 doublef = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);62 for ( intj = 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++) { 63 63 f *= Math.Cos(r[j] * Math.PI / 2); 64 64 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ3.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double sum = 0; 53 intlength = r.Length - objectives + 1;54 for ( inti = r.Length - length; i < r.Length; i++) {55 doubled = 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; 56 56 sum += d * d - Math.Cos(20 * Math.PI * d); 57 57 } 58 doubleg = 100 * (length + sum);58 var g = 100 * (length + sum); 59 59 60 60 //calculating f0...fM-1 61 for ( inti = 0; i < objectives; i++) {62 doublef = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);63 for ( intj = 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++) { 64 64 f *= Math.Cos(r[j] * Math.PI / 2); 65 65 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ4.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double g = 0; 53 for ( inti = objectives; i < r.Length; i++) {54 doubled = r[i] - 0.5;53 for (var i = objectives; i < r.Length; i++) { 54 var d = r[i] - 0.5; 55 55 g += d * d; 56 56 } 57 57 58 58 //calculating f0...fM-1 59 for ( inti = 0; i < objectives; i++) {60 doublef = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);61 for ( intj = 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++) { 62 62 f *= Math.Cos(Math.Pow(r[j], 100) * Math.PI / 2); 63 63 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ5.cs
r15583 r16171 42 42 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 43 43 } 44 double[]res = new double[objectives];44 var res = new double[objectives]; 45 45 46 46 //calculate g(Xm) 47 47 double g = 0; 48 for ( inti = objectives; i < r.Length; i++) {49 doubled = r[i] - 0.5;48 for (var i = objectives; i < r.Length; i++) { 49 var d = r[i] - 0.5; 50 50 g += d * d; 51 51 } … … 56 56 57 57 //calculating f0...fM-1 58 for ( inti = 0; i < objectives; i++) {59 doublef = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);60 for ( intj = 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++) { 61 61 f *= Math.Cos(phi(r[j]) * Math.PI / 2); 62 62 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ6.cs
r15583 r16171 42 42 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 43 43 } 44 double[]res = new double[objectives];44 var res = new double[objectives]; 45 45 46 46 //calculate g(Xm) 47 47 double g = 0; 48 for ( inti = objectives; i < r.Length; i++) {48 for (var i = objectives; i < r.Length; i++) { 49 49 g += Math.Pow(r[i], 0.1); 50 50 } … … 55 55 56 56 //calculating f0...fM-1 57 for ( inti = 0; i < objectives; i++) {58 doublef = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);59 for ( intj = 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++) { 60 60 f *= Math.Cos(phi(r[j]) * Math.PI / 2); 61 61 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ7.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double g = 0, length = length = r.Length - objectives + 1; 53 for ( inti = objectives; i < r.Length; i++) {53 for (var i = objectives; i < r.Length; i++) { 54 54 g += r[i]; 55 55 } … … 58 58 59 59 //calculating f0...fM-2 60 for ( inti = 0; i < objectives - 1; i++) {60 for (var i = 0; i < objectives - 1; i++) { 61 61 res[i] = r[i]; 62 62 } 63 63 //calculate fM-1 64 64 double h = objectives; 65 for ( inti = 0; i < objectives - 1; i++) {65 for (var i = 0; i < objectives - 1; i++) { 66 66 h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i])); 67 67 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ8.cs
r15583 r16171 30 30 public class DTLZ8 : DTLZ, IConstrainedTestFunction { 31 31 public static double[] IllegalValue(int size, bool[] maximization) { 32 double[]res = new double[size];33 for ( inti = 0; i < size; i++) {32 var res = new double[size]; 33 for (var i = 0; i < size; i++) { 34 34 res[i] = maximization[i] ? Double.MinValue : Double.MaxValue; 35 35 } … … 49 49 double n = r.Length; 50 50 double M = objectives; 51 doubleratio = n / M;52 double[]res = new double[objectives];53 for ( intj = 0; j < objectives; j++) {51 var ratio = n / M; 52 var res = new double[objectives]; 53 for (var j = 0; j < objectives; j++) { 54 54 double sum = 0; 55 for ( inti = (int)(j * ratio); i < (j + 1) + ratio; i++) {55 for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 56 56 sum += r[i]; 57 57 } … … 59 59 res[j] = sum; 60 60 } 61 for ( intj = 0; j < M - 1; j++) {61 for (var j = 0; j < M - 1; j++) { 62 62 if (res[objectives - 1] + 4 * res[j] - 1 < 0) return IllegalValue(objectives, GetMaximization(objectives)); 63 63 } 64 doublemin = Double.PositiveInfinity;65 for ( inti = 0; i < res.Length - 1; i++) {66 for ( intj = 0; j < i; j++) {67 doubled = 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]; 68 68 if (min < d) min = d; 69 69 } … … 78 78 double n = r.Length; 79 79 double M = objectives; 80 doubleratio = n / M;81 double[]res = new double[objectives];82 double[]constraints = new double[objectives];83 for ( intj = 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++) { 84 84 double sum = 0; 85 for ( inti = (int)(j * ratio); i < (j + 1) + ratio; i++) {85 for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 86 86 sum += r[i]; 87 87 } … … 89 89 res[j] = sum; 90 90 } 91 for ( intj = 0; j < M - 1; j++) {92 doubled1 = 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; 93 93 constraints[j] = d1 < 0 ? -d1 : 0; 94 94 } 95 doublemin = Double.PositiveInfinity;96 for ( inti = 0; i < res.Length - 1; i++) {97 for ( intj = 0; j < i; j++) {98 doubled2 = 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]; 99 99 if (min < d2) min = d2; 100 100 } 101 101 } 102 doubled = 2 * res[objectives - 1] + min - 1;102 var d = 2 * res[objectives - 1] + min - 1; 103 103 constraints[constraints.Length - 1] = d < 0 ? -d : 0; 104 104 return constraints; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR.cs
r15583 r16171 20 20 #endregion 21 21 using System; 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Encodings.RealVectorEncoding; 25 using HeuristicLab.Optimization; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 27 … … 36 38 37 39 protected override double[] GetReferencePoint(int objectives) { 38 double[]rp = new double[objectives];39 for ( inti = 0; i < objectives; i++) {40 var rp = new double[objectives]; 41 for (var i = 0; i < objectives; i++) { 40 42 rp[i] = 11; 41 43 } … … 58 60 protected abstract double G(RealVector y); 59 61 62 protected override double GetBestKnownHypervolume(int objectives) { 63 return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives)); 64 } 60 65 61 66 protected double H(double x, RealVector r) { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR1.cs
r15583 r16171 31 31 public class IHR1 : IHR { 32 32 protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) { 33 List<double[]>res = new List<double[]>();34 for ( inti = 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); 36 36 r[0] = 1 / 500.0 * i; 37 37 res.Add(this.Evaluate(r, objectives)); 38 38 } 39 39 return res; 40 }41 42 protected override double GetBestKnownHypervolume(int objectives) {43 return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));44 40 } 45 41 … … 64 60 65 61 protected override double G(RealVector y) { 66 doublesum = 0.0;67 for ( inti = 1; i < y.Length; i++) {62 var sum = 0.0; 63 for (var i = 1; i < y.Length; i++) { 68 64 sum += HG(y[i]); 69 65 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR2.cs
r15583 r16171 31 31 public class IHR2 : IHR { 32 32 protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) { 33 List<double[]>res = new List<double[]>();34 for ( inti = 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); 36 36 r[0] = 1 / 500.0 * i; 37 37 … … 39 39 } 40 40 return res; 41 }42 43 protected override double GetBestKnownHypervolume(int objectives) {44 return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));45 41 } 46 42 … … 66 62 67 63 protected override double G(RealVector y) { 68 doublesum = 0.0;69 for ( inti = 1; i < y.Length; i++) {64 var sum = 0.0; 65 for (var i = 1; i < y.Length; i++) { 70 66 sum += HG(y[i]); 71 67 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR3.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 31 32 public class IHR3 : IHR { 32 33 protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) { 33 List<double[]>res = new List<double[]>();34 for ( inti = 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); 36 37 r[0] = 1 / 500.0 * i; 37 38 … … 39 40 } 40 41 return res; 41 }42 43 protected override double GetBestKnownHypervolume(int objectives) {44 return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));45 42 } 46 43 … … 66 63 67 64 protected override double G(RealVector y) { 68 doublesum = 0.0;69 for ( inti = 1; i < y.Length; i++) {65 var sum = 0.0; 66 for (var i = 1; i < y.Length; i++) { 70 67 sum += HG(y[i]); 71 68 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR4.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 31 32 public class IHR4 : IHR { 32 33 protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) { 33 List<double[]>res = new List<double[]>();34 for ( inti = 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); 36 37 r[0] = 1 / 500.0 * i; 37 38 res.Add(this.Evaluate(r, objectives)); 38 39 } 39 40 return res; 40 }41 42 protected override double GetBestKnownHypervolume(int objectives) {43 return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));44 41 } 45 42 … … 69 66 70 67 protected override double G(RealVector y) { 71 doublesum = 0.0;72 for ( inti = 1; i < y.Length; i++) {68 var sum = 0.0; 69 for (var i = 1; i < y.Length; i++) { 73 70 sum += y[i] * y[i] - 10 * Math.Cos(4 * Math.PI * y[i]); 74 71 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/IHR/IHR6.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 31 32 public class IHR6 : IHR { 32 33 protected override IEnumerable<double[]> GetOptimalParetoFront(int objectives) { 33 List<double[]>res = new List<double[]>();34 for ( inti = 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); 36 37 r[0] = 1 / 500.0 * i; 37 38 res.Add(this.Evaluate(r, objectives)); 38 39 } 39 40 return res; 40 }41 42 protected override double GetBestKnownHypervolume(int objectives) {43 return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));44 41 } 45 42 … … 65 62 66 63 protected override double G(RealVector y) { 67 doublesum = 0.0;68 for ( inti = 1; i < y.Length; i++) {64 var sum = 0.0; 65 for (var i = 1; i < y.Length; i++) { 69 66 sum += HG(y[i]); 70 67 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Optimization; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 43 45 44 46 protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) { 45 List<double[]>res = new List<double[]>();46 for ( inti = 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); 48 50 r[0] = 2 / 500.0 * i; 49 51 r[1] = 2 / 500.0 * i; … … 54 56 55 57 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)); 57 59 } 58 60 … … 68 70 public override double[] Evaluate(RealVector r, int objectives) { 69 71 if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives"); 70 doublex = r[0];72 var x = r[0]; 71 73 double a = 1000; 72 doublesum = x * x;73 for ( inti = 1; i < r.Length - 1; i++) {74 var sum = x * x; 75 for (var i = 1; i < r.Length - 1; i++) { 74 76 sum += a * r[i] * r[i]; 75 77 } … … 77 79 78 80 //objective1 79 doublef0 = 1 / (a * a * r.Length) * sum;81 var f0 = 1 / (a * a * r.Length) * sum; 80 82 81 83 x = x - 2; 82 84 sum = x * x; 83 for ( inti = 1; i < r.Length - 1; i++) {85 for (var i = 1; i < r.Length - 1; i++) { 84 86 sum += a * (r[i] - 2) * (r[i] - 2); 85 87 } … … 87 89 sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2); 88 90 //objective0 89 doublef1 = 1 / (a * a * r.Length) * sum;91 var f1 = 1 / (a * a * r.Length) * sum; 90 92 91 93 return new double[] { f0, f1 }; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/ELLI1.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Optimization; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 43 45 44 46 protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) { 45 List<double[]>res = new List<double[]>();46 for ( inti = 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); 48 50 r[0] = 2 / 500.0 * i; 49 51 r[1] = 2 / 500.0 * i; … … 54 56 55 57 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)); 57 59 } 58 60 … … 69 71 if (objectives != 2) throw new ArgumentException("The ELLI problem must always have 2 objectives"); 70 72 double a = 1000; 71 doublesum = 0.0;72 for ( inti = 0; i < r.Length; i++) {73 var sum = 0.0; 74 for (var i = 0; i < r.Length; i++) { 73 75 sum += Math.Pow(a, 2 * i / (r.Length - 1)) * r[i] * r[i]; 74 76 } 75 77 76 78 //objective1 77 doublef0 = 1 / (a * a * r.Length) * sum;79 var f0 = 1 / (a * a * r.Length) * sum; 78 80 79 81 sum = 0.0; 80 for ( inti = 0; i < r.Length; i++) {82 for (var i = 0; i < r.Length; i++) { 81 83 sum += Math.Pow(a, 2 * i / (r.Length - 1)) * (r[i] - 2) * (r[i] - 2); 82 84 } 83 85 //objective0 84 doublef1 = 1 / (a * a * r.Length) * sum;86 var f1 = 1 / (a * a * r.Length) * sum; 85 87 86 88 return new double[] { f0, f1 }; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs
r15583 r16171 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.RealVectorEncoding; 28 using HeuristicLab.Optimization; 27 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 30 … … 44 46 45 47 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)); 47 49 } 48 50 … … 65 67 66 68 //objective1 67 for ( inti = 0; i < r.Length; i++) {68 doubled = r[i] - aux;69 for (var i = 0; i < r.Length; i++) { 70 var d = r[i] - aux; 69 71 f0 += d * d; 70 72 } … … 72 74 73 75 //objective2 74 doublef1 = 0.0;75 for ( inti = 0; i < r.Length; i++) {76 doubled = r[i] + aux;76 var f1 = 0.0; 77 for (var i = 0; i < r.Length; i++) { 78 var d = r[i] + aux; 77 79 f1 += d * d; 78 80 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Kursawe.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Optimization; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 43 45 44 46 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)); 46 48 } 47 49 … … 65 67 if (objectives != 2) throw new ArgumentException("The Kursawe problem must always have 2 objectives"); 66 68 //objective 1 67 doublef0 = 0.0;68 for ( inti = 0; i < r.Length - 1; i++) {69 var f0 = 0.0; 70 for (var i = 0; i < r.Length - 1; i++) { 69 71 f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1])); 70 72 } 71 73 //objective2 72 doublef1 = 0.0;73 for ( inti = 0; i < r.Length; i++) {74 var f1 = 0.0; 75 for (var i = 0; i < r.Length; i++) { 74 76 f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3)); 75 77 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN1.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Optimization; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 48 50 49 51 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)); 51 53 } 52 54 … … 63 65 if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives"); 64 66 if (r.Length != 1) return null; 65 doublex = r[0];67 var x = r[0]; 66 68 67 69 //objective1 68 doublef0 = x * x;70 var f0 = x * x; 69 71 70 72 //objective0 71 doublef1 = x - 2;73 var f1 = x - 2; 72 74 f1 *= f1; 73 75 -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN2.cs
r15583 r16171 59 59 public override double[] Evaluate(RealVector r, int objectives) { 60 60 if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives"); 61 doublex = r[0];61 var x = r[0]; 62 62 63 63 //objective1 … … 69 69 70 70 //objective0 71 doublef1 = x - 5;71 var f1 = x - 5; 72 72 f1 *= f1; 73 73 -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ParetoFrontStore.cs
r15583 r16171 29 29 internal class ParetoFrontStore { 30 30 internal static IEnumerable<double[]> GetParetoFront(String filename) { 31 List<double[]>data = new List<double[]>();31 var data = new List<double[]>(); 32 32 var assembly = Assembly.GetExecutingAssembly(); 33 Stringressourcename = typeof(ParetoFrontStore).Namespace + ".TestFunctions." + filename + ".pf";33 var ressourcename = typeof(ParetoFrontStore).Namespace + ".TestFunctions." + filename + ".pf"; 34 34 35 35 //check if file is listed … … 42 42 while ((s = ressourceReader.ReadLine()) != null) { 43 43 var tokens = s.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); 44 double[]point = new double[tokens.Length];45 for ( inti = 0; i < point.Length; i++) {44 var point = new double[tokens.Length]; 45 for (var i = 0; i < point.Length; i++) { 46 46 point[i] = Double.Parse(tokens[i], CultureInfo.InvariantCulture); 47 47 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT1.cs
r15583 r16171 44 44 public override double[] Evaluate(RealVector r) { 45 45 double g = 0; 46 for ( inti = 1; i < r.Length; i++) g += r[i];46 for (var i = 1; i < r.Length; i++) g += r[i]; 47 47 g = 1.0 + 9.0 * g / (r.Length - 1); 48 doublef0 = r[0];49 doublef1 = g * (1.0 - Math.Sqrt(r[0] / g));48 var f0 = r[0]; 49 var f1 = g * (1.0 - Math.Sqrt(r[0] / g)); 50 50 return new double[] { f0, f1 }; 51 51 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT2.cs
r15583 r16171 42 42 public override double[] Evaluate(RealVector r) { 43 43 double g = 0; 44 for ( inti = 1; i < r.Length; i++) g += r[i];44 for (var i = 1; i < r.Length; i++) g += r[i]; 45 45 g = 1.0 + 9.0 * g / (r.Length - 1); 46 doubled = r[0] / g;47 doublef0 = r[0];48 doublef1 = g * (1.0 - d * d);46 var d = r[0] / g; 47 var f0 = r[0]; 48 var f1 = g * (1.0 - d * d); 49 49 return new double[] { f0, f1 }; 50 50 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT3.cs
r15583 r16171 44 44 public override double[] Evaluate(RealVector r) { 45 45 double g = 0; 46 for ( inti = 1; i < r.Length; i++) g += r[i];46 for (var i = 1; i < r.Length; i++) g += r[i]; 47 47 g = 1.0 + 9.0 * g / (r.Length - 1); 48 doubled = r[0] / g;49 doublef0 = r[0];50 doublef1 = 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])); 51 51 return new double[] { f0, f1 }; 52 52 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT4.cs
r15583 r16171 30 30 public class ZDT4 : ZDT { 31 31 protected override double[,] GetBounds(int objectives) { 32 double[,]bounds = new double[objectives, 2];32 var bounds = new double[objectives, 2]; 33 33 bounds[0, 0] = 0; bounds[0, 1] = 1; 34 for ( inti = 1; i < objectives; i++) {34 for (var i = 1; i < objectives; i++) { 35 35 bounds[i, 0] = -5; 36 36 bounds[i, 1] = 5; … … 53 53 public override double[] Evaluate(RealVector r) { 54 54 double g = 0; 55 for ( inti = 1; i < r.Length; i++) {56 doublev = r[i];55 for (var i = 1; i < r.Length; i++) { 56 var v = r[i]; 57 57 g += v * v - 10 * Math.Cos(4 * Math.PI * v); 58 58 } 59 59 g = 1.0 + 10.0 * (r.Length - 1) + g; 60 doubled = r[0] / g;61 doublef0 = r[0];62 doublef1 = 1 - Math.Sqrt(d);60 var d = r[0] / g; 61 var f0 = r[0]; 62 var f1 = 1 - Math.Sqrt(d); 63 63 return new double[] { f0, f1 }; 64 64 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/ZDT/ZDT6.cs
r15583 r16171 43 43 public override double[] Evaluate(RealVector r) { 44 44 double g = 0; 45 for ( inti = 1; i < r.Length; i++) g += r[i];45 for (var i = 1; i < r.Length; i++) g += r[i]; 46 46 g = 1.0 + 9.0 * Math.Pow(g / (r.Length - 1), 0.25); 47 doublef1 = 1 - Math.Exp(-4 * r[0]) * Math.Pow(Math.Sin(6 * Math.PI * r[0]), 6);48 doubled = f1 / g;49 doublef2 = 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); 50 50 return new double[] { f1, f2 }; 51 51 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Utilities.cs
r15583 r16171 26 26 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 27 27 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 47 28 internal static DoubleMatrix ToMatrix(IEnumerable<double[]> source) { 48 29 try { 49 intfirstDimension = source.Count();50 intsecondDimension = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular30 var firstDimension = source.Count(); 31 var secondDimension = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular 51 32 52 33 var result = new DoubleMatrix(firstDimension, secondDimension); 53 34 var enumarator = source.GetEnumerator(); 54 for ( inti = 0; i < firstDimension && enumarator.MoveNext(); ++i)55 for ( intj = 0; j < secondDimension; ++j)35 for (var i = 0; i < firstDimension && enumarator.MoveNext(); ++i) 36 for (var j = 0; j < secondDimension; ++j) 56 37 result[i, j] = enumarator.Current[j]; 57 38 return result; … … 62 43 } 63 44 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 79 46 } 80 47 } -
branches/2943_MOBasicProblem_MOCMAES/MOCMAES-TestProblem-Rework.sln
r16123 r16171 11 11 EndProject 12 12 Project("{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}" 13 EndProject 14 Project("{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}" 15 EndProject 16 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Data-3.3", "HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj", "{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}" 13 17 EndProject 14 18 Global … … 70 74 {D53E8E48-CFAA-4F57-AC35-63BEF4476159}.Release|x86.ActiveCfg = Release|x86 71 75 {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 72 100 EndGlobalSection 73 101 GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset
for help on using the changeset viewer.