Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4154


Ignore:
Timestamp:
08/04/10 17:34:02 (14 years ago)
Author:
svonolfe
Message:

Further improved the VRP design (#1039)

Location:
trunk/sources
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs

    r4151 r4154  
    156156                      Brush customerBrush = Brushes.Black;
    157157
    158                       t += VehicleRoutingProblem.GetDistance(
     158                      t += VRPUtilities.GetDistance(
    159159                        lastCustomer, location, coordinates, distanceMatrix, useDistanceMatrix);
    160160
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Creators/AlbaPushForwardInsertionCreator.cs

    r4150 r4154  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    3031
    3132namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs

    r4150 r4154  
    2828namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    2929  [StorableClass]
    30   public abstract class AlbaCrossover : VRPCrossover {
    31     public ILookupParameter<IntValue> VehiclesParameter {
    32       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    33     }
    34 
    35     public AlbaCrossover()
    36       : base() {
    37         Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The vehicles count."));
    38     }
    39    
     30  public abstract class AlbaCrossover : VRPCrossover {   
    4031    protected virtual void Crossover() {
    4132    }
    4233
    4334    public override IOperation Apply() {
    44       int cities = 0;
    45 
    4635      ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);
    4736      for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {
    4837        IVRPEncoding solution = ParentsParameter.ActualValue[i];
    49         cities = solution.Cities;
     38
    5039        if (!(solution is AlbaEncoding)) {
    5140          parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs

    r4150 r4154  
    3939
    4040    protected override void Crossover() {
    41       int cities = ParentsParameter.ActualValue[0].Cities;
    42 
    4341      PermutationCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName;
    4442      IAtomicOperation op = this.ExecutionContext.CreateOperation(
     
    5149        ExecutionContext.Scope.Variables.Remove(childName);
    5250
    53         ChildParameter.ActualValue = new AlbaEncoding(permutation, cities);
     51        ChildParameter.ActualValue = new AlbaEncoding(permutation, Cities);
    5452      } else
    5553        ChildParameter.ActualValue = null;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r4150 r4154  
    2828namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    2929  [StorableClass]
    30   public abstract class AlbaManipulator : VRPManipulator {
    31     public ILookupParameter<IntValue> VehiclesParameter {
    32       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    33     }
    34 
    35     public AlbaManipulator()
    36       : base() {
    37         Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The vehicles count."));
    38     }
    39    
     30  public abstract class AlbaManipulator : VRPManipulator {   
    4031    protected virtual void Manipulate() {
    4132    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs

    r4150 r4154  
    2929  [Item("AlbaMoveOperator", "A move operator for an alba VRP representation.")]
    3030  [StorableClass]
    31   public abstract class AlbaMoveOperator : VRPMoveOperator {
    32     public ILookupParameter<IntValue> VehiclesParameter {
    33       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    34     }
    35 
    36     public AlbaMoveOperator()
    37       : base() {
    38       Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The vehicles count."));
    39     }
    40    
     31  public abstract class AlbaMoveOperator : VRPMoveOperator {   
    4132    [Storable]
    4233    protected abstract IPermutationMoveOperator PermutationMoveOperatorParameter { get; set; }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs

    r4068 r4154  
    8282      Permutation permutation = VRPSolutionParameter.ActualValue as Permutation;
    8383      string moveName = TranslocationMoveGeneratorParameter.ActualValue.TranslocationMoveParameter.Name;
    84       int cities = VRPSolutionParameter.ActualValue.Cities;
    8584
    8685      List<Scope> toBeDeleted = new List<Scope>();
     
    9392            if (move.Index1 - 1 >= 0 &&
    9493              move.Index3 - 1 >= 0)
    95               criteria1 = (permutation[move.Index1] >= cities &&
    96                 permutation[move.Index1 - 1] >= cities &&
    97                 permutation[move.Index3 - 1] >= cities);
     94              criteria1 = (permutation[move.Index1] >= Cities &&
     95                permutation[move.Index1 - 1] >= Cities &&
     96                permutation[move.Index3 - 1] >= Cities);
    9897
    9998            int index3 = move.Index3 + (move.Index2 - move.Index1) + 1;
     
    101100            if (move.Index2 + 1 < permutation.Length &&
    102101              index3 < permutation.Length)
    103               criteria2 = (permutation[move.Index2] >= cities &&
    104                 permutation[move.Index2 + 1] >= cities &&
    105                 permutation[index3] >= cities);
     102              criteria2 = (permutation[move.Index2] >= Cities &&
     103                permutation[move.Index2 + 1] >= Cities &&
     104                permutation[index3] >= Cities);
    106105
    107106            if (criteria1 && criteria2)
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/IntListRepresentationCreator.cs

    r4150 r4154  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using System.Collections.Generic;
     28using HeuristicLab.Problems.VehicleRouting.Encodings;
    2829
    29 namespace HeuristicLab.Problems.VehicleRouting {
     30namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    3031  [StorableClass]
    3132  public abstract class IntListRepresentationCreator : VRPCreator {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/PushForwardInsertionCreator.cs

    r4150 r4154  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.VehicleRouting {
     31namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    3232  [StorableClass]
    3333  public abstract class PushForwardCreator : IntListRepresentationCreator, IStochasticOperator {
     
    199199       *-----------------------------------------------------------------------------
    200200       */
    201       for (int i = 1; i <= CitiesParameter.ActualValue.Value; i++) {
     201      for (int i = 1; i <= Cities; i++) {
    202202        distance = Distance(i, 0);
    203203        if (CoordinatesParameter.ActualValue[i, 0] < x0) distance = -distance;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Creators/PotvinPushForwardInsertionCreator.cs

    r4150 r4154  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    3031
    3132namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCreator.cs

    r4068 r4154  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.VehicleRouting {
     28namespace HeuristicLab.Problems.VehicleRouting.Encodings {
    2929  [StorableClass]
    30   public abstract class VRPCreator : SingleSuccessorOperator, IVRPCreator {
     30  public abstract class VRPCreator : VRPOperator, IVRPCreator {
    3131    public override bool CanChangeName {
    3232      get { return false; }
     
    3434
    3535    #region IVRPCreator Members
    36     public IValueLookupParameter<IntValue> CitiesParameter {
    37       get { return (IValueLookupParameter<IntValue>)Parameters["Cities"]; }
    38     }
    3936    public ILookupParameter<IVRPEncoding> VRPSolutionParameter {
    4037      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPSolution"]; }
    4138    }
    42     public ILookupParameter<DoubleMatrix> CoordinatesParameter {
    43       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
    44     }
    45     public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    46       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
    47     }
    48     public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
    49       get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
    50     }
    51     public ILookupParameter<IntValue> VehiclesParameter {
    52       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    53     }
    54     public ILookupParameter<DoubleValue> CapacityParameter {
    55       get { return (ILookupParameter<DoubleValue>)Parameters["Capacity"]; }
    56     }
    57     public ILookupParameter<DoubleArray> DemandParameter {
    58       get { return (ILookupParameter<DoubleArray>)Parameters["Demand"]; }
    59     }
    60     public ILookupParameter<DoubleArray> ReadyTimeParameter {
    61       get { return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"]; }
    62     }
    63     public ILookupParameter<DoubleArray> DueTimeParameter {
    64       get { return (ILookupParameter<DoubleArray>)Parameters["DueTime"]; }
    65     }
    66     public ILookupParameter<DoubleArray> ServiceTimeParameter {
    67       get { return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"]; }
    68     }
     39   
     40      public IValueLookupParameter<IntValue> CitiesParameter {
     41        get { return (IValueLookupParameter<IntValue>)Parameters["Cities"]; }
     42      }
    6943
    7044    public VRPCreator()
    7145      : base() {
    72       Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count."));
    73       Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The vehicles count."));
    74       Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    75       Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    76       Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
    77       Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
    78       Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
    79       Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
    80       Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
    81       Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
    82 
    8346      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPSolution", "The new VRP solution."));
    8447    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCrossover.cs

    r4150 r4154  
    2626
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings {
    28   public abstract class VRPCrossover : SingleSuccessorOperator, IVRPCrossover {
     28  public abstract class VRPCrossover : VRPOperator, IVRPCrossover {
    2929    #region IVRPCrossover Members
    3030
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPManipulator.cs

    r4150 r4154  
    2626
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings {
    28   public abstract class VRPManipulator : SingleSuccessorOperator, IVRPManipulator {
     28  public abstract class VRPManipulator : VRPOperator, IVRPManipulator {
    2929    #region IVRPManipulator Members
    3030
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPMoveOperator.cs

    r4150 r4154  
    2626
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings {
    28   public abstract class VRPMoveOperator : SingleSuccessorOperator, IVRPMoveOperator {
     28  public abstract class VRPMoveOperator : VRPOperator, IVRPMoveOperator {
    2929    #region IVRPManipulator Members
    3030
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs

    r4150 r4154  
    3939  [Item("VRPEvaluator", "Evaluates solutions for the VRP problem.")]
    4040  [StorableClass]
    41   public sealed class VRPEvaluator : SingleSuccessorOperator, IVRPEvaluator {
     41  public sealed class VRPEvaluator : VRPOperator, IVRPEvaluator {
    4242    #region ISingleObjectiveEvaluator Members
    4343    public ILookupParameter<DoubleValue> QualityParameter {
     
    6565      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPSolution"]; }
    6666    }
    67     public ILookupParameter<DoubleMatrix> CoordinatesParameter {
    68       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
    69     }
    70     public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    71       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
    72     }
    73     public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
    74       get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
    75     }
    76     public ILookupParameter<IntValue> VehiclesParameter {
    77       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    78     }
    79     public ILookupParameter<DoubleValue> CapacityParameter {
    80       get { return (ILookupParameter<DoubleValue>)Parameters["Capacity"]; }
    81     }
    82     public ILookupParameter<DoubleArray> DemandParameter {
    83       get { return (ILookupParameter<DoubleArray>)Parameters["Demand"]; }
    84     }
    85     public ILookupParameter<DoubleArray> ReadyTimeParameter {
    86       get { return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"]; }
    87     }
    88     public ILookupParameter<DoubleArray> DueTimeParameter {
    89       get { return (ILookupParameter<DoubleArray>)Parameters["DueTime"]; }
    90     }
    91     public ILookupParameter<DoubleArray> ServiceTimeParameter {
    92       get { return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"]; }
    93     }
     67   
    9468    public ILookupParameter<DoubleValue> FleetUsageFactor {
    9569      get { return (ILookupParameter<DoubleValue>)Parameters["FleetUsageFactor"]; }
     
    11791      Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness."));
    11892      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPSolution", "The VRP solution which should be evaluated."));
    119       Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    120       Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    121       Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
    122       Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles."));
    123       Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
    124       Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
    125       Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
    126       Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
    127       Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
    12893      Parameters.Add(new LookupParameter<DoubleValue>("FleetUsageFactor", "The fleet usage factor considered in the evaluation."));
    12994      Parameters.Add(new LookupParameter<DoubleValue>("TimeFactor", "The time factor considered in the evaluation."));
     
    166131
    167132        //drive there
    168         double currentDistace = VehicleRoutingProblem.GetDistance(start, end, coordinates, distanceMatrix, useDistanceMatrix);
     133        double currentDistace = VRPUtilities.GetDistance(start, end, coordinates, distanceMatrix, useDistanceMatrix);
    169134        distance += currentDistace;
    170135        time += currentDistace;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4150 r4154  
    107107  <ItemGroup>
    108108    <Compile Include="Analyzers\BestVRPSolutionAnalyzer.cs" />
     109    <Compile Include="VRPUtilities.cs" />
     110    <Compile Include="VRPOperator.cs" />
    109111    <Compile Include="Encodings\General\PushForwardInsertionCreator.cs" />
    110112    <Compile Include="Encodings\General\IntListRepresentationCreator.cs" />
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPCreator.cs

    r4068 r4154  
    2727  public interface IVRPCreator : IVRPOperator, ISolutionCreator {
    2828    IValueLookupParameter<IntValue> CitiesParameter { get; }
    29     ILookupParameter<IntValue> VehiclesParameter { get; }
    30     ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
    31     ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
    32     ILookupParameter<BoolValue> UseDistanceMatrixParameter { get; }
    33     ILookupParameter<DoubleValue> CapacityParameter { get; }
    34     ILookupParameter<DoubleArray> DemandParameter { get; }
    35     ILookupParameter<DoubleArray> ReadyTimeParameter { get; }
    36     ILookupParameter<DoubleArray> DueTimeParameter { get; }
    37     ILookupParameter<DoubleArray> ServiceTimeParameter { get; }
    38 
    3929    ILookupParameter<IVRPEncoding> VRPSolutionParameter { get; }
    4030  }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPEncoding.cs

    r4068 r4154  
    2828      get;
    2929    }
    30 
    31     int Cities {
    32       get;
    33     }
    3430  }
    3531}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPEvaluator.cs

    r4068 r4154  
    2525
    2626namespace HeuristicLab.Problems.VehicleRouting {
    27   public interface IVRPEvaluator : ISingleObjectiveEvaluator {
     27  public interface IVRPEvaluator : ISingleObjectiveEvaluator, IVRPOperator {
    2828    ILookupParameter<IVRPEncoding> VRPSolutionParameter { get; }
    29     ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
    30     ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
    31     ILookupParameter<BoolValue> UseDistanceMatrixParameter { get; }
    32     ILookupParameter<IntValue> VehiclesParameter { get; }
    33     ILookupParameter<DoubleValue> CapacityParameter { get; }
    34     ILookupParameter<DoubleArray> DemandParameter { get; }
    35     ILookupParameter<DoubleArray> ReadyTimeParameter { get; }
    36     ILookupParameter<DoubleArray> DueTimeParameter { get; }
    37     ILookupParameter<DoubleArray> ServiceTimeParameter { get; }
    38 
     29   
    3930    ILookupParameter<DoubleValue> VehcilesUtilizedParameter { get; }
    4031    ILookupParameter<DoubleValue> TravelTimeParameter { get; }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPMoveEvaluator.cs

    r4068 r4154  
    2525
    2626namespace HeuristicLab.Problems.VehicleRouting {
    27   public interface IVRPMoveEvaluator : ISingleObjectiveMoveEvaluator, IVRPMoveOperator {
    28     ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
    29     ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
    30     ILookupParameter<BoolValue> UseDistanceMatrixParameter { get; }
    31     ILookupParameter<IntValue> VehiclesParameter { get; }
    32     ILookupParameter<DoubleValue> CapacityParameter { get; }
    33     ILookupParameter<DoubleArray> DemandParameter { get; }
    34     ILookupParameter<DoubleArray> ReadyTimeParameter { get; }
    35     ILookupParameter<DoubleArray> DueTimeParameter { get; }
    36     ILookupParameter<DoubleArray> ServiceTimeParameter { get; }
    37 
     27  public interface IVRPMoveEvaluator : ISingleObjectiveMoveEvaluator, IVRPMoveOperator {   
    3828    ILookupParameter<DoubleValue> MoveVehcilesUtilizedParameter { get; }
    3929    ILookupParameter<DoubleValue> MoveTravelTimeParameter { get; }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPOperator.cs

    r4068 r4154  
    2121
    2222
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25
    2326namespace HeuristicLab.Problems.VehicleRouting {
    2427  public interface IVRPOperator {
     28    ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
     29    int Cities { get; }
     30    ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
     31    ILookupParameter<BoolValue> UseDistanceMatrixParameter { get; }
     32    ILookupParameter<IntValue> VehiclesParameter { get; }
     33    ILookupParameter<DoubleValue> CapacityParameter { get; }
     34    ILookupParameter<DoubleArray> DemandParameter { get; }
     35    ILookupParameter<DoubleArray> ReadyTimeParameter { get; }
     36    ILookupParameter<DoubleArray> DueTimeParameter { get; }
     37    ILookupParameter<DoubleArray> ServiceTimeParameter { get; }
    2538  }
    2639}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/MoveEvaluators/VRPMoveEvaluator.cs

    r4068 r4154  
    2626using HeuristicLab.Parameters;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Problems.VehicleRouting.Encodings;
    2829
    2930namespace HeuristicLab.Problems.VehicleRouting {
    3031  [Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
    3132  [StorableClass]
    32   public abstract class VRPMoveEvaluator : SingleSuccessorOperator, IVRPMoveEvaluator, IMoveOperator {
     33  public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
    3334    public override bool CanChangeName {
    3435      get { return false; }
     
    3839      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPSolution"]; }
    3940    }
    40     public ILookupParameter<DoubleMatrix> CoordinatesParameter {
    41       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
    42     }
    43     public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    44       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
    45     }
    46     public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
    47       get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
    48     }
    49     public ILookupParameter<IntValue> VehiclesParameter {
    50       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
    51     }
    52     public ILookupParameter<DoubleValue> CapacityParameter {
    53       get { return (ILookupParameter<DoubleValue>)Parameters["Capacity"]; }
    54     }
    55     public ILookupParameter<DoubleArray> DemandParameter {
    56       get { return (ILookupParameter<DoubleArray>)Parameters["Demand"]; }
    57     }
    58     public ILookupParameter<DoubleArray> ReadyTimeParameter {
    59       get { return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"]; }
    60     }
    61     public ILookupParameter<DoubleArray> DueTimeParameter {
    62       get { return (ILookupParameter<DoubleArray>)Parameters["DueTime"]; }
    63     }
    64     public ILookupParameter<DoubleArray> ServiceTimeParameter {
    65       get { return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"]; }
    66     }
     41   
    6742    public ILookupParameter<DoubleValue> FleetUsageFactor {
    6843      get { return (ILookupParameter<DoubleValue>)Parameters["FleetUsageFactor"]; }
     
    11388      Parameters.Add(new LookupParameter<DoubleValue>("MoveTardiness", "The tardiness."));
    11489      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The evaluated quality of a move on a VRP solution."));
    115       Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    116       Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    117       Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
    118       Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles."));
    119       Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
    120       Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
    121       Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
    122       Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
    123       Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
    12490      Parameters.Add(new LookupParameter<DoubleValue>("FleetUsageFactor", "The fleet usage factor considered in the evaluation."));
    12591      Parameters.Add(new LookupParameter<DoubleValue>("TimeFactor", "The time factor considered in the evaluation."));
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4150 r4154  
    375375    }
    376376    private void ParameterizeOperators() {
    377       foreach (IVRPMoveOperator op in Operators.OfType<IVRPMoveOperator>()) {
    378         op.VRPSolutionParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
    379       }
    380       foreach (AlbaMoveOperator op in Operators.OfType<AlbaMoveOperator>()) {
    381         op.VehiclesParameter.ActualName = VehiclesParameter.Name;
    382       }
    383 
    384       foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) {
     377      foreach (IVRPOperator op in Operators.OfType<IVRPOperator>()) {
    385378        op.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
    386379        op.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;
    387380        op.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name;
    388         op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    389         op.VRPSolutionParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
    390381        op.VehiclesParameter.ActualName = VehiclesParameter.Name;
    391382        op.CapacityParameter.ActualName = CapacityParameter.Name;
     
    394385        op.DueTimeParameter.ActualName = DueTimeParameter.Name;
    395386        op.ServiceTimeParameter.ActualName = ServiceTimeParameter.Name;
     387      }
     388     
     389      foreach (IVRPMoveOperator op in Operators.OfType<IVRPMoveOperator>()) {
     390        op.VRPSolutionParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
     391      }
     392
     393      foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) {
    396394        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
    397395        op.TimeFactor.ActualName = TimeFactor.Name;
     
    399397        op.OverloadPenalty.ActualName = OverloadPenalty.Name;
    400398        op.TardinessPenalty.ActualName = TardinessPenalty.Name;
     399        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     400        op.VRPSolutionParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
    401401      }
    402402      string translocationMove = Operators.OfType<IMoveGenerator>().OfType<IAlbaTranslocationMoveOperator>().First().TranslocationMoveParameter.ActualName;
     
    408408        op.ChildParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
    409409      }
    410       foreach (AlbaCrossover op in Operators.OfType<AlbaCrossover>()) {
    411         op.VehiclesParameter.ActualName = VehiclesParameter.Name;
    412       }
    413410
    414411      foreach (IVRPManipulator op in Operators.OfType<IVRPManipulator>()) {
    415412        op.VRPSolutionParameter.ActualName = SolutionCreator.VRPSolutionParameter.ActualName;
    416413      }
    417       foreach (AlbaManipulator op in Operators.OfType<AlbaManipulator>()) {
    418         op.VehiclesParameter.ActualName = VehiclesParameter.Name;
    419       }
    420414    }
    421415    private void ClearDistanceMatrix() {
     
    423417    }
    424418    #endregion
    425 
    426     private static double CalculateDistance(int start, int end, DoubleMatrix coordinates) {
    427       double distance = 0.0;
    428 
    429       distance =
    430           Math.Sqrt(
    431             Math.Pow(coordinates[start, 0] - coordinates[end, 0], 2) +
    432             Math.Pow(coordinates[start, 1] - coordinates[end, 1], 2));
    433 
    434       return distance;
    435     }
    436 
    437     private static DoubleMatrix CreateDistanceMatrix(DoubleMatrix coordinates) {
    438       DoubleMatrix distanceMatrix = new DoubleMatrix(coordinates.Rows, coordinates.Rows);
    439 
    440       for (int i = 0; i < distanceMatrix.Rows; i++) {
    441         for (int j = i; j < distanceMatrix.Columns; j++) {
    442           double distance = CalculateDistance(i, j, coordinates);
    443 
    444           distanceMatrix[i, j] = distance;
    445           distanceMatrix[j, i] = distance;
    446         }
    447       }
    448 
    449       return distanceMatrix;
    450     }
    451 
    452     public static double GetDistance(int start, int end,
    453       DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix) {
    454       double distance = 0.0;
    455 
    456       if (useDistanceMatrix.Value) {
    457         if (distanceMatrix.ActualValue == null) {
    458           distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
    459         }
    460 
    461         distance = distanceMatrix.ActualValue[start, end];
    462       } else {
    463         distance = CalculateDistance(start, end, coordinates);
    464       }
    465 
    466       return distance;
    467     }
    468 
    469     public static double GetDistance(int start, int end,
    470       DoubleMatrix coordinates, DoubleMatrix distanceMatrix, BoolValue useDistanceMatrix) {
    471       double distance = 0.0;
    472 
    473       if (useDistanceMatrix.Value) {
    474         distance = distanceMatrix[start, end];
    475       } else {
    476         distance = CalculateDistance(start, end, coordinates);
    477       }
    478 
    479       return distance;
    480     }
    481419
    482420    public void ImportFromSolomon(string solomonFileName) {
     
    522460        } else {
    523461          Demand[i] = rand.Next(10, 50);
    524           DueTime[i] = rand.Next((int)Math.Ceiling(CalculateDistance(0, i, Coordinates)), 1200);
     462          DueTime[i] = rand.Next((int)Math.Ceiling(VRPUtilities.CalculateDistance(0, i, Coordinates)), 1200);
    525463          ReadyTime[i] = DueTime[i] - rand.Next(0, 100);
    526464          ServiceTime[i] = 90;
Note: See TracChangeset for help on using the changeset viewer.