Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/17 15:16:55 (7 years ago)
Author:
abeham
Message:

#2205: added results tab to solution view to analyze vrp solution in more detail

  • reorganized insertion infos and adapted some evaluators and instances
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MDCVRP/MDCVRPTW/MDCVRPPDTW/MDCVRPPDTWEvaluator.cs

    r14185 r14677  
    4343
    4444    protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour, IVRPEncoding solution) {
    45       TourInsertionInfo tourInfo = new TourInsertionInfo(solution.GetVehicleAssignment(solution.GetTourIndex(tour)));
    46       eval.InsertionInfo.AddTourInsertionInfo(tourInfo);
    4745      double originalQuality = eval.Quality;
    4846
    49       IHeterogenousCapacitatedProblemInstance cvrpInstance = instance as IHeterogenousCapacitatedProblemInstance;
     47      var cvrpInstance = (IHeterogenousCapacitatedProblemInstance)instance;
    5048      DoubleArray demand = instance.Demand;
    5149
    52       ITimeWindowedProblemInstance vrptw = instance as ITimeWindowedProblemInstance;
     50      var vrptw = (ITimeWindowedProblemInstance)instance;
    5351      DoubleArray dueTime = vrptw.DueTime;
    5452      DoubleArray readyTime = vrptw.ReadyTime;
    5553      DoubleArray serviceTimes = vrptw.ServiceTime;
    5654
    57       IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance;
     55      var pdp = (IPickupAndDeliveryProblemInstance)instance;
    5856      IntArray pickupDeliveryLocation = pdp.PickupDeliveryLocation;
    5957
    60       IMultiDepotProblemInstance mdp = instance as IMultiDepotProblemInstance;
     58      var mdp = (IMultiDepotProblemInstance)instance;
    6159      IntArray vehicleAssignment = mdp.VehicleDepotAssignment;
    6260      int depots = mdp.Depots.Value;
     
    8179      double tourStartTime = readyTime[0];
    8280      time = tourStartTime;
     81
     82      var tourInfo = new CVRPTWTourInsertionInfo(solution.GetVehicleAssignment(solution.GetTourIndex(tour)), capacity, tourStartTime);
     83      eval.InsertionInfo.AddTourInsertionInfo(tourInfo);
    8384
    8485      //simulate a tour, start and end at depot
     
    9293
    9394        //drive there
    94         double currentDistace = vrptw.GetDistance(start, end, solution);
    95         time += currentDistace;
    96         distance += currentDistace;
     95        double currentDistance = vrptw.GetDistance(start, end, solution);
     96        time += currentDistance;
     97        distance += currentDistance;
    9798
    9899        double arrivalTime = time;
     
    129130          //Pickup / deliver
    130131          bool validPickupDelivery =
    131             validPickupDelivery =
    132132            ((demand[end - 1] >= 0) ||
    133133             (stops.ContainsKey(pickupDeliveryLocation[end - 1])));
     
    144144
    145145        double spareCapacity = capacity - currentLoad;
    146         CVRPPDTWInsertionInfo stopInfo = new CVRPPDTWInsertionInfo(start, end, spareCapacity, tourStartTime,
     146        var stopInfo = new CVRPPDTWStopInsertionInfo(start, end, currentDistance, spareCapacity,
    147147          arrivalTime, time, spareTime, waitTime, new List<int>(stops.Keys), arrivalSpareCapacity);
    148148        tourInfo.AddStopInsertionInfo(stopInfo);
     
    156156      eval.VehicleUtilization += 1;
    157157
    158       (eval as CVRPEvaluation).Overload += overweight;
     158      ((CVRPEvaluation)eval).Overload += overweight;
    159159      double tourPenalty = 0;
    160160      double penalty = overweight * cvrpInstance.OverloadPenalty.Value;
     
    163163      tourPenalty += penalty;
    164164
    165       (eval as CVRPTWEvaluation).Tardiness += tardiness;
     165      ((CVRPTWEvaluation)eval).Tardiness += tardiness;
    166166      (eval as CVRPTWEvaluation).TravelTime += time;
    167167
     
    171171      tourPenalty += penalty;
    172172
    173       (eval as CVRPPDTWEvaluation).PickupViolations += pickupViolations;
     173      ((CVRPPDTWEvaluation)eval).PickupViolations += pickupViolations;
    174174      penalty = pickupViolations * pdp.PickupViolationPenalty.Value;
    175175      eval.Penalty += penalty;
     
    184184    protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer,
    185185      out bool feasible) {
    186       CVRPPDTWInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index) as CVRPPDTWInsertionInfo;
     186      var tourInfo = (CVRPTWTourInsertionInfo)tourInsertionInfo;
     187      var insertionInfo = (CVRPPDTWStopInsertionInfo)tourInsertionInfo.GetStopInsertionInfo(index);
    187188
    188189      double costs = 0;
     
    230231
    231232      if (index > 0)
    232         time = (tourInsertionInfo.GetStopInsertionInfo(index - 1) as CVRPTWInsertionInfo).LeaveTime;
     233        time = ((CVRPTWStopInsertionInfo)tourInsertionInfo.GetStopInsertionInfo(index - 1)).LeaveTime;
    233234      else
    234         time = insertionInfo.TourStartTime;
     235        time = tourInfo.TourStartTime;
    235236
    236237      time += startDistance;
     
    246247      time += endDistance;
    247248
    248       double additionalTime = time - (tourInsertionInfo.GetStopInsertionInfo(index) as CVRPTWInsertionInfo).ArrivalTime;
     249      double additionalTime = time - ((CVRPTWStopInsertionInfo)tourInsertionInfo.GetStopInsertionInfo(index)).ArrivalTime;
    249250      for (int i = index; i < tourInsertionInfo.GetStopCount(); i++) {
    250         CVRPTWInsertionInfo nextStop = tourInsertionInfo.GetStopInsertionInfo(i) as CVRPTWInsertionInfo;
     251        var nextStop = (CVRPTWStopInsertionInfo)tourInsertionInfo.GetStopInsertionInfo(i);
    251252
    252253        if (demand >= 0) {
Note: See TracChangeset for help on using the changeset viewer.