1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

add defaultVehicleType

now types do not have to be set neccessarily, since 'default' is always
set with cost-param (fix=0,dist=1,time=0)
This commit is contained in:
Stefan Schroeder 2013-06-06 09:18:23 +02:00
parent 8df602f8b8
commit 9f5b3c168b
2 changed files with 11 additions and 62 deletions

View file

@ -71,11 +71,12 @@ public class VehicleImpl implements Vehicle {
private String id;
private int capacity;
private double fixedCost;
private double perDistance;
private double perTime;
// private TimeSchedule timeSchedule = new TimeSchedule(0.0,Integer.MAX_VALUE);
/**
* default cost values for default vehicle type
*/
private double fixedCost = 0.0;
private double perDistance = 1.0;
private double perTime = 0.0;
public Builder(String id, int capacity) {
super();
@ -89,11 +90,8 @@ public class VehicleImpl implements Vehicle {
public Builder setCostPerTime(double perTime){ this.perTime = perTime; return this; }
// public Builder setTimeSchedule(TimeSchedule timeSchedule){ this.timeSchedule = timeSchedule; return this; }
public VehicleType build(){
return new VehicleType(this);
// return Type.newInstance(id, capacity, VehicleCostParams.newInstance(fixedCost, perTime, perDistance));
}
}
@ -127,9 +125,6 @@ public class VehicleImpl implements Vehicle {
public final String typeId;
public final int capacity;
public final VehicleCostParams vehicleCostParams;
// private double speed = 22.0;
private TimeSchedule timeSchedule;
public static VehicleType newInstance(String typeId, int capacity, VehicleCostParams para){
return new VehicleType(typeId, capacity, para);
@ -139,7 +134,6 @@ public class VehicleImpl implements Vehicle {
typeId = builder.id;
capacity = builder.capacity;
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance);
// timeSchedule = builder.timeSchedule;
}
public VehicleType(String typeId, int capacity,VehicleCostParams vehicleCostParams) {
@ -157,23 +151,10 @@ public class VehicleImpl implements Vehicle {
return capacity;
}
@Deprecated
public TimeSchedule getTimeSchedule() {
return timeSchedule;
}
public VehicleCostParams getVehicleCostParams() {
return vehicleCostParams;
}
// public double getSpeed() {
// return speed;
// }
//
// public void setSpeed(double speed) {
// this.speed = speed;
// }
@Override
public String toString() {
return "[typeId="+typeId+"][capacity="+capacity+"]" + vehicleCostParams;
@ -206,12 +187,14 @@ public class VehicleImpl implements Vehicle {
public static class VehicleBuilder {
static Logger log = Logger.getLogger(VehicleBuilder.class);
private String id;
private VehicleType type;
private String locationId;
private Coordinate locationCoord;
private double earliestStart = 0.0;
private double latestArrival = Double.MAX_VALUE;
private VehicleType type = VehicleType.Builder.newInstance("default", 0).build();
private VehicleBuilder(String id) {
super();
this.id = id;
@ -243,7 +226,6 @@ public class VehicleImpl implements Vehicle {
}
public VehicleImpl build(){
if(type == null) throw new IllegalStateException("type must not be null");
if(locationId == null && locationCoord != null) locationId = locationCoord.toString();
if(locationId == null && locationCoord == null) throw new IllegalStateException("locationId and locationCoord is missing.");
if(locationCoord == null) log.warn("locationCoord for vehicle " + id + " is missing.");
@ -291,14 +273,6 @@ public class VehicleImpl implements Vehicle {
return coord;
}
// public void setCoord(Coordinate coord) {
// this.coord = coord;
// }
// public void setLocationId(String locationId) {
// this.locationId = locationId;
// }
/*
* (non-Javadoc)
*
@ -309,18 +283,6 @@ public class VehicleImpl implements Vehicle {
return earliestDeparture;
}
/*
* (non-Javadoc)
*
* @see
* org.matsim.contrib.freight.vrp.basics.Vehicle#setEarliestDeparture(double
* )
*/
// public void setEarliestDeparture(double earliestDeparture) {
// this.earliestDeparture = earliestDeparture;
// }
/*
* (non-Javadoc)
*
@ -331,17 +293,6 @@ public class VehicleImpl implements Vehicle {
return latestArrival;
}
/*
* (non-Javadoc)
*
* @see
* org.matsim.contrib.freight.vrp.basics.Vehicle#setLatestArrival(double)
*/
// public void setLatestArrival(double latestArrival) {
// this.latestArrival = latestArrival;
// }
/*
* (non-Javadoc)
*

View file

@ -36,14 +36,12 @@ public class ManhattanCosts implements VehicleRoutingTransportCosts {
}
@Override
public double getTransportCost(String fromId, String toId, double time,
Driver driver, Vehicle vehicle) {
public double getTransportCost(String fromId, String toId, double time,Driver driver, Vehicle vehicle) {
return calculateDistance(fromId, toId);
}
@Override
public double getTransportTime(String fromId, String toId, double time,
Driver driver, Vehicle vehicle) {
public double getTransportTime(String fromId, String toId, double time,Driver driver, Vehicle vehicle) {
double transportTime = calculateDistance(fromId, toId) / speed;
return transportTime;
}