Changeset 16807 for branches/2521_ProblemRefactoring
- Timestamp:
- 04/17/19 23:07:03 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/IIndicator.cs
r16723 r16807 20 20 #endregion 21 21 using System.Collections.Generic; 22 using HEAL.Attic; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.RealVectorEncoding; 24 25 using HeuristicLab.Optimization; 25 using HEAL.Attic;26 26 27 27 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { … … 36 36 /// <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> 37 37 /// <returns>the index of the least contributing point according to any type of quality criteria</returns> 38 int LeastContributer(IReadOnlyList<Individual> front, MultiObjective BasicProblem<RealVectorEncoding> problem);38 int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem); 39 39 } 40 40 } -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs
r16723 r16807 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Encodings.RealVectorEncoding; 28 29 using HeuristicLab.Optimization; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { … … 41 41 #endregion 42 42 43 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjective BasicProblem<RealVectorEncoding> problem) {43 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) { 44 44 var bounds = problem.Encoding.Bounds; 45 45 var extracted = front.Select(x => x.PenalizedFitness).ToArray(); -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs
r16723 r16807 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Encodings.RealVectorEncoding; 28 29 using HeuristicLab.Optimization; 29 using HEAL.Attic;30 30 using HeuristicLab.Problems.TestFunctions.MultiObjective; 31 31 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { … … 41 41 #endregion 42 42 43 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjective BasicProblem<RealVectorEncoding> problem) {43 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) { 44 44 var frontCopy = front.Select(x => x.PenalizedFitness).ToList(); 45 45 if (frontCopy.Count <= 1) return 0; 46 //TODO discuss with bwerth 46 47 var p = problem as MultiObjectiveTestFunctionProblem; 47 48 var refPoint = BuildReferencePoint(p != null ? frontCopy.Concat(new[] { p.ReferencePoint.CloneAsArray() }) : frontCopy, problem.Maximization); -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs
r16723 r16807 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Encodings.RealVectorEncoding; 28 29 using HeuristicLab.Optimization; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { … … 42 42 #endregion 43 43 44 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjective BasicProblem<RealVectorEncoding> problem) {44 public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) { 45 45 var extracted = front.Select(x => x.PenalizedFitness).ToArray(); 46 46 if (extracted.Length <= 2) return 0; -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Individual.cs
r16723 r16807 23 23 using System; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HEAL.Attic;28 28 using HeuristicLab.Random; 29 29 -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs
r16723 r16807 25 25 using System.Linq; 26 26 using System.Threading; 27 using HEAL.Attic; 27 28 using HeuristicLab.Analysis; 28 29 using HeuristicLab.Common; … … 32 33 using HeuristicLab.Optimization; 33 34 using HeuristicLab.Parameters; 34 using HEAL.Attic;35 35 using HeuristicLab.Problems.TestFunctions.MultiObjective; 36 36 using HeuristicLab.Random; … … 42 42 public class MOCMAEvolutionStrategy : BasicAlgorithm { 43 43 public override Type ProblemType { 44 get { return typeof(MultiObjective BasicProblem<RealVectorEncoding>); }45 } 46 public new MultiObjective BasicProblem<RealVectorEncoding> Problem {47 get { return (MultiObjective BasicProblem<RealVectorEncoding>)base.Problem; }44 get { return typeof(MultiObjectiveProblem<RealVectorEncoding, RealVector>); } 45 } 46 public new MultiObjectiveProblem<RealVectorEncoding, RealVector> Problem { 47 get { return (MultiObjectiveProblem<RealVectorEncoding, RealVector>)base.Problem; } 48 48 set { base.Problem = value; } 49 49 } … … 361 361 ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume; 362 362 } 363 ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), problem.Objectives, problem.ProblemSize);363 ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), Problem.Objectives, Problem.Encoding.Length); 364 364 } 365 365 #endregion … … 409 409 } 410 410 private double[] Evaluate(RealVector x) { 411 var res = Problem.Evaluate( new SingleEncodingIndividual(Problem.Encoding, new Scope { Variables = { new Variable(Problem.Encoding.Name, x) } }), random);411 var res = Problem.Evaluate(x, random); 412 412 return res; 413 413 } … … 495 495 ResultsHypervolumeDifferenceDataLine.Values.Add(ResultsDifferenceBestKnownHypervolume); 496 496 497 Problem.Analyze( 498 solutions.Select(x => (Optimization.Individual)new SingleEncodingIndividual(Problem.Encoding, new Scope { Variables = { new Variable(Problem.Encoding.Name, x.Mean) } })).ToArray(), 497 Problem.Analyze(solutions.Select(x => x.Mean).ToArray(), 499 498 solutions.Select(x => x.Fitness).ToArray(), 500 499 Results, -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r16723 r16807 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.Problems.Instances; 32 32 … … 35 35 [Creatable(CreatableAttribute.Categories.Problems, Priority = 95)] 36 36 [Item("Test Function (multi-objective)", "Test functions with real valued inputs and multiple objectives.")] 37 public class MultiObjectiveTestFunctionProblem : MultiObjective BasicProblem<RealVectorEncoding>, IProblemInstanceConsumer<MOTFData> {37 public class MultiObjectiveTestFunctionProblem : MultiObjectiveProblem<RealVectorEncoding, RealVector>, IProblemInstanceConsumer<MOTFData> { 38 38 39 39 #region Parameter Properties 40 public IValueParameter<BoolArray> MaximizationParameter {41 get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }42 }43 40 public IFixedValueParameter<IntValue> ProblemSizeParameter { 44 41 get { return (IFixedValueParameter<IntValue>)Parameters["ProblemSize"]; } … … 65 62 public override bool[] Maximization { 66 63 get { 67 if (!Parameters.ContainsKey("Maximization")) return new bool[2]; 68 return MaximizationParameter.Value.ToArray(); 64 //necessary because of virtual member call in base ctor 65 if (!Parameters.ContainsKey("TestFunction")) return new bool[0]; 66 return TestFunction.Maximization(Objectives).ToArray(); 69 67 } 70 68 } … … 136 134 137 135 138 public override void Analyze( Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {139 base.Analyze( individuals, qualities, results, random);136 public override void Analyze(RealVector[] solutions, double[][] qualities, ResultCollection results, IRandom random) { 137 base.Analyze(solutions, qualities, results, random); 140 138 if (results.ContainsKey("Pareto Front")) { 141 139 ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true; … … 156 154 } 157 155 158 public double[] Evaluate(RealVector individual) { 159 return TestFunction.Evaluate(individual, Objectives); 160 } 161 162 public override double[] Evaluate(Individual individual, IRandom random) { 163 return Evaluate(individual.RealVector()); 164 } 156 public override double[] Evaluate(RealVector solution, IRandom random) { 157 return TestFunction.Evaluate(solution, Objectives); 158 } 159 165 160 166 161 public void Load(MOTFData data) { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs
r16723 r16807 22 22 using System; 23 23 using System.Collections.Generic; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { … … 35 35 } 36 36 37 protected override bool[] GetMaximization(int objec itves) {37 protected override bool[] GetMaximization(int objectives) { 38 38 return new bool[2]; 39 39 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs
r16723 r16807 148 148 pictureBox.Refresh(); 149 149 DoubleMatrix bounds = Content.Bounds; 150 if (bounds == null) bounds = Content. Evaluator.Bounds;150 if (bounds == null) bounds = Content.Bounds; 151 151 double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1]; 152 152 double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);
Note: See TracChangeset
for help on using the changeset viewer.