Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/12/15 15:39:28 (9 years ago)
Author:
abeham
Message:

#2282:

  • Renamed BinaryVectorProblem to BinaryProblem
  • Removed IBinaryVectorProblem interface
  • Derived BinaryProblem from SingleObjectiveBasicProblem
  • Changed bool[] datatype to BinaryVector
File:
1 edited

Legend:

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

    r11960 r11987  
    3232using HeuristicLab.Parameters;
    3333using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    34 using HeuristicLab.Problems.BinaryVector;
     34using HeuristicLab.Problems.Binary;
    3535using HeuristicLab.Random;
    3636
     
    4444  public class ParameterlessPopulationPyramid : BasicAlgorithm {
    4545    public override Type ProblemType {
    46       get { return typeof(BinaryVectorProblem); }
    47     }
    48     public new BinaryVectorProblem Problem {
    49       get { return (BinaryVectorProblem)base.Problem; }
     46      get { return typeof(BinaryProblem); }
     47    }
     48    public new BinaryProblem Problem {
     49      get { return (BinaryProblem)base.Problem; }
    5050      set { base.Problem = value; }
    5151    }
     
    5656
    5757    // Tracks all solutions in Pyramid for quick membership checks
    58     private HashSet<bool[]> seen = new HashSet<bool[]>(new EnumerableBoolEqualityComparer());
     58    private HashSet<BinaryVector> seen = new HashSet<BinaryVector>(new EnumerableBoolEqualityComparer());
    5959
    6060    #region ParameterNames
     
    179179    }
    180180
    181     private void AddIfUnique(bool[] solution, int level) {
     181    private void AddIfUnique(BinaryVector solution, int level) {
    182182      // Don't add things you have seen
    183183      if (seen.Contains(solution)) return;
     
    185185        pyramid.Add(new Population(tracker.Length, random));
    186186      }
    187       var copied = (bool[])solution.Clone();
     187      var copied = (BinaryVector)solution.Clone();
    188188      pyramid[level].Add(copied);
    189189      seen.Add(copied);
     
    193193    private double iterate() {
    194194      // Create a random solution
    195       bool[] solution = new bool[tracker.Length];
     195      BinaryVector solution = new BinaryVector(tracker.Length);
    196196      for (int i = 0; i < solution.Length; i++) {
    197197        solution[i] = random.Next(2) == 1;
    198198      }
    199       double fitness = tracker.Evaluate(solution);
     199      double fitness = tracker.Evaluate(solution, random);
    200200      fitness = HillClimber.ImproveToLocalOptimum(tracker, solution, fitness, random);
    201201      AddIfUnique(solution, 0);
     
    249249          fitness = iterate();
    250250          cancellationToken.ThrowIfCancellationRequested();
    251         }
    252         finally {
     251        } finally {
    253252          ResultsEvaluations = tracker.Evaluations;
    254253          ResultsBestSolution = new BinaryVector(tracker.BestSolution);
Note: See TracChangeset for help on using the changeset viewer.