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/StochasticTwoPointFiveMultiMoveGenerator.cs

    r13408 r13412  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Encodings.PermutationEncoding;
    26 using HeuristicLab.Operators;
    2726using HeuristicLab.Optimization;
    2827using HeuristicLab.Parameters;
     
    3029
    3130namespace HeuristicLab.Problems.PTSP {
    32   [Item("Stochastic25MultiMoveGenerator", "Randomly samples n from all possible inversion and shift moves (2.5-opt) from a given permutation.")]
     31  [Item("Stochastic 2.5-MultiMoveGenerator", "Randomly samples n from all possible inversion and shift moves (2.5-opt) from a given permutation.")]
    3332  [StorableClass]
    34   class Stochastic25MultiMoveGenerator : TwoPointFiveMoveGenerator, IMultiMoveGenerator, IStochasticOperator {
     33  public sealed class StochasticTwoPointFiveMultiMoveGenerator : TwoPointFiveMoveGenerator, IMultiMoveGenerator, IStochasticOperator {
    3534    public ILookupParameter<IRandom> RandomParameter {
    3635      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     
    4645
    4746    [StorableConstructor]
    48     protected Stochastic25MultiMoveGenerator(bool deserializing) : base(deserializing) { }
    49     protected Stochastic25MultiMoveGenerator(Stochastic25MultiMoveGenerator original, Cloner cloner) : base(original, cloner) { }
    50     public Stochastic25MultiMoveGenerator()
     47    private StochasticTwoPointFiveMultiMoveGenerator(bool deserializing) : base(deserializing) { }
     48    private StochasticTwoPointFiveMultiMoveGenerator(StochasticTwoPointFiveMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { }
     49    public StochasticTwoPointFiveMultiMoveGenerator()
    5150      : base() {
    5251      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator."));
     
    5554
    5655    public override IDeepCloneable Clone(Cloner cloner) {
    57       return new Stochastic25MultiMoveGenerator(this, cloner);
     56      return new StochasticTwoPointFiveMultiMoveGenerator(this, cloner);
    5857    }
    5958
    6059    public static TwoPointFiveMove[] Apply(Permutation permutation, IRandom random, int sampleSize) {
    61       int length = permutation.Length;
    62       TwoPointFiveMove[] moves = new TwoPointFiveMove[sampleSize];
    63       for (int i = 0; i < sampleSize; i++) {
    64         moves[i] = Stochastic25SingleMoveGenerator.Apply(permutation, random);
     60      var moves = new TwoPointFiveMove[sampleSize];
     61      for (var i = 0; i < sampleSize; i++) {
     62        moves[i] = StochasticTwoPointFiveSingleMoveGenerator.Apply(permutation, random);
    6563      }
    6664      return moves;
     
    6866
    6967    protected override TwoPointFiveMove[] GenerateMoves(Permutation permutation) {
    70       IRandom random = RandomParameter.ActualValue;
    71       return Apply(permutation, random, SampleSizeParameter.ActualValue.Value);
     68      return Apply(permutation, RandomParameter.ActualValue, SampleSizeParameter.ActualValue.Value);
    7269    }
    7370  }
Note: See TracChangeset for help on using the changeset viewer.