Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs

    r4352 r4722  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
     25using HeuristicLab.Data;
    2426using HeuristicLab.Parameters;
    2527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using System.Collections.Generic;
    2828
    2929namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3737    [StorableConstructor]
    3838    private PotvinLocalSearchManipulator(bool deserializing) : base(deserializing) { }
    39 
    40     public PotvinLocalSearchManipulator() : base() {
     39    private PotvinLocalSearchManipulator(PotvinLocalSearchManipulator original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new PotvinLocalSearchManipulator(this, cloner);
     44    }
     45    public PotvinLocalSearchManipulator()
     46      : base() {
    4147      Parameters.Add(new ValueParameter<IntValue>("Iterations", "The number of max iterations.", new IntValue(100)));
    4248    }
     
    7177          }
    7278          individual.Tours[currentTour].Cities.RemoveRange(currentCity, length);
    73          
     79
    7480          currentCity++;
    7581        }
     
    106112                  individual.Tours[insertionTour].Cities.InsertRange(
    107113                    insertionPlace,
    108                     toBeInserted); 
     114                    toBeInserted);
    109115                }
    110116                city++;
     
    115121          }
    116122          iterations++;
    117         } while (insertionFound && 
     123        } while (insertionFound &&
    118124          iterations < Iterations.Value.Value);
    119125
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs

    r4352 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
     24using HeuristicLab.Optimization;
    2425using HeuristicLab.Parameters;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Optimization;
    2827
    2928namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3736    [StorableConstructor]
    3837    protected PotvinManipulator(bool deserializing) : base(deserializing) { }
    39 
     38    protected PotvinManipulator(PotvinManipulator original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
    4041    public PotvinManipulator() {
    4142      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     
    7374    protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, out int route, out int place) {
    7475      return individual.FindInsertionPlace(
    75         DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, 
    76         DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue, 
     76        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
     77        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
    7778        DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,
    7879        city, routeToAvoid, out route, out place);
    7980    }
    80    
     81
    8182    public override IOperation Apply() {
    8283      IVRPEncoding solution = VRPToursParameter.ActualValue;
     
    8485        VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter);
    8586      }
    86      
     87
    8788      Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PotvinEncoding);
    8889
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs

    r4352 r4722  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using System.Collections.Generic;
    2826
    2927namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3331    [StorableConstructor]
    3432    private PotvinOneLevelExchangeMainpulator(bool deserializing) : base(deserializing) { }
     33    private PotvinOneLevelExchangeMainpulator(PotvinOneLevelExchangeMainpulator original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new PotvinOneLevelExchangeMainpulator(this, cloner);
     38    }
     39    public PotvinOneLevelExchangeMainpulator() : base() { }
    3540
    36     public PotvinOneLevelExchangeMainpulator() : base() { }
    37    
    3841    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    3942      int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
     
    5255
    5356      route1.Cities.RemoveAll(
    54         new System.Predicate<int>( 
     57        new System.Predicate<int>(
    5558          delegate(int val) {
    56             return (replaced.Contains(val)); 
     59            return (replaced.Contains(val));
    5760          }
    5861        )
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r4352 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using System.Collections.Generic;
    2825
    2926namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    3330    [StorableConstructor]
    3431    private PotvinTwoLevelExchangeManipulator(bool deserializing) : base(deserializing) { }
     32    private PotvinTwoLevelExchangeManipulator(PotvinTwoLevelExchangeManipulator original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new PotvinTwoLevelExchangeManipulator(this, cloner);
     35    }
     36    public PotvinTwoLevelExchangeManipulator() : base() { }
    3537
    36     public PotvinTwoLevelExchangeManipulator() : base() { }
    37    
    3838    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    3939      int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
     
    5454                if (FindInsertionPlace(individual,
    5555                  customer2, selectedIndex, out route, out place)) {
    56                     individual.Tours[route].Cities.Insert(place, customer2);
     56                  individual.Tours[route].Cities.Insert(place, customer2);
    5757                  route1.Cities.RemoveAt(customer1Position);
    5858
Note: See TracChangeset for help on using the changeset viewer.