Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/15 20:14:52 (10 years ago)
Author:
pfleck
Message:

#2269

  • merged trunk after 3.3.11 release
  • updated copyright and plugin version in ALPS plugin
  • removed old ALPS samples based on an userdefined alg
Location:
branches/ALPS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS

  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r11960 r12018  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 * and the BEACON Center for the Study of Evolution in Action.
    55 *
     
    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.