Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17668


Ignore:
Timestamp:
07/14/20 20:28:33 (4 years ago)
Author:
dleko
Message:

#2825 Bugfix.

Location:
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs

    r17667 r17668  
    219219            base.Initialize(cancellationToken);
    220220
    221             int pop = ReferencePoint.GetNumberOfGeneratedReferencePoints(NumberOfObjectives);
     221            int numberOfGeneratedReferencePoints = ReferencePoint.GetNumberOfGeneratedReferencePoints(NumberOfObjectives);
     222            int pop = ((numberOfGeneratedReferencePoints + 3) / 4) * 4;
    222223            PopulationSize.Value = pop;
    223224            InitResults();
     225            InitFields();
    224226            InitReferencePoints();
    225             InitFields();
    226227            Analyze();
    227228        }
     
    260261            Results.Add(new Result(GeneratedReferencePointsResultName, "The initially generated reference points", new DoubleMatrix()));
    261262            Results.Add(new Result(CurrentFrontResultName, "The Pareto Front", new DoubleMatrix()));
    262             Results.Add(new Result(CurrentGenerationResultName, "The current generation", new IntValue(0)));
     263            Results.Add(new Result(CurrentGenerationResultName, "The current generation", new IntValue(1)));
    263264        }
    264265
     
    274275                // the next generation) maybe todo: use cloner?
    275276
    276                 List<Solution> qt = Mutate(Recombine(solutions));
    277                 List<Solution> rt = Utility.Concat(solutions, qt);
    278 
    279                 solutions = NSGA3Selection.SelectSolutionsForNextGeneration(rt, GetCopyOfReferencePoints(), Problem.Maximization, random);
    280 
    281                 ResultsCurrentGeneration.Value++;
     277                try
     278                {
     279                    List<Solution> qt = Mutate(Recombine(solutions));
     280                    List<Solution> rt = Utility.Concat(solutions, qt);
     281
     282                    solutions = NSGA3Selection.SelectSolutionsForNextGeneration(rt, GetCopyOfReferencePoints(), Problem.Maximization, random);
     283
     284                    ResultsCurrentGeneration.Value++;
     285                }
     286                catch (Exception ex)
     287                {
     288                    throw new Exception($"Failed in generation {ResultsCurrentGeneration}", ex);
     289                }
    282290            }
    283291        }
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3Selection.cs

    r17665 r17668  
    3838                lf = i;
    3939            }
     40            // remove useless fronts
     41            fronts.RemoveRange(lf + 1, fronts.Count - lf - 1);
    4042
    4143            List<Solution> nextGeneration = new List<Solution>();
     
    4648                // Add every front to the next generation list except for the one that is added only partially
    4749                nextGeneration = new List<Solution>();
    48                 for (int f = 0; f < lf - 1; f++)
     50                for (int f = 0; f < lf; f++)
    4951                    nextGeneration = Utility.Concat(nextGeneration, fronts[f]);
    5052                int k = N - nextGeneration.Count;
     
    109111                }
    110112            }
    111             // todo: delete this
    112             //for (int f = 0; f < Fronts.Count; f++)
    113             //{
    114             //    foreach (var solution in Fronts[f])
    115             //    {
    116             //        for (int i = 0; i < NumberOfObjectives; i++)
    117             //        {
    118             //            if (Math.Abs(intercepts[i] - idealPoint[i]) > EPSILON)
    119             //            {
    120             //                solution.Fitness[i] = solution.Fitness[i] / (intercepts[i] - idealPoint[i]);
    121             //            }
    122             //            else
    123             //            {
    124             //                solution.Fitness[i] = solution.Fitness[i] / EPSILON;
    125             //            }
    126             //        }
    127             //    }
    128             //}
    129113        }
    130114
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/ReferencePoint.cs

    r17667 r17668  
    8989            int outerPoints = Utility.NCR(nDim + outerDiv - 1, outerDiv);
    9090            int innerPoints = innerDiv == 0 ? 0 : Utility.NCR(nDim + innerDiv - 1, innerDiv);
    91             int nRefPoints = outerPoints + innerPoints;
    92             return nRefPoints;
     91            return outerPoints + innerPoints;
    9392        }
    9493
Note: See TracChangeset for help on using the changeset viewer.