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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.