Changeset 16657
- Timestamp:
- 03/07/19 16:15:04 (6 years ago)
- Location:
- branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithm.cs
r16630 r16657 60 60 var neighbourhoodSelectionProbability = NeighbourhoodSelectionProbability; 61 61 var rand = RandomParameter.Value; 62 var normalizeObjectives = NormalizeObjectives; 63 var maximumNumberOfReplacedSolutions = MaximumNumberOfReplacedSolutions; 62 64 63 65 // cancellation token for the inner operations which should not be immediately cancelled … … 103 105 NadirPoint.UpdateNadir(childSolution.Qualities); 104 106 // update neighbourhood will insert the child into the population 105 UpdateNeighbourHood(rand, childSolution, subProblemId, neighbourType );107 UpdateNeighbourHood(rand, childSolution, subProblemId, neighbourType, maximumNumberOfReplacedSolutions, normalizeObjectives); 106 108 107 109 ++evaluatedSolutions; -
branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/MOEADAlgorithmBase.cs
r16649 r16657 166 166 public new IMultiObjectiveHeuristicOptimizationProblem Problem { 167 167 get { return (IMultiObjectiveHeuristicOptimizationProblem)base.Problem; } 168 set { base.Problem = value; } 168 169 } 169 170 public int Seed { … … 472 473 } 473 474 474 protected void UpdateNeighbourHood(IRandom random, IMOEADSolution individual, int subProblemId, NeighborType neighbourType ) {475 protected void UpdateNeighbourHood(IRandom random, IMOEADSolution individual, int subProblemId, NeighborType neighbourType, int maximumNumberOfReplacedSolutions, bool normalizeObjectives = false) { 475 476 int replacedSolutions = 0; 476 477 int size = neighbourType == NeighborType.NEIGHBOR ? NeighbourSize : population.Length; … … 481 482 : i; 482 483 483 double f1 = CalculateFitness(population[k].Qualities, lambda[k] );484 double f2 = CalculateFitness(individual.Qualities, lambda[k] );484 double f1 = CalculateFitness(population[k].Qualities, lambda[k], normalizeObjectives); 485 double f2 = CalculateFitness(individual.Qualities, lambda[k], normalizeObjectives); 485 486 486 487 if (f2 < f1) { … … 489 490 } 490 491 491 if (replacedSolutions >= MaximumNumberOfReplacedSolutions) {492 if (replacedSolutions >= maximumNumberOfReplacedSolutions) { 492 493 return; 493 494 } … … 495 496 } 496 497 497 private double CalculateFitness(double[] qualities, double[] lambda ) {498 private double CalculateFitness(double[] qualities, double[] lambda, bool normalizeObjectives = false) { 498 499 int dim = qualities.Length; 499 500 switch (functionType) { … … 502 503 503 504 for (int n = 0; n < dim; n++) { 504 var diff = qualities[n] - IdealPoint[n]; 505 if (NormalizeObjectives) { 506 diff /= NadirPoint[n] - IdealPoint[n]; 505 // deal with NaN and Infinity 506 var q = qualities[n]; 507 if (double.IsNaN(q) || double.IsInfinity(q)) { 508 q = NadirPoint[n]; 507 509 } 510 q -= IdealPoint[n]; 511 512 if (normalizeObjectives) { 513 q /= NadirPoint[n] - IdealPoint[n]; 514 } 515 508 516 var l = lambda[n].IsAlmost(0) ? 1e-4 : lambda[n]; 509 var feval = l * Math.Abs( diff);517 var feval = l * Math.Abs(q); 510 518 511 519 if (feval > maxFun) { … … 562 570 protected void UpdateParetoFronts() { 563 571 var qualities = population.Select(x => Enumerable.Range(0, NadirPoint.Length).Select(i => x.Qualities[i] / NadirPoint[i]).ToArray()).ToArray(); 564 var maximization = Enumerable.Repeat(false, IdealPoint.Length).ToArray(); // MOEA/D minimizes everything internally \572 var maximization = Enumerable.Repeat(false, IdealPoint.Length).ToArray(); // MOEA/D minimizes everything internally 565 573 var pf = DominationCalculator<IMOEADSolution>.CalculateBestParetoFront(population, qualities, maximization); 566 574 … … 638 646 } 639 647 var r = OnlinePearsonsRCalculator.Calculate(points.Select(x => x.X), points.Select(x => x.Y), out OnlineCalculatorError error); 640 if (error != OnlineCalculatorError.None) { r = double.NaN; }641 sp.Name = $"Pareto Front [{c[0]}, {c[1]}], correlation: {r .ToString("N2")}";648 var r2 = r * r; 649 sp.Name = $"Pareto Front [{c[0]}, {c[1]}], correlation: {r2.ToString("N2")}"; 642 650 } 643 651 } -
branches/2987_MOEAD_Algorithm/HeuristicLab.Algorithms.MOEAD/3.4/Plugin.cs.frame
r16560 r16657 35 35 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 36 [PluginDependency("HeuristicLab.Random", "3.3")] 37 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 38 [PluginDependency("HeuristicLab.Problems.TestFunctions.MultiObjective", "3.3")] 37 39 public class HeuristicLabAlgorithmsMOEADPlugin : PluginBase { 38 40 }
Note: See TracChangeset
for help on using the changeset viewer.