Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4380


Ignore:
Timestamp:
09/10/10 13:58:35 (14 years ago)
Author:
svonolfe
Message:

Readded DistanceMatrix parameter to the VRP problem instance (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r4378 r4380  
    5656      get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
    5757    }
     58    protected OptionalValueParameter<DoubleMatrix> DistanceMatrixParameter {
     59      get { return (OptionalValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     60    }
    5861    protected ValueParameter<BoolValue> UseDistanceMatrixParameter {
    5962      get { return (ValueParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
     
    7780      set { CoordinatesParameter.Value = value; }
    7881    }
    79    
    80     [Storable]
    81     public DoubleMatrix DistanceMatrix { get; set; }
    82    
     82
     83    public DoubleMatrix DistanceMatrix {
     84      get { return DistanceMatrixParameter.Value; }
     85      set { DistanceMatrixParameter.Value = value; }
     86    }
    8387    public BoolValue UseDistanceMatrix {
    8488      get { return UseDistanceMatrixParameter.Value; }
     
    134138    public double GetDistance(int start, int end) {
    135139      double distance = 0.0;
     140      DoubleMatrix distanceMatrix = DistanceMatrix;
    136141
    137       if (DistanceMatrix == null && UseDistanceMatrix.Value)
    138         DistanceMatrix = CreateDistanceMatrix();
    139      
    140       if(DistanceMatrix != null)
    141         distance = DistanceMatrix[start, end];
     142      if (distanceMatrix == null && UseDistanceMatrix.Value) {
     143        distanceMatrix = DistanceMatrix = CreateDistanceMatrix();
     144      }
     145
     146      if (distanceMatrix != null)
     147        distance = distanceMatrix[start, end];
    142148      else
    143149        distance = CalculateDistance(start, end);
     
    175181      : base() {
    176182      Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrix()));
     183      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    177184      Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));
    178185      Parameters.Add(new ValueParameter<IntValue>("Vehicles", "The number of vehicles.", new IntValue(0)));
Note: See TracChangeset for help on using the changeset viewer.