Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/06/14 16:58:02 (10 years ago)
Author:
bgoldman
Message:

#2282 Major bug fixes, now gets answers close to correct.

Location:
branches/Parameter-less Population Pyramid
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Parameter-less Population Pyramid/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.csproj

    r11666 r11667  
    104104  <ItemGroup>
    105105    <Compile Include="AlgorithmBase.cs" />
     106    <Compile Include="EnumerableBoolEqualityComparer.cs" />
    106107    <Compile Include="LinkageCrossover.cs" />
     108    <Compile Include="Plugin.cs" />
    107109    <Compile Include="Problems\DeceptiveTrapProblem.cs" />
    108110    <Compile Include="HillClimber.cs" />
     
    111113    <Compile Include="Population.cs" />
    112114    <Compile Include="Problems\BinaryVectorProblem.cs" />
    113     <Compile Include="Plugin.cs" />
    114115    <Compile Include="Problems\EvaluationTracker.cs" />
    115116    <Compile Include="Problems\HIFFProblem.cs" />
  • branches/Parameter-less Population Pyramid/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs

    r11666 r11667  
    5757      if (changed) {
    5858        double newFitness = problem.Evaluate(solution);
    59         if (problem.IsBetter(newFitness, fitness)) {
    60           // improvement made, keep change to solution
    61           fitness = newFitness;
    62         } else {
    63           // revert solution
     59        // if the original is strictly better, revert the change
     60        if (problem.IsBetter(fitness, newFitness)) {
    6461          foreach (var index in flipped) {
    6562            solution[index] = !solution[index];
    6663          }
     64        } else {
     65          // new solution is no worse than original, keep change to solution
     66          fitness = newFitness;
    6767        }
    6868      }
  • branches/Parameter-less Population Pyramid/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageTree.cs

    r11666 r11667  
    5252        // Swap element "i" with a random earlier element (including itself)
    5353        int swapIndex = random.Next(i + 1);
    54         yield return source[swapIndex];
    55         source[swapIndex] = source[i];
    56         // we don't actually perform the swap, we can forget about the
    57         // swapped element because we already returned it.
     54        source.Swap(i, swapIndex);
     55        yield return source[i];
    5856      }
    5957      yield return source[0];
     
    148146      var topLevel = Enumerable.Range(0, length).ToList();
    149147      bool[] useful = Enumerable.Repeat(true, clusters.Length).ToArray();
    150 
    151148
    152149      // Store the distances between all clusters
  • branches/Parameter-less Population Pyramid/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r11666 r11667  
    3939  [StorableClass]
    4040  [Creatable("Parameterless Population Pyramid")]
    41  
     41
    4242  public class ParameterlessPopulationPyramid : AlgorithmBase {
    4343    private readonly IRandom random = new MersenneTwister();
     
    4646
    4747    // Tracks all solutions in Pyramid for quick membership checks
    48     private readonly HashSet<bool[]> seen = new HashSet<bool[]>();
     48    private HashSet<bool[]> seen = new HashSet<bool[]>(new EnumerableBoolEqualityComparer());
    4949
    5050    private const string MaximumIterationsParameterName = "Maximum Iterations";
     
    5353      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumIterationsParameterName]; }
    5454    }
    55    
     55
    5656    public int MaximumIterations {
    5757      get { return MaximumIterationsParameter.Value.Value; }
     
    7070    }
    7171
    72    
     72
    7373    private const string SeedParameterName = "Seed";
    7474
     
    149149    }
    150150
    151 
    152151    private void AddIfUnique(bool[] solution, int level) {
    153152      // Don't add things you have seen
     
    156155        pyramid.Add(new Population(tracker.Length, random));
    157156      }
    158       pyramid[level].Add(solution);
    159       seen.Add(solution);
     157      var copied = (bool[])solution.Clone();
     158      pyramid[level].Add(copied);
     159      seen.Add(copied);
    160160    }
    161161
     
    169169      fitness = HillClimber.ImproveToLocalOptimum(tracker, solution, fitness, random);
    170170      AddIfUnique(solution, 0);
     171
    171172      for (int level = 0; level < pyramid.Count; level++) {
    172173        var current = pyramid[level];
     
    184185      if (SetSeedRandomly) Seed = new System.Random().Next();
    185186      pyramid = new List<Population>();
     187      seen.Clear();
    186188      random.Reset(Seed);
    187189      tracker = new EvaluationTracker(Problem, MaximumEvaluations);
     
    213215          ResultsQualitiesBest.Values.Add(tracker.BestQuality);
    214216          ResultsQualitiesIteration.Values.Add(fitness);
    215         }       
     217        }
    216218      }
    217219    }
  • branches/Parameter-less Population Pyramid/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Plugin.cs.frame

    r11632 r11667  
    3131  [Plugin("HeuristicLab.Algorithms.ParameterlessPopulationPyramid", "3.3.10.$WCREV$")]
    3232  [PluginFile("HeuristicLab.Algorithms.ParameterlessPopulationPyramid-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3334  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3435  [PluginDependency("HeuristicLab.Common", "3.3")]
    3536  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     37  [PluginDependency("HeuristicLab.Core", "3.3")]
     38  [PluginDependency("HeuristicLab.Data", "3.3")]
     39  [PluginDependency("HeuristicLab.Encodings.BinaryVectorEncoding", "3.3")]
     40  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     41  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3642  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     43  [PluginDependency("HeuristicLab.Random", "3.3")]
    3744  public class Plugin : PluginBase {
    3845  }
  • branches/Parameter-less Population Pyramid/ParameterlessPopulationPyramid.Test/ParameterlessPopulationPyramid.Test.csproj

    r11656 r11667  
    6363  </Choose>
    6464  <ItemGroup>
     65    <Compile Include="EnumerableBoolEqualityComparerTest.cs" />
    6566    <Compile Include="LinkageTreeTest.cs" />
    6667    <Compile Include="Properties\AssemblyInfo.cs" />
Note: See TracChangeset for help on using the changeset viewer.