- Timestamp:
- 02/16/15 20:14:52 (10 years ago)
- Location:
- branches/ALPS
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS
- Property svn:mergeinfo changed
/stable merged: 12008-12010 /trunk/sources merged: 11978,11982-11984,11987-11994,11996,11998-12004,12012,12015-12016
- Property svn:mergeinfo changed
-
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs
r11669 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs
r11956 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 22 22 23 23 using System; 24 using HeuristicLab.Problems.BinaryVector; 24 using HeuristicLab.Common; 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.BinaryVectorEncoding; 28 using HeuristicLab.Parameters; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Problems.Binary; 25 31 26 32 namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid { … … 28 34 // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014 29 35 // 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; 32 38 33 39 private int maxEvaluations; … … 49 55 } 50 56 51 public bool[]BestSolution {57 public BinaryVector BestSolution { 52 58 get; 53 59 private set; … … 55 61 #endregion 56 62 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) { 58 78 this.problem = problem; 59 79 this.maxEvaluations = maxEvaluations; 60 BestSolution = new bool[0];80 BestSolution = new BinaryVector(Length); 61 81 BestQuality = double.NaN; 62 82 Evaluations = 0; 63 83 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 }); 64 87 } 65 88 66 public double Evaluate(bool[] individual) {89 public override double Evaluate(BinaryVector vector, IRandom random) { 67 90 if (Evaluations >= maxEvaluations) throw new OperationCanceledException("Maximum Evaluation Limit Reached"); 68 91 Evaluations++; 69 double fitness = problem.Evaluate( individual);92 double fitness = problem.Evaluate(vector, random); 70 93 if (double.IsNaN(BestQuality) || problem.IsBetter(fitness, BestQuality)) { 71 94 BestQuality = fitness; 72 BestSolution = ( bool[])individual.Clone();95 BestSolution = (BinaryVector)vector.Clone(); 73 96 BestFoundOnEvaluation = Evaluations; 74 97 } … … 76 99 } 77 100 78 #region ForwardedInteraface 79 public int Length { 101 public override int Length { 80 102 get { return problem.Length; } 103 set { problem.Length = value; } 81 104 } 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 } 84 111 } 112 85 113 public bool IsBetter(double quality, double bestQuality) { 86 114 return problem.IsBetter(quality, bestQuality); 87 115 } 88 #endregion 116 89 117 } 90 118 } -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.csproj
r11961 r12018 148 148 <Private>False</Private> 149 149 </ProjectReference> 150 <ProjectReference Include="..\..\HeuristicLab.Problems.Binary Vector\3.3\HeuristicLab.Problems.BinaryVector-3.3.csproj">150 <ProjectReference Include="..\..\HeuristicLab.Problems.Binary\3.3\HeuristicLab.Problems.Binary-3.3.csproj"> 151 151 <Project>{fc627be5-0f93-47d8-bd2e-530ea2b8aa5f}</Project> 152 <Name>HeuristicLab.Problems.Binary Vector-3.3</Name>152 <Name>HeuristicLab.Problems.Binary-3.3</Name> 153 153 <Private>False</Private> 154 154 </ProjectReference> … … 162 162 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 163 163 <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) 168 169 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> 170 178 </PropertyGroup> 171 179 <!-- 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 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 28 28 using HeuristicLab.Core; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.Encodings.BinaryVectorEncoding; 30 31 using HeuristicLab.Optimization; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.Problems.Binary Vector;34 using HeuristicLab.Problems.Binary; 34 35 using HeuristicLab.Random; 35 36 … … 49 50 50 51 public override Type ProblemType { 51 get { return typeof(Binary VectorProblem); }52 get { return typeof(BinaryProblem); } 52 53 } 53 public new Binary VectorProblem Problem {54 get { return (Binary VectorProblem)base.Problem; }54 public new BinaryProblem Problem { 55 get { return (BinaryProblem)base.Problem; } 55 56 set { base.Problem = value; } 56 57 } … … 83 84 Results.Add(new Result("Best quality", BestQuality)); 84 85 for (int iteration = 0; iteration < Iterations; iteration++) { 85 bool[] solution = new bool[Problem.Length];86 var solution = new BinaryVector(Problem.Length); 86 87 for (int i = 0; i < solution.Length; i++) { 87 88 solution[i] = random.Next(2) == 1; 88 89 } 89 90 90 var fitness = Problem.Evaluate(solution );91 var fitness = Problem.Evaluate(solution, random); 91 92 92 93 fitness = ImproveToLocalOptimum(Problem, solution, fitness, random); … … 97 98 } 98 99 // 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) { 100 101 var tried = new HashSet<int>(); 101 102 do { … … 104 105 if (tried.Contains(option)) continue; 105 106 solution[option] = !solution[option]; 106 double newFitness = problem.Evaluate(solution );107 double newFitness = problem.Evaluate(solution, rand); 107 108 if (problem.IsBetter(newFitness, fitness)) { 108 109 fitness = newFitness; -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs
r11956 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 23 23 using System.Linq; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Problems.BinaryVector; 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 using HeuristicLab.Problems.Binary; 26 27 using HeuristicLab.Random; 27 28 … … 32 33 public static class LinkageCrossover { 33 34 // 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) { 35 36 var options = Enumerable.Range(0, donors.Count).ToArray(); 36 37 foreach (var cluster in tree.Clusters) { … … 40 41 foreach (var donorIndex in options.ShuffleList(rand)) { 41 42 // 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); 43 44 if (donorFound) break; 44 45 } … … 47 48 } 48 49 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) { 50 51 // keep track of which bits flipped to make the donation 51 52 List<int> flipped = new List<int>(); … … 58 59 changed = flipped.Count > 0; 59 60 if (changed) { 60 double newFitness = problem.Evaluate(solution );61 double newFitness = problem.Evaluate(solution, rand); 61 62 // if the original is strictly better, revert the change 62 63 if (problem.IsBetter(fitness, newFitness)) { -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageTree.cs
r11939 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Encodings.BinaryVectorEncoding; 28 29 using HeuristicLab.Random; 29 30 … … 64 65 } 65 66 66 public void Add( bool[]solution) {67 public void Add(BinaryVector solution) { 67 68 if (solution.Length != length) throw new ArgumentException("The individual has not the correct length."); 68 69 for (int i = 1; i < solution.Length; i++) { -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs
r11960 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 32 32 using HeuristicLab.Parameters; 33 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 using HeuristicLab.Problems.Binary Vector;34 using HeuristicLab.Problems.Binary; 35 35 using HeuristicLab.Random; 36 36 … … 44 44 public class ParameterlessPopulationPyramid : BasicAlgorithm { 45 45 public override Type ProblemType { 46 get { return typeof(Binary VectorProblem); }47 } 48 public new Binary VectorProblem Problem {49 get { return (Binary VectorProblem)base.Problem; }46 get { return typeof(BinaryProblem); } 47 } 48 public new BinaryProblem Problem { 49 get { return (BinaryProblem)base.Problem; } 50 50 set { base.Problem = value; } 51 51 } … … 56 56 57 57 // 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()); 59 59 60 60 #region ParameterNames … … 179 179 } 180 180 181 private void AddIfUnique( bool[]solution, int level) {181 private void AddIfUnique(BinaryVector solution, int level) { 182 182 // Don't add things you have seen 183 183 if (seen.Contains(solution)) return; … … 185 185 pyramid.Add(new Population(tracker.Length, random)); 186 186 } 187 var copied = ( bool[])solution.Clone();187 var copied = (BinaryVector)solution.Clone(); 188 188 pyramid[level].Add(copied); 189 189 seen.Add(copied); … … 193 193 private double iterate() { 194 194 // Create a random solution 195 bool[] solution = new bool[tracker.Length];195 BinaryVector solution = new BinaryVector(tracker.Length); 196 196 for (int i = 0; i < solution.Length; i++) { 197 197 solution[i] = random.Next(2) == 1; 198 198 } 199 double fitness = tracker.Evaluate(solution );199 double fitness = tracker.Evaluate(solution, random); 200 200 fitness = HillClimber.ImproveToLocalOptimum(tracker, solution, fitness, random); 201 201 AddIfUnique(solution, 0); … … 249 249 fitness = iterate(); 250 250 cancellationToken.ThrowIfCancellationRequested(); 251 } 252 finally { 251 } finally { 253 252 ResultsEvaluations = tracker.Evaluations; 254 253 ResultsBestSolution = new BinaryVector(tracker.BestSolution); -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Plugin.cs.frame
r11956 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 /// Plugin class for HeuristicLab.Algorithms.ParameterlessPopulationPyramid plugin. 30 30 /// </summary> 31 [Plugin("HeuristicLab.Algorithms.ParameterlessPopulationPyramid", "3.3.1 0.$WCREV$")]31 [Plugin("HeuristicLab.Algorithms.ParameterlessPopulationPyramid", "3.3.11.$WCREV$")] 32 32 [PluginFile("HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.dll", PluginFileType.Assembly)] 33 33 [PluginDependency("HeuristicLab.Analysis", "3.3")] … … 40 40 [PluginDependency("HeuristicLab.Parameters", "3.3")] 41 41 [PluginDependency("HeuristicLab.Persistence", "3.3")] 42 [PluginDependency("HeuristicLab.Problems.Binary Vector", "3.3")]42 [PluginDependency("HeuristicLab.Problems.Binary", "3.3")] 43 43 [PluginDependency("HeuristicLab.Random", "3.3")] 44 44 public class Plugin : PluginBase { -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Population.cs
r11838 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * and the BEACON Center for the Study of Evolution in Action. 5 5 * … … 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 25 26 26 27 namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid { … … 29 30 // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid 30 31 public class Population { 31 public List< bool[]> Solutions {32 public List<BinaryVector> Solutions { 32 33 get; 33 34 private set; … … 40 41 41 42 public Population(int length, IRandom rand) { 42 Solutions = new List< bool[]>();43 Solutions = new List<BinaryVector>(); 43 44 Tree = new LinkageTree(length, rand); 44 45 } 45 public void Add( bool[]solution) {46 public void Add(BinaryVector solution) { 46 47 Solutions.Add(solution); 47 48 Tree.Add(solution); -
branches/ALPS/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Properties/AssemblyInfo.cs.frame
r11632 r12018 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 // set of attributes. Change these attribute values to modify the information 28 28 // 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.")] 31 31 [assembly: AssemblyConfiguration("")] 32 [assembly: AssemblyCompany(" ")]32 [assembly: AssemblyCompany("HEAL")] 33 33 [assembly: AssemblyProduct("HeuristicLab")] 34 [assembly: AssemblyCopyright("(c) 2002-201 4 HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2015 HEAL and BEACON Center for the Study of Evolution in Action")] 35 35 [assembly: AssemblyTrademark("")] 36 36 [assembly: AssemblyCulture("")] … … 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.1 0.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.11.$WCREV$")]
Note: See TracChangeset
for help on using the changeset viewer.