Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/19/10 16:51:30 (14 years ago)
Author:
svonolfe
Message:

Added prins encoding (#1039)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs

    r4230 r4268  
    3131  [Item("AlbaEncoding", "Represents an Alba encoding of VRP solutions. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
    3232  [StorableClass]
    33   public class AlbaEncoding : Permutation, IVRPEncoding {
     33  public class AlbaEncoding : PermutationEncoding {
    3434    [Storable]
    3535    private int cities;
    3636   
    3737    #region IVRPEncoding Members
    38     public List<Tour> GetTours() {
     38    public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) {
    3939      List<Tour> result = new List<Tour>();
    4040
     
    7878
    7979    public AlbaEncoding(Permutation permutation, int cities)
    80       : base(PermutationTypes.RelativeUndirected) {
    81       this.array = new int[permutation.Length];
    82       for (int i = 0; i < array.Length; i++)
    83         this.array[i] = permutation[i];
    84 
     80      : base(permutation) {
    8581      this.cities = cities;
    8682    }
     
    8884    [StorableConstructor]
    8985    private AlbaEncoding(bool serializing)
    90       : base() {
     86      : base(serializing) {
    9187    }
    9288
    93     public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles) {
    94       List<Tour> tours = encoding.GetTours();
     89    public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles, ILookupParameter<DoubleMatrix> distanceMatrix) {
     90      List<Tour> tours = encoding.GetTours(distanceMatrix, vehicles);
    9591
    9692      int cities = 0;
     
    155151
    156152    internal static void RemoveUnusedParameters(ParameterCollection parameters) {
    157       parameters.Remove("DistanceMatrix");
    158153      parameters.Remove("UseDistanceMatrix");
    159154      parameters.Remove("Capacity");
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs

    r4206 r4268  
    5353
    5454        if (!(solution is AlbaEncoding)) {
    55           parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     55          parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value,
     56            DistanceMatrixParameter);
    5657        } else {
    5758          parents[i] = solution;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r4206 r4268  
    6262      IVRPEncoding solution = VRPToursParameter.ActualValue;
    6363      if (!(solution is AlbaEncoding)) {
    64         VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     64        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter);
    6565      }
    6666
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs

    r4204 r4268  
    4141      IVRPEncoding solution = VRPToursParameter.ActualValue;
    4242      if (!(solution is AlbaEncoding)) {
    43         VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     43        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value,
     44          DistanceMatrixParameter);
    4445      }
    4546
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionEvaluator.cs

    r4206 r4268  
    4444
    4545    public static TourEvaluation GetMoveQuality(AlbaEncoding individual, IntraRouteInversionMove move,
     46      IntValue vehicles,
    4647      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    4748      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    5354
    5455      return VRPEvaluator.Evaluate(
    55         newSolution, dueTimeArray, serviceTimeArray, readyTimeArray,
     56        newSolution, vehicles, dueTimeArray, serviceTimeArray, readyTimeArray,
    5657        demandArray, capacity, fleetUsageFactor, timeFactor, distanceFactor,
    5758        overloadPenalty, tardinessPenalty, coordinates, distanceMatrix, useDistanceMatrix);
     
    6162      return GetMoveQuality(
    6263        VRPToursParameter.ActualValue as AlbaEncoding, IntraRouteInversionMoveParameter.ActualValue,
     64        VehiclesParameter.ActualValue,
    6365        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
    6466        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMove.cs

    r4206 r4268  
    5757
    5858    public TourEvaluation GetMoveQuality(
    59       IVRPEncoding individual,
     59      IVRPEncoding individual, IntValue vehicles,
    6060      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    6161      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    6363      DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    6464      ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
    65         return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this,
     65        return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, vehicles,
    6666          dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    6767          coordinates, fleetUsageFactor, timeFactor, distanceFactor,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/LambdaInterchangeMove.cs

    r4206 r4268  
    8989
    9090    public TourEvaluation GetMoveQuality(
    91       IVRPEncoding individual,
     91      IVRPEncoding individual, IntValue vehicles,
    9292      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    9393      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    9595      DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    9696      ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
    97         return LambdaInterchangeMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this,
     97        return LambdaInterchangeMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this,  vehicles,
    9898          dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    9999          coordinates, fleetUsageFactor, timeFactor, distanceFactor,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/LambdaInterchangeMoveEvaluator.cs

    r4206 r4268  
    4444
    4545    public static TourEvaluation GetMoveQuality(AlbaEncoding individual, LambdaInterchangeMove move,
     46      IntValue vehicles,
    4647      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    4748      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    5354
    5455      return VRPEvaluator.Evaluate(
    55         newSolution, dueTimeArray, serviceTimeArray, readyTimeArray,
     56        newSolution, vehicles, dueTimeArray, serviceTimeArray, readyTimeArray,
    5657        demandArray, capacity, fleetUsageFactor, timeFactor, distanceFactor,
    5758        overloadPenalty, tardinessPenalty, coordinates, distanceMatrix, useDistanceMatrix);
     
    6162      return GetMoveQuality(
    6263        VRPToursParameter.ActualValue as AlbaEncoding, LambdaInterchangeMoveParameter.ActualValue,
     64        VehiclesParameter.ActualValue,
    6365        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
    6466        DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/PermutationTranslocationMoveEvaluator.cs

    r4208 r4268  
    5151      return VRPEvaluator.Evaluate(
    5252        newSolution,
     53        VehiclesParameter.ActualValue,
    5354        DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
    5455        DemandParameter.ActualValue, CapacityParameter.ActualValue,
Note: See TracChangeset for help on using the changeset viewer.