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:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS

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

    r11669 r12018  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs

    r11956 r12018  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 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 *
     
    2222
    2323using System;
    24 using HeuristicLab.Problems.BinaryVector;
     24using HeuristicLab.Common;
     25using HeuristicLab.Core;
     26using HeuristicLab.Data;
     27using HeuristicLab.Encodings.BinaryVectorEncoding;
     28using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.Binary;
    2531
    2632namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid {
     
    2834  // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014
    2935  // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid
    30   public class EvaluationTracker : IBinaryVectorProblem {
    31     private readonly IBinaryVectorProblem problem;
     36  internal sealed class EvaluationTracker : BinaryProblem {
     37    private readonly BinaryProblem problem;
    3238
    3339    private int maxEvaluations;
     
    4955    }
    5056
    51     public bool[] BestSolution {
     57    public BinaryVector BestSolution {
    5258      get;
    5359      private set;
     
    5561    #endregion
    5662
    57     public EvaluationTracker(IBinaryVectorProblem problem, int maxEvaluations) {
     63    [StorableConstructor]
     64    private EvaluationTracker(bool deserializing) : base(deserializing) { }
     65    private EvaluationTracker(EvaluationTracker original, Cloner cloner)
     66      : base(original, cloner) {
     67      problem = cloner.Clone(original.problem);
     68      maxEvaluations = original.maxEvaluations;
     69      BestQuality = original.BestQuality;
     70      Evaluations = original.Evaluations;
     71      BestFoundOnEvaluation = original.BestFoundOnEvaluation;
     72      BestSolution = cloner.Clone(BestSolution);
     73    }
     74    public override IDeepCloneable Clone(Cloner cloner) {
     75      return new EvaluationTracker(this, cloner);
     76    }
     77    public EvaluationTracker(BinaryProblem problem, int maxEvaluations) {
    5878      this.problem = problem;
    5979      this.maxEvaluations = maxEvaluations;
    60       BestSolution = new bool[0];
     80      BestSolution = new BinaryVector(Length);
    6181      BestQuality = double.NaN;
    6282      Evaluations = 0;
    6383      BestFoundOnEvaluation = 0;
     84
     85      if (Parameters.ContainsKey("Maximization")) Parameters.Remove("Maximization");
     86      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    6487    }
    6588
    66     public double Evaluate(bool[] individual) {
     89    public override double Evaluate(BinaryVector vector, IRandom random) {
    6790      if (Evaluations >= maxEvaluations) throw new OperationCanceledException("Maximum Evaluation Limit Reached");
    6891      Evaluations++;
    69       double fitness = problem.Evaluate(individual);
     92      double fitness = problem.Evaluate(vector, random);
    7093      if (double.IsNaN(BestQuality) || problem.IsBetter(fitness, BestQuality)) {
    7194        BestQuality = fitness;
    72         BestSolution = (bool[])individual.Clone();
     95        BestSolution = (BinaryVector)vector.Clone();
    7396        BestFoundOnEvaluation = Evaluations;
    7497      }
     
    7699    }
    77100
    78     #region ForwardedInteraface
    79     public int Length {
     101    public override int Length {
    80102      get { return problem.Length; }
     103      set { problem.Length = value; }
    81104    }
    82     public bool Maximization {
    83       get { return problem.Maximization; }
     105
     106    public override bool Maximization {
     107      get {
     108        if (problem == null) return false;
     109        return problem.Maximization;
     110      }
    84111    }
     112
    85113    public bool IsBetter(double quality, double bestQuality) {
    86114      return problem.IsBetter(quality, bestQuality);
    87115    }
    88     #endregion
     116
    89117  }
    90118}
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.csproj

    r11961 r12018  
    148148      <Private>False</Private>
    149149    </ProjectReference>
    150     <ProjectReference Include="..\..\HeuristicLab.Problems.BinaryVector\3.3\HeuristicLab.Problems.BinaryVector-3.3.csproj">
     150    <ProjectReference Include="..\..\HeuristicLab.Problems.Binary\3.3\HeuristicLab.Problems.Binary-3.3.csproj">
    151151      <Project>{fc627be5-0f93-47d8-bd2e-530ea2b8aa5f}</Project>
    152       <Name>HeuristicLab.Problems.BinaryVector-3.3</Name>
     152      <Name>HeuristicLab.Problems.Binary-3.3</Name>
    153153      <Private>False</Private>
    154154    </ProjectReference>
     
    162162  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    163163  <PropertyGroup>
    164     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    165 set ProjectDir=$(ProjectDir)
    166 set SolutionDir=$(SolutionDir)
    167 set Outdir=$(Outdir)
     164    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
     165      set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     166      set ProjectDir=$(ProjectDir)
     167      set SolutionDir=$(SolutionDir)
     168      set Outdir=$(Outdir)
    168169
    169 call PreBuildEvent.cmd</PreBuildEvent>
     170      call PreBuildEvent.cmd
     171    </PreBuildEvent>
     172    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     173      export ProjectDir=$(ProjectDir)
     174      export SolutionDir=$(SolutionDir)
     175
     176      $SolutionDir/PreBuildEvent.sh
     177    </PreBuildEvent>
    170178  </PropertyGroup>
    171179  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.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 *
     
    2828using HeuristicLab.Core;
    2929using HeuristicLab.Data;
     30using HeuristicLab.Encodings.BinaryVectorEncoding;
    3031using HeuristicLab.Optimization;
    3132using HeuristicLab.Parameters;
    3233using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    33 using HeuristicLab.Problems.BinaryVector;
     34using HeuristicLab.Problems.Binary;
    3435using HeuristicLab.Random;
    3536
     
    4950
    5051    public override Type ProblemType {
    51       get { return typeof(BinaryVectorProblem); }
     52      get { return typeof(BinaryProblem); }
    5253    }
    53     public new BinaryVectorProblem Problem {
    54       get { return (BinaryVectorProblem)base.Problem; }
     54    public new BinaryProblem Problem {
     55      get { return (BinaryProblem)base.Problem; }
    5556      set { base.Problem = value; }
    5657    }
     
    8384      Results.Add(new Result("Best quality", BestQuality));
    8485      for (int iteration = 0; iteration < Iterations; iteration++) {
    85         bool[] solution = new bool[Problem.Length];
     86        var solution = new BinaryVector(Problem.Length);
    8687        for (int i = 0; i < solution.Length; i++) {
    8788          solution[i] = random.Next(2) == 1;
    8889        }
    8990
    90         var fitness = Problem.Evaluate(solution);
     91        var fitness = Problem.Evaluate(solution, random);
    9192
    9293        fitness = ImproveToLocalOptimum(Problem, solution, fitness, random);
     
    9798    }
    9899    // In the GECCO paper, Section 2.1
    99     public static double ImproveToLocalOptimum(IBinaryVectorProblem problem, bool[] solution, double fitness, IRandom rand) {
     100    public static double ImproveToLocalOptimum(BinaryProblem problem, BinaryVector solution, double fitness, IRandom rand) {
    100101      var tried = new HashSet<int>();
    101102      do {
     
    104105          if (tried.Contains(option)) continue;
    105106          solution[option] = !solution[option];
    106           double newFitness = problem.Evaluate(solution);
     107          double newFitness = problem.Evaluate(solution, rand);
    107108          if (problem.IsBetter(newFitness, fitness)) {
    108109            fitness = newFitness;
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs

    r11956 r12018  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 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 *
     
    2323using System.Linq;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Problems.BinaryVector;
     25using HeuristicLab.Encodings.BinaryVectorEncoding;
     26using HeuristicLab.Problems.Binary;
    2627using HeuristicLab.Random;
    2728
     
    3233  public static class LinkageCrossover {
    3334    // In the GECCO paper, Figure 3
    34     public static double ImproveUsingTree(LinkageTree tree, IList<bool[]> donors, bool[] solution, double fitness, IBinaryVectorProblem problem, IRandom rand) {
     35    public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, BinaryProblem problem, IRandom rand) {
    3536      var options = Enumerable.Range(0, donors.Count).ToArray();
    3637      foreach (var cluster in tree.Clusters) {
     
    4041        foreach (var donorIndex in options.ShuffleList(rand)) {
    4142          // Attempt the donation
    42           fitness = Donate(solution, fitness, donors[donorIndex], cluster, problem, out donorFound);
     43          fitness = Donate(solution, fitness, donors[donorIndex], cluster, problem, rand, out donorFound);
    4344          if (donorFound) break;
    4445        }
     
    4748    }
    4849
    49     private static double Donate(bool[] solution, double fitness, bool[] source, IEnumerable<int> cluster, IBinaryVectorProblem problem, out bool changed) {
     50    private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, BinaryProblem problem, IRandom rand, out bool changed) {
    5051      // keep track of which bits flipped to make the donation
    5152      List<int> flipped = new List<int>();
     
    5859      changed = flipped.Count > 0;
    5960      if (changed) {
    60         double newFitness = problem.Evaluate(solution);
     61        double newFitness = problem.Evaluate(solution, rand);
    6162        // if the original is strictly better, revert the change
    6263        if (problem.IsBetter(fitness, newFitness)) {
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageTree.cs

    r11939 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 *
     
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Encodings.BinaryVectorEncoding;
    2829using HeuristicLab.Random;
    2930
     
    6465    }
    6566
    66     public void Add(bool[] solution) {
     67    public void Add(BinaryVector solution) {
    6768      if (solution.Length != length) throw new ArgumentException("The individual has not the correct length.");
    6869      for (int i = 1; i < solution.Length; i++) {
  • 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);
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Plugin.cs.frame

    r11956 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 *
    55 * This file is part of HeuristicLab.
     
    2929  /// Plugin class for HeuristicLab.Algorithms.ParameterlessPopulationPyramid plugin.
    3030  /// </summary>
    31   [Plugin("HeuristicLab.Algorithms.ParameterlessPopulationPyramid", "3.3.10.$WCREV$")]
     31  [Plugin("HeuristicLab.Algorithms.ParameterlessPopulationPyramid", "3.3.11.$WCREV$")]
    3232  [PluginFile("HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.dll", PluginFileType.Assembly)]
    3333  [PluginDependency("HeuristicLab.Analysis", "3.3")]
     
    4040  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4141  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    42   [PluginDependency("HeuristicLab.Problems.BinaryVector", "3.3")]
     42  [PluginDependency("HeuristicLab.Problems.Binary", "3.3")]
    4343  [PluginDependency("HeuristicLab.Random", "3.3")]
    4444  public class Plugin : PluginBase {
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Population.cs

    r11838 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 *
     
    2323using System.Collections.Generic;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.BinaryVectorEncoding;
    2526
    2627namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid {
     
    2930  // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid
    3031  public class Population {
    31     public List<bool[]> Solutions {
     32    public List<BinaryVector> Solutions {
    3233      get;
    3334      private set;
     
    4041
    4142    public Population(int length, IRandom rand) {
    42       Solutions = new List<bool[]>();
     43      Solutions = new List<BinaryVector>();
    4344      Tree = new LinkageTree(length, rand);
    4445    }
    45     public void Add(bool[] solution) {
     46    public void Add(BinaryVector solution) {
    4647      Solutions.Add(solution);
    4748      Tree.Add(solution);
  • branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Properties/AssemblyInfo.cs.frame

    r11632 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 *
    55 * This file is part of HeuristicLab.
     
    2727// set of attributes. Change these attribute values to modify the information
    2828// associated with an assembly.
    29 [assembly: AssemblyTitle("HeuristicLab.Core")]
    30 [assembly: AssemblyDescription("HeuristicLab core classes")]
     29[assembly: AssemblyTitle("HeuristicLab.Algorithms.ParameterlessPopulationPyramid")]
     30[assembly: AssemblyDescription("Binary value optimization algorithm which requires no configuration.")]
    3131[assembly: AssemblyConfiguration("")]
    32 [assembly: AssemblyCompany("")]
     32[assembly: AssemblyCompany("HEAL")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2014 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2015 HEAL and BEACON Center for the Study of Evolution in Action")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
     
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.10.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.11.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.