Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/09/10 09:55:31 (14 years ago)
Author:
svonolfe
Message:

Merged relevant changes from the trunk into the branch (cloning,...) (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerInsertionManipulator.cs

    r4365 r4752  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    3536    public AlbaCustomerInsertionManipulator()
    3637      : base() {
     38    }
     39
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      return new AlbaCustomerInsertionManipulator(this, cloner);
     42    }
     43
     44    private AlbaCustomerInsertionManipulator(AlbaCustomerInsertionManipulator original, Cloner cloner)
     45      : base(original, cloner) {
    3746    }
    3847
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerInversionManipulator.cs

    r4365 r4752  
    2626using HeuristicLab.Data;
    2727using System.Collections.Generic;
     28using HeuristicLab.Common;
    2829
    2930namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    3637    public AlbaCustomerInversionManipulator()
    3738      : base() {
     39    }
     40
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new AlbaCustomerInversionManipulator(this, cloner);
     43    }
     44
     45    private AlbaCustomerInversionManipulator(AlbaCustomerInversionManipulator original, Cloner cloner)
     46      : base(original, cloner) {
    3847    }
    3948
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerSwapManipulator.cs

    r4365 r4752  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    3536    public AlbaCustomerSwapManipulator()
    3637      : base() {
     38    }
     39
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      return new AlbaCustomerSwapManipulator(this, cloner);
     42    }
     43
     44    private AlbaCustomerSwapManipulator(AlbaCustomerSwapManipulator original, Cloner cloner)
     45      : base(original, cloner) {
    3746    }
    3847
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaIntraRouteInversionManipulator.cs

    r4365 r4752  
    2727using System;
    2828using System.Collections.Generic;
     29using HeuristicLab.Common;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    3839      : base() {
    3940     }
     41
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new AlbaIntraRouteInversionManipulator(this, cloner);
     44    }
     45
     46    private AlbaIntraRouteInversionManipulator(AlbaIntraRouteInversionManipulator original, Cloner cloner)
     47      : base(original, cloner) {
     48    }
    4049
    4150    public static void Apply(AlbaEncoding individual, int index1, int index2) {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaLambdaInterchangeManipulator.cs

    r4365 r4752  
    2727using System;
    2828using System.Collections.Generic;
     29using HeuristicLab.Common;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    4344        Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1)));
    4445     }
     46
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      return new AlbaLambdaInterchangeManipulator(this, cloner);
     49    }
     50
     51    private AlbaLambdaInterchangeManipulator(AlbaLambdaInterchangeManipulator original, Cloner cloner)
     52      : base(original, cloner) {
     53    }
    4554
    4655    public static void Apply(AlbaEncoding individual, int tour1Index, int position1, int length1,
     
    100109    protected override void Manipulate(IRandom rand, AlbaEncoding individual) {
    101110      List<Tour> tours = individual.GetTours();
    102       int lambda = LambdaParameter.Value.Value;
     111      if (tours.Count > 1) {
     112        int lambda = LambdaParameter.Value.Value;
    103113
    104       int route1Index = rand.Next(tours.Count);
    105       Tour route1 = tours[route1Index];
     114        int route1Index = rand.Next(tours.Count);
     115        Tour route1 = tours[route1Index];
    106116
    107       int route2Index = rand.Next(tours.Count - 1);
    108       if (route2Index >= route1Index)
    109         route2Index += 1;
    110       Tour route2 = tours[route2Index];
    111117
    112       int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1));
    113       int index1 = rand.Next(route1.Stops.Count - length1 + 1);
     118        int route2Index = rand.Next(tours.Count - 1);
     119        if (route2Index >= route1Index)
     120          route2Index += 1;
     121        Tour route2 = tours[route2Index];
    114122
    115       int l2Min = 0;
    116       if (length1 == 0)
    117         l2Min = 1;
    118       int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1));
    119       int index2 = rand.Next(route2.Stops.Count - length2 + 1);
     123        int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1));
     124        int index1 = rand.Next(route1.Stops.Count - length1 + 1);
    120125
    121       Apply(individual, route1Index, index1, length1,
    122         route2Index, index2, length2);
     126        int l2Min = 0;
     127        if (length1 == 0)
     128          l2Min = 1;
     129        int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1));
     130        int index2 = rand.Next(route2.Stops.Count - length2 + 1);
     131
     132        Apply(individual, route1Index, index1, length1,
     133          route2Index, index2, length2);
     134      }
    123135    }
    124136  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r4376 r4752  
    2828using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2929using HeuristicLab.Problems.VehicleRouting.Encodings.General;
     30using HeuristicLab.Common;
    3031
    3132namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    4344      : base() {
    4445        Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     46    }
     47
     48    protected AlbaManipulator(AlbaManipulator original, Cloner cloner)
     49      : base(original, cloner) {
    4550    }
    4651
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaPermutationManipulator.cs

    r4365 r4752  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
     
    4243    }
    4344
     45    public override IDeepCloneable Clone(Cloner cloner) {
     46      return new AlbaPermutationManipualtor(this, cloner);
     47    }
     48
     49    private AlbaPermutationManipualtor(AlbaPermutationManipualtor original, Cloner cloner)
     50      : base(original, cloner) {
     51    }
     52
    4453    protected override void Manipulate(IRandom random, AlbaEncoding individual) {
    4554      InnerManipulatorParameter.ActualValue.PermutationParameter.ActualName = VRPToursParameter.ActualName;
Note: See TracChangeset for help on using the changeset viewer.