Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/15 23:38:51 (8 years ago)
Author:
abeham
Message:

#2221:

  • Completely refactored PTSP branch
    • Added two sets of problem instances based on TSPLIB: homogeneous and heterogeneous
    • Implemented missing EvaluateByCoordinates for 1-shift moves
    • Made it clear that move evaluators are for estimated PTSP only
    • Changed parameter realization from a rather strange list of list of ints to a list of bool arrays
    • Reusing code of the 2-opt and 1-shift move evaluators in 2.5 move evaluator
    • Introducing distance calculators to properly handle the case when no distance matrix is given (previous code only worked with distance matrix and without only with euclidean distance in some settings)
    • Fixed several smaller code issues: protected, static, method parameters, copy & paste, interfaces, naming, parameters, serialization hooks, license headers, doc comments, data types
File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Moves/TwoPointFiveOpt/StochasticTwoPointFiveSingleMoveGenerator.cs

    r13408 r13412  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.Optimization;
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Operators;
    29 using HeuristicLab.Encodings.PermutationEncoding;
    30 
    3129
    3230namespace HeuristicLab.Problems.PTSP {
    33   [Item("Stochastic25SingleMoveGenerator", "Randomly samples a single from all possible inversion and shift moves (2.5-opt) from a given permutation.")]
     31  [Item("Stochastic 2.5-SingleMoveGenerator", "Randomly samples a single from all possible inversion and shift moves (2.5-opt) from a given permutation.")]
    3432  [StorableClass]
    35   class Stochastic25SingleMoveGenerator : TwoPointFiveMoveGenerator, IStochasticOperator, ISingleMoveGenerator {
     33  public sealed class StochasticTwoPointFiveSingleMoveGenerator : TwoPointFiveMoveGenerator, IStochasticOperator, ISingleMoveGenerator {
    3634    public ILookupParameter<IRandom> RandomParameter {
    3735      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     
    3937
    4038    [StorableConstructor]
    41     protected Stochastic25SingleMoveGenerator(bool deserializing) : base(deserializing) { }
    42     protected Stochastic25SingleMoveGenerator(Stochastic25SingleMoveGenerator original, Cloner cloner) : base(original, cloner) { }
    43     public Stochastic25SingleMoveGenerator()
     39    private StochasticTwoPointFiveSingleMoveGenerator(bool deserializing) : base(deserializing) { }
     40    private StochasticTwoPointFiveSingleMoveGenerator(StochasticTwoPointFiveSingleMoveGenerator original, Cloner cloner) : base(original, cloner) { }
     41    public StochasticTwoPointFiveSingleMoveGenerator()
    4442      : base() {
    4543      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator."));
     
    4745
    4846    public override IDeepCloneable Clone(Cloner cloner) {
    49       return new Stochastic25SingleMoveGenerator(this, cloner);
     47      return new StochasticTwoPointFiveSingleMoveGenerator(this, cloner);
    5048    }
    5149
    5250    public static TwoPointFiveMove Apply(Permutation permutation, IRandom random) {
    5351      int length = permutation.Length;
    54       if (length == 1) throw new ArgumentException("Stochastic25SingleMoveGenerator: There cannot be an inversion move given a permutation of length 1.", "permutation");
     52      if (length == 1) throw new ArgumentException("Stochastic 2.5-SingleMoveGenerator: There cannot be an inversion move given a permutation of length 1.", "permutation");
    5553      int index1 = random.Next(length - 1);
    5654      int index2 = random.Next(index1 + 1, length);
     
    6361      bool isInvert = random.NextDouble() > 0.5;
    6462      return new TwoPointFiveMove(index1, index2, isInvert);
    65      
     63
    6664    }
    6765
    6866    protected override TwoPointFiveMove[] GenerateMoves(Permutation permutation) {
    69       IRandom random = RandomParameter.ActualValue;
    70       return new TwoPointFiveMove[] { Apply(permutation, random) };
     67      return new[] { Apply(permutation, RandomParameter.ActualValue) };
    7168    }
    7269  }
Note: See TracChangeset for help on using the changeset viewer.