Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7756


Ignore:
Timestamp:
04/24/12 14:22:32 (12 years ago)
Author:
jkarder
Message:

#1331:

  • added path relinking and problem specific operators (KnapsackPathRelinker, TravelingSalesmanPathRelinker) for it
  • adjusted event handling
  • minor code improvements
Location:
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/HeuristicLab.Algorithms.ScatterSearch-3.3.csproj

    r7744 r7756  
    8787  <ItemGroup>
    8888    <Compile Include="DiversityCalculator.cs" />
     89    <Compile Include="IPathRelinker.cs" />
    8990    <Compile Include="Knapsack\BinaryVectorDiversityCalculator.cs" />
     91    <Compile Include="Knapsack\KnapsackPathRelinker.cs" />
     92    <Compile Include="TravelingSalesman\TravelingSalesmanPathRelinker.cs" />
     93    <Compile Include="PathRelinker.cs" />
    9094    <Compile Include="Knapsack\INBinaryVectorCrossover.cs" />
    9195    <Compile Include="IScatterSearchTargetProcessor.cs" />
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/BinaryVectorDiversityCalculator.cs

    r7744 r7756  
    3131  [Item("BinaryVectorDiversityCalculator", "An operator that performs diversity calculation between bool-valued vectors.")]
    3232  [StorableClass]
    33   public sealed class BinaryVectorDiversityCalculator : HeuristicLab.Algorithms.ScatterSearch.DiversityCalculator {
     33  public sealed class BinaryVectorDiversityCalculator : DiversityCalculator {
    3434    [StorableConstructor]
    3535    private BinaryVectorDiversityCalculator(bool deserializing) : base(deserializing) { }
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/KnapsackImprovementOperator.cs

    r7744 r7756  
    3939  [StorableClass]
    4040  public sealed class KnapsackImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator, IScatterSearchTargetProcessor {
    41 
    4241    #region Problem properties
    4342    public Type ProblemType {
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/NBinaryVectorCrossover.cs

    r7744 r7756  
    6464      #region Create parameters
    6565      Parameters.Add(new ScopeParameter("CurrentScope"));
    66       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic crossover operators."));
    67       Parameters.Add(new ScopeTreeLookupParameter<BinaryVector>("Parents", "The parent vectors which should be crossed."));
     66      Parameters.Add(new LookupParameter<IRandom>("Random"));
     67      Parameters.Add(new ScopeTreeLookupParameter<BinaryVector>("Parents"));
    6868      #endregion
    6969      ParentsParameter.ActualName = "BinaryVector";
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/NChildCrossover.cs

    r7744 r7756  
    7878
    7979    protected override ItemArray<BinaryVector> Cross(IRandom random, ItemArray<BinaryVector> parents) {
    80       if (parents.Length != 2) throw new ArgumentException("ERROR in NChildCrossover: The number of parents is not equal to 2");
     80      if (parents.Length != 2) throw new ArgumentException("NChildCrossover: The number of parents is not equal to 2.");
    8181
    8282      if (NParameter.ActualValue == null) throw new InvalidOperationException("NChildCrossover: Parameter " + NParameter.ActualName + " could not be found.");
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs

    r7744 r7756  
    306306      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
    307307
     308      CrossoverParameter.ValidValues.Add(new TravelingSalesman.TravelingSalesmanPathRelinker());
     309      CrossoverParameter.ValidValues.Add(new Knapsack.KnapsackPathRelinker());
     310
    308311      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
    309312        CrossoverParameter.ValidValues.Add(crossover);
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/TravelingSalesman/PermutationDiversityCalculator.cs

    r7744 r7756  
    3232  [Item("PermutationDiversityCalculator", "An operator that performs diversity calculation between permutations.")]
    3333  [StorableClass]
    34   public sealed class PermutationDiversityCalculator : HeuristicLab.Algorithms.ScatterSearch.DiversityCalculator {
     34  public sealed class PermutationDiversityCalculator : DiversityCalculator {
    3535    [StorableConstructor]
    3636    private PermutationDiversityCalculator(bool deserializing) : base(deserializing) { }
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/TravelingSalesman/TravelingSalesmanImprovementOperator.cs

    r7744 r7756  
    3939  [StorableClass]
    4040  public sealed class TravelingSalesmanImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator, IScatterSearchTargetProcessor {
    41 
    4241    #region Problem properties
    4342    public Type ProblemType {
     
    6261      get { return (IValueLookupParameter<IEvaluator>)Parameters["Evaluator"]; }
    6362    }
    64     public IValueLookupParameter<IntValue> ImprovementIterationsParameter {
    65       get { return (IValueLookupParameter<IntValue>)Parameters["ImprovementIterations"]; }
     63    public IValueLookupParameter<IntValue> ImprovementAttemptsParameter {
     64      get { return (IValueLookupParameter<IntValue>)Parameters["ImprovementAttempts"]; }
    6665    }
    6766    public IValueLookupParameter<IRandom> RandomParameter {
     
    9695      set { EvaluatorParameter.ActualValue = value; }
    9796    }
    98     public IntValue ImprovementIterations {
    99       get { return ImprovementIterationsParameter.ActualValue; }
    100       set { ImprovementIterationsParameter.ActualValue = value; }
     97    public IntValue ImprovementAttempts {
     98      get { return ImprovementAttemptsParameter.ActualValue; }
     99      set { ImprovementAttemptsParameter.ActualValue = value; }
    101100    }
    102101    public IRandom Random {
     
    118117      : base() {
    119118      #region Create parameters
    120       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope."));
    121       Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    122       Parameters.Add(new ValueLookupParameter<IEvaluator>("Evaluator", "The operator which is used to evaluate new solutions."));
    123       Parameters.Add(new ValueLookupParameter<IntValue>("ImprovementIterations", "The number of improvement attempts."));
    124       Parameters.Add(new ValueLookupParameter<IRandom>("Random", "..."));
     119      Parameters.Add(new ScopeParameter("CurrentScope"));
     120      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Coordinates"));
     121      Parameters.Add(new ValueLookupParameter<IEvaluator>("Evaluator"));
     122      Parameters.Add(new ValueLookupParameter<IntValue>("ImprovementAttempts", new IntValue(100)));
     123      Parameters.Add(new ValueLookupParameter<IRandom>("Random"));
    125124      Parameters.Add(new ValueLookupParameter<IItem>("Target"));
    126125      #endregion
     
    138137      double bestLength = currLength;
    139138
    140       for (int i = 0; i < ImprovementIterations.Value; i++) {
     139      for (int i = 0; i < ImprovementAttempts.Value; i++) {
    141140        int a = Random.Next(currSol.Length - 1);
    142141        int b = Random.Next(currSol.Length - 1);
Note: See TracChangeset for help on using the changeset viewer.