Changeset 4268


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

Added prins encoding (#1039)

Location:
branches/VRP
Files:
15 added
25 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs

    r4230 r4268  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Problems.VehicleRouting.Encodings;
     29using HeuristicLab.Parameters;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    119120              if (Content.Solution != null) {
    120121                int currentTour = 0;
    121                 foreach (Tour tour in Content.Solution.GetTours()) {
     122                foreach (Tour tour in Content.Solution.GetTours(new ValueLookupParameter<DoubleMatrix>("DistanceMatrix", distanceMatrix))) {
    122123                  double t = 0.0;
    123124                  Point[] tourPoints = new Point[tour.Cities.Count + 2];
  • 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,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/Crossovers/GVRCrossover.cs

    r4230 r4268  
    104104      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
    105105        IVRPEncoding solution = ParentsParameter.ActualValue[i];
    106 
    107106        if (!(solution is GVREncoding)) {
    108           parents[i] = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue, 
    109             VehiclesParameter.ActualValue);
     107          parents[i] = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue,
     108            DistanceMatrixParameter);
    110109        } else {
    111110          parents[i] = solution;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/GVREncoding.cs

    r4230 r4268  
    3737
    3838    [Storable]
    39     private IntValue vehicles { get; set; }
    40 
    41     [Storable]
    4239    private DoubleArray demand { get; set; }
    4340
    44     public override List<Tour> GetTours() {
     41    public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) {
    4542      List<Tour> tours = new List<Tour>();
     43      Tour newTour = new Tour();
     44      double currentDemand = 0;
    4645
    4746      int toursProcessed = 0;
    4847      foreach (Tour tour in base.Tours) {
    49         Tour newTour = new Tour();
    50         double currentDemand = 0;
     48        if (maxVehicles > tours.Count) {
     49          newTour = new Tour();
     50          currentDemand = 0;
     51        }
    5152
    5253        foreach (int city in tour.Cities) {
    5354          currentDemand += demand[city];
    5455
    55           if (vehicles.Value > tours.Count + base.Tours.Count - toursProcessed &&
     56          if (maxVehicles > tours.Count &&
    5657            currentDemand > capacity.Value) {
    5758            if(newTour.Cities.Count > 0)
     
    6667        }
    6768
    68         if (newTour.Cities.Count > 0)
     69        if (newTour.Cities.Count > 0 &&
     70          maxVehicles > tours.Count)
    6971          tours.Add(newTour);
     72
    7073        toursProcessed++;
    7174      }
     
    7578   
    7679    public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
    77       GVREncoding clone = new GVREncoding(capacity, demand, vehicles);
     80      GVREncoding clone = new GVREncoding(capacity, demand);
    7881      cloner.RegisterClonedObject(this, clone);
    7982      clone.Tours = (ItemList<Tour>)cloner.Clone(this.Tours);
     
    8285    }
    8386
    84     public GVREncoding(DoubleValue capacity, DoubleArray demand, IntValue vehicles)
     87    public GVREncoding(DoubleValue capacity, DoubleArray demand)
    8588      : base() {
    8689        this.capacity = capacity;
    8790        this.demand = demand;
    88         this.vehicles = vehicles;
    8991    }
    9092
     
    9496    }
    9597
    96     public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand, IntValue vehicles) {
    97       GVREncoding solution = new GVREncoding(capacity, demand, vehicles);
     98    public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand,
     99      ILookupParameter<DoubleMatrix> distanceMatrix) {
     100      GVREncoding solution = new GVREncoding(capacity, demand);
    98101
    99       TourEncoding.ConvertFrom(encoding, solution);
     102      TourEncoding.ConvertFrom(encoding, solution, distanceMatrix);
    100103
    101104      return solution;
    102105    }
    103106
    104     public static GVREncoding ConvertFrom(List<int> route, DoubleValue capacity, DoubleArray demand, IntValue vehicles) {
    105       GVREncoding solution = new GVREncoding(capacity, demand, vehicles);
     107    public static GVREncoding ConvertFrom(List<int> route, DoubleValue capacity, DoubleArray demand) {
     108      GVREncoding solution = new GVREncoding(capacity, demand);
    106109
    107110      TourEncoding.ConvertFrom(route, solution);
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/Manipulators/GVRManipulator.cs

    r4230 r4268  
    4343      //remove unused parameters
    4444      Parameters.Remove("Coordinates");
    45       Parameters.Remove("DistanceMatrix");
    4645      Parameters.Remove("UseDistanceMatrix");
    4746      Parameters.Remove("ReadyTime");
     
    5655      if (!(solution is GVREncoding)) {
    5756        VRPToursParameter.ActualValue = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue,
    58           VehiclesParameter.ActualValue);
     57          DistanceMatrixParameter);
    5958      }
    6059
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IVRPMove.cs

    r4205 r4268  
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    2828  public interface IVRPMove : IItem {
    29     TourEvaluation GetMoveQuality(IVRPEncoding individual,
     29    TourEvaluation GetMoveQuality(IVRPEncoding individual,  IntValue vehicles,
    3030        DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray,
    3131        DoubleValue capacity,DoubleMatrix coordinates,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r4205 r4268  
    4747      return move.GetMoveQuality(
    4848        VRPToursParameter.ActualValue,
     49        VehiclesParameter.ActualValue,
    4950        DueTimeParameter.ActualValue,
    5051        ServiceTimeParameter.ActualValue,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/TourEncoding.cs

    r4230 r4268  
    3737   
    3838    #region IVRPEncoding Members
    39     public virtual List<Tour> GetTours() {
    40       return new List<Tour>(Tours);
     39    public virtual List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) {
     40      List<Tour> result = new List<Tour>(Tours);
     41
     42      while (result.Count > maxVehicles) {
     43        Tour tour = result[result.Count - 1];
     44        result[result.Count - 2].Cities.AddRange(tour.Cities);
     45
     46        result.Remove(tour);
     47      }
     48
     49      return result;
    4150    }
    4251
     
    6675      : base() {
    6776    }
    68    
    69     public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution) {
    70       solution.Tours = new ItemList<Tour>(encoding.GetTours());
     77
     78    public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, ILookupParameter<DoubleMatrix> distanceMatrix) {
     79      solution.Tours = new ItemList<Tour>(encoding.GetTours(distanceMatrix));
    7180    }
    7281
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs

    r4206 r4268  
    129129
    130130        if (!(solution is PotvinEncoding)) {
    131           parents[i] = PotvinEncoding.ConvertFrom(solution);
     131          parents[i] = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter);
    132132        } else {
    133133          parents[i] = solution;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs

    r4206 r4268  
    8282      IVRPEncoding solution = VRPToursParameter.ActualValue;
    8383      if (!(solution is PotvinEncoding)) {
    84         VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution);
     84        VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter);
    8585      }
    8686     
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

    r4230 r4268  
    5353    }
    5454   
    55     public static PotvinEncoding ConvertFrom(IVRPEncoding encoding) {
     55    public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) {
    5656      PotvinEncoding solution = new PotvinEncoding();
    5757
    58       TourEncoding.ConvertFrom(encoding, solution);
     58      TourEncoding.ConvertFrom(encoding, solution, distanceMatrix);
    5959
    6060      return solution;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs

    r4230 r4268  
    101101      IVRPEncoding vrpSolution = VRPToursParameter.ActualValue;
    102102
    103       return vrpSolution.GetTours().Count;
     103      return vrpSolution.GetTours(DistanceMatrixParameter, VehiclesParameter.ActualValue.Value).Count;
    104104    }
    105105
     
    178178    }
    179179
    180     public static TourEvaluation Evaluate(IVRPEncoding solution, DoubleArray dueTimeArray,
     180    public static TourEvaluation Evaluate(IVRPEncoding solution, IntValue vehicles, DoubleArray dueTimeArray,
    181181      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    182182      DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
     
    190190      sumEval.Tardiness = 0;
    191191
    192       foreach (Tour tour in solution.GetTours()) {
     192      foreach (Tour tour in solution.GetTours(distanceMatrix)) {
    193193        TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    194194          fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty,
     
    208208      IVRPEncoding solution = VRPToursParameter.ActualValue;
    209209
    210       TourEvaluation sumEval = Evaluate(solution, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
     210      TourEvaluation sumEval = Evaluate(solution, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
    211211        DemandParameter.ActualValue, CapacityParameter.ActualValue,
    212212        FleetUsageFactor.ActualValue, TimeFactor.ActualValue, DistanceFactor.ActualValue, OverloadPenalty.ActualValue, TardinessPenalty.ActualValue,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4241 r4268  
    131131    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionMoveMaker.cs" />
    132132    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionMove.cs" />
     133    <Compile Include="Encodings\General\PermutationEncoding.cs" />
    133134    <Compile Include="Encodings\General\Creators\MultiVRPCreator.cs" />
    134     <Compile Include="Encodings\General\Crossovers\MultiVRPManipulator.cs" />
     135    <Compile Include="Encodings\General\Manipulators\MultiVRPManipulator.cs" />
    135136    <Compile Include="Encodings\General\Crossovers\MultiVRPCrossover.cs" />
    136137    <Compile Include="Encodings\General\Creators\RandomCreator.cs" />
     
    156157    <Compile Include="Encodings\Potvin\Manipulators\OneLevelExchangeManipulator.cs" />
    157158    <Compile Include="Encodings\Potvin\Manipulators\PotvinManipulator.cs" />
     159    <Compile Include="Encodings\Prins\Crossovers\PrinsCrossover.cs" />
     160    <Compile Include="Encodings\Prins\Crossovers\PrinsPermutationCrossover.cs" />
     161    <Compile Include="Encodings\Prins\Interfaces\IPrinsOperator.cs" />
     162    <Compile Include="Encodings\Prins\Manipulators\PrinsStochasticLSManipulator.cs" />
     163    <Compile Include="Encodings\Prins\Manipulators\PrinsExhaustiveLSManipulator.cs" />
     164    <Compile Include="Encodings\Prins\Manipulators\PrinsLSManipulator.cs" />
     165    <Compile Include="Encodings\Prins\Manipulators\PrinsManipulator.cs" />
     166    <Compile Include="Encodings\Prins\Manipulators\PrinsPermutationManipulator.cs" />
     167    <Compile Include="Encodings\Prins\PrinsEncoding.cs" />
    158168    <Compile Include="Interfaces\IVRPMoveMaker.cs" />
    159169    <Compile Include="TSPLIBParser.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPEncoding.cs

    r4230 r4268  
    2323using HeuristicLab.Problems.VehicleRouting.Encodings;
    2424using System.Collections.Generic;
     25using HeuristicLab.Data;
    2526
    2627namespace HeuristicLab.Problems.VehicleRouting {
    2728  public interface IVRPEncoding : IItem {
    28     List<Tour> GetTours();
     29    List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix, int maxVehicles = int.MaxValue);
    2930  }
    3031}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs

    r4241 r4268  
    139139      bool feasible = true;
    140140
    141       foreach (Tour tour in solution.GetTours()) {
     141      foreach (Tour tour in solution.GetTours(DistanceMatrixParameter)) {
    142142        if (!Feasible(tour)) {
    143143          feasible = false;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs

    r4154 r4268  
    6060
    6161      if (useDistanceMatrix.Value) {
    62         if (distanceMatrix.ActualValue == null) {
    63           distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
    64         }
     62        if (distanceMatrix is IValueLookupParameter<DoubleMatrix> &&
     63          (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value != null) {
     64            distance = (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value[start, end];
     65        } else {
     66          if (distanceMatrix.ActualValue == null) {
     67            distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
     68          }
    6569
    66         distance = distanceMatrix.ActualValue[start, end];
     70          distance = distanceMatrix.ActualValue[start, end];
     71        }       
    6772      } else {
    6873        distance = CalculateDistance(start, end, coordinates);
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4241 r4268  
    3434using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    3535using HeuristicLab.Problems.VehicleRouting.Encodings.General;
     36using HeuristicLab.Problems.VehicleRouting.Encodings.Prins;
    3637
    3738namespace HeuristicLab.Problems.VehicleRouting {
     
    386387      }
    387388
     389      foreach (IPrinsOperator op in Operators.OfType<IPrinsOperator>()) {
     390        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
     391        op.TimeFactor.ActualName = TimeFactor.Name;
     392        op.DistanceFactor.ActualName = DistanceFactor.Name;
     393        op.OverloadPenalty.ActualName = OverloadPenalty.Name;
     394        op.TardinessPenalty.ActualName = TardinessPenalty.Name;
     395      }
     396
    388397      foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) {
    389398        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
Note: See TracChangeset for help on using the changeset viewer.