Changeset 14527


Ignore:
Timestamp:
12/23/16 16:13:11 (3 years ago)
Author:
jkarder
Message:

#2524:

  • made sure that P3 results are updated after cancellation
  • fixed unit tests to also call Initialize
Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r14523 r14527  
    250250      // Loop until iteration limit reached or canceled.
    251251      while (ResultsIterations < MaximumIterations) {
    252         cancellationToken.ThrowIfCancellationRequested();
    253         double fitness = iterate();
    254 
    255         ResultsEvaluations = tracker.Evaluations;
    256         ResultsBestSolution = new BinaryVector(tracker.BestSolution);
    257         ResultsBestQuality = tracker.BestQuality;
    258         ResultsBestFoundOnEvaluation = tracker.BestFoundOnEvaluation;
    259         ResultsQualitiesBest.Values.Add(tracker.BestQuality);
    260         ResultsQualitiesIteration.Values.Add(fitness);
    261         ResultsLevels.Values.Add(pyramid.Count);
    262         ResultsSolutions.Values.Add(seen.Count);
    263 
    264         ResultsIterations++;
     252        double fitness = double.NaN;
     253
     254        try {
     255          fitness = iterate();
     256          ResultsIterations++;
     257          cancellationToken.ThrowIfCancellationRequested();
     258        } finally {
     259          ResultsEvaluations = tracker.Evaluations;
     260          ResultsBestSolution = new BinaryVector(tracker.BestSolution);
     261          ResultsBestQuality = tracker.BestQuality;
     262          ResultsBestFoundOnEvaluation = tracker.BestFoundOnEvaluation;
     263          ResultsQualitiesBest.Values.Add(tracker.BestQuality);
     264          ResultsQualitiesIteration.Values.Add(fitness);
     265          ResultsLevels.Values.Add(pyramid.Count);
     266          ResultsSolutions.Values.Add(seen.Count);
     267        }
    265268      }
    266269    }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3/ParameterlessPopulationPyramidTest.cs

    r14185 r14527  
    3939      PrivateObject hidden = new PrivateObject(solver);
    4040      try {
    41         hidden.Invoke("Run", new CancellationToken());
     41        var ct = new CancellationToken();
     42        hidden.Invoke("Initialize", ct);
     43        hidden.Invoke("Run", ct);
    4244      } catch (OperationCanceledException) {
    4345        // Ignore
Note: See TracChangeset for help on using the changeset viewer.