Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/10 18:08:14 (14 years ago)
Author:
svonolfe
Message:

Refactored VRP based on the code review (#1039)

File:
1 edited

Legend:

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

    r4174 r4179  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Problems.VehicleRouting.Encodings;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using System;
    2729
    2830namespace HeuristicLab.Problems.VehicleRouting {
     31  [Item("VRPOperator", "A VRP operator.")]
     32  [StorableClass]
    2933  public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator {
    3034    public int Cities {
     
    3236    }
    3337    public ILookupParameter<DoubleMatrix> CoordinatesParameter {
    34       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     38      get {
     39        if (Parameters.ContainsKey("Coordinates"))
     40          return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"];
     41        else
     42          return null;
     43      }
    3544    }
    3645    public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
    37       get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     46      get {
     47        if (Parameters.ContainsKey("DistanceMatrix"))
     48          return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"];
     49        else
     50          return null;
     51      }
    3852    }
    3953    public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
    40       get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
     54      get {
     55        if (Parameters.ContainsKey("UseDistanceMatrix"))
     56          return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"];
     57        else
     58          return null;
     59      }
    4160    }
    4261    public ILookupParameter<IntValue> VehiclesParameter {
    43       get { return (ILookupParameter<IntValue>)Parameters["Vehicles"]; }
     62      get {
     63        if (Parameters.ContainsKey("Vehicles"))
     64          return (ILookupParameter<IntValue>)Parameters["Vehicles"];
     65        else
     66          return null;
     67      }
    4468    }
    4569    public ILookupParameter<DoubleValue> CapacityParameter {
    46       get { return (ILookupParameter<DoubleValue>)Parameters["Capacity"]; }
     70      get {
     71        if (Parameters.ContainsKey("Capacity"))
     72          return (ILookupParameter<DoubleValue>)Parameters["Capacity"];
     73        else
     74          return null;
     75      }
    4776    }
    4877    public ILookupParameter<DoubleArray> DemandParameter {
    49       get { return (ILookupParameter<DoubleArray>)Parameters["Demand"]; }
     78      get {
     79        if (Parameters.ContainsKey("Demand"))
     80          return (ILookupParameter<DoubleArray>)Parameters["Demand"];
     81        else
     82          return null;
     83      }
    5084    }
    5185    public ILookupParameter<DoubleArray> ReadyTimeParameter {
    52       get { return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"]; }
     86      get {
     87        if (Parameters.ContainsKey("ReadyTime"))
     88          return (ILookupParameter<DoubleArray>)Parameters["ReadyTime"];
     89        else
     90          return null;
     91      }
    5392    }
    5493    public ILookupParameter<DoubleArray> DueTimeParameter {
    55       get { return (ILookupParameter<DoubleArray>)Parameters["DueTime"]; }
     94      get {
     95        if (Parameters.ContainsKey("DueTime"))
     96          return (ILookupParameter<DoubleArray>)Parameters["DueTime"];
     97        else
     98          return null;
     99      }
    56100    }
    57101    public ILookupParameter<DoubleArray> ServiceTimeParameter {
    58       get { return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"]; }
     102      get {
     103        if (Parameters.ContainsKey("ServiceTime"))
     104          return (ILookupParameter<DoubleArray>)Parameters["ServiceTime"];
     105        else
     106          return null;
     107      }
    59108    }
     109
     110    [StorableConstructor]
     111    protected VRPOperator(bool deserializing) : base(deserializing) { }
    60112
    61113    public VRPOperator()
Note: See TracChangeset for help on using the changeset viewer.