Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package rinde.sim.pdptw.gendreau06;
 

Author(s):
Rinde van Lon <rinde.vanlon@cs.kuleuven.be>
public class Gendreau06ObjectiveFunction implements ObjectiveFunction {
  protected final double alpha;
  protected final double beta;
     = 1d;
     = 1d;
  }

  
All parcels need to be delivered, all vehicles need to be back at the depot.
  public boolean isValidResult(StatisticsDTO stats) {
    return stats.totalParcels == stats.acceptedParcels
        && stats.totalParcels == stats.totalPickups
        && stats.totalParcels == stats.totalDeliveries && stats.simFinish
        && stats.totalVehicles == stats.vehiclesAtDepot;
  }

  
Computes the cost according to the definition of the paper: the cost function used throughout this work is to minimize a weighted sum of three different criteria: total travel time, sum of lateness over all pick-up and delivery locations and sum of overtime over all vehicles. The function is defined as: sum(Tk) + alpha sum(max(0,tv-lv)) + beta sum(max(0,tk-l0)) Where: Tk is the total travel time on route Rk, alpha and beta are weighting parameters which were set to 1 in the paper. The definition of lateness: max(0,lateness) is commonly referred to as tardiness. All times are expressed in minutes.
  public double computeCost(StatisticsDTO stats) {
    final double totalTravelTime = travelTime(stats);
    final double sumTardiness = tardiness(stats);
    final double overTime = overTime(stats);
    return totalTravelTime + ( * sumTardiness) + ( * overTime);
  }
    return new StringBuilder().append("Travel time: ")
        .append(travelTime(stats)).append("\nTardiness: ")
        .append(tardiness(stats)).append("\nOvertime: ")
        .append(overTime(stats)).append("\nTotal: ").append(computeCost(stats))
        .toString();
  }
  // time in minutes
  public double travelTime(StatisticsDTO stats) {
    // avg speed is 30 km/h
    // = (dist / 30.0) * 60.0
    return stats.totalDistance * 2d;
  }
  public double tardiness(StatisticsDTO stats) {
    return (stats.pickupTardiness + stats.deliveryTardiness) / 60000d;
  }
  public double overTime(StatisticsDTO stats) {
    return stats.overTime / 60000d;
  }
New to GrepCode? Check out our FAQ X