Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2011-2014 Rinde van Lon, iMinds DistriNet, KU Leuven
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *         http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.github.rinde.rinsim.scenario.gendreau06;
 
 
Objective function for Gendreau et al. (2006) problem instances.

Author(s):
Rinde van Lon
 
 public final class Gendreau06ObjectiveFunction implements ObjectiveFunction,
     Serializable {
   private static final long serialVersionUID = 6069190376442772396L;
   private static final Gendreau06ObjectiveFunction INSTANCE = new Gendreau06ObjectiveFunction();
   private static final double MS_TO_MINUTES = 60000d;
   private static final double ALPHA = 1d;
   private static final double BETA = 1d;
 
   private Gendreau06ObjectiveFunction() {}

  
All parcels need to be delivered, all vehicles need to be back at the depot.

Parameters:
stats The statistics object to check for validity.
Returns:
true when the statistics object represents a valid simulation run, false otherwise.
 
   @Override
   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.

Parameters:
stats The statistics object to compute the cost for.
Returns:
The cost.
 
   @Override
   public double computeCost(StatisticsDTO stats) {
     final double totalTravelTime = travelTime(stats);
     final double sumTardiness = tardiness(stats);
     final double overTime = overTime(stats);
     return totalTravelTime +  * sumTardiness +  * overTime;
   }
 
   @Override
     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();
 
   }

  
Computes the travel time based on the com.github.rinde.rinsim.pdptw.common.StatisticsDTO.

Parameters:
stats The statistics.
Returns:
The travel time in minutes.
 
   public double travelTime(StatisticsDTO stats) {
     // avg speed is 30 km/h
     // = (dist / 30.0) * 60.0
     return stats.totalDistance * 2d;
   }

  
Computes the tardiness based on the com.github.rinde.rinsim.pdptw.common.StatisticsDTO.

Parameters:
stats The statistics.
Returns:
The tardiness in minutes.
  public double tardiness(StatisticsDTO stats) {
    return (stats.pickupTardiness + stats.deliveryTardiness) / ;
  }

  
Computes the over time based on the com.github.rinde.rinsim.pdptw.common.StatisticsDTO.

Parameters:
stats The statistics.
Returns:
The over time in minutes.
  public double overTime(StatisticsDTO stats) {
    return stats.overTime / ;
  }
  public String toString() {
    return this.getClass().getName();
  }

  

Returns:
The instance.
  public static Gendreau06ObjectiveFunction instance() {
    return ;
  }
New to GrepCode? Check out our FAQ X