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:
parent
8df602f8b8
commit
9f5b3c168b
2 changed files with 11 additions and 62 deletions
|
|
@ -71,11 +71,12 @@ public class VehicleImpl implements Vehicle {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
private double fixedCost;
|
/**
|
||||||
private double perDistance;
|
* default cost values for default vehicle type
|
||||||
private double perTime;
|
*/
|
||||||
|
private double fixedCost = 0.0;
|
||||||
// private TimeSchedule timeSchedule = new TimeSchedule(0.0,Integer.MAX_VALUE);
|
private double perDistance = 1.0;
|
||||||
|
private double perTime = 0.0;
|
||||||
|
|
||||||
public Builder(String id, int capacity) {
|
public Builder(String id, int capacity) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -89,11 +90,8 @@ public class VehicleImpl implements Vehicle {
|
||||||
|
|
||||||
public Builder setCostPerTime(double perTime){ this.perTime = perTime; return this; }
|
public Builder setCostPerTime(double perTime){ this.perTime = perTime; return this; }
|
||||||
|
|
||||||
// public Builder setTimeSchedule(TimeSchedule timeSchedule){ this.timeSchedule = timeSchedule; return this; }
|
|
||||||
|
|
||||||
public VehicleType build(){
|
public VehicleType build(){
|
||||||
return new VehicleType(this);
|
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 String typeId;
|
||||||
public final int capacity;
|
public final int capacity;
|
||||||
public final VehicleCostParams vehicleCostParams;
|
public final VehicleCostParams vehicleCostParams;
|
||||||
// private double speed = 22.0;
|
|
||||||
|
|
||||||
private TimeSchedule timeSchedule;
|
|
||||||
|
|
||||||
public static VehicleType newInstance(String typeId, int capacity, VehicleCostParams para){
|
public static VehicleType newInstance(String typeId, int capacity, VehicleCostParams para){
|
||||||
return new VehicleType(typeId, capacity, para);
|
return new VehicleType(typeId, capacity, para);
|
||||||
|
|
@ -139,7 +134,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
typeId = builder.id;
|
typeId = builder.id;
|
||||||
capacity = builder.capacity;
|
capacity = builder.capacity;
|
||||||
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance);
|
vehicleCostParams = new VehicleCostParams(builder.fixedCost, builder.perTime, builder.perDistance);
|
||||||
// timeSchedule = builder.timeSchedule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehicleType(String typeId, int capacity,VehicleCostParams vehicleCostParams) {
|
public VehicleType(String typeId, int capacity,VehicleCostParams vehicleCostParams) {
|
||||||
|
|
@ -156,24 +150,11 @@ public class VehicleImpl implements Vehicle {
|
||||||
public int getCapacity() {
|
public int getCapacity() {
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public TimeSchedule getTimeSchedule() {
|
|
||||||
return timeSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VehicleCostParams getVehicleCostParams() {
|
public VehicleCostParams getVehicleCostParams() {
|
||||||
return vehicleCostParams;
|
return vehicleCostParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public double getSpeed() {
|
|
||||||
// return speed;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setSpeed(double speed) {
|
|
||||||
// this.speed = speed;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[typeId="+typeId+"][capacity="+capacity+"]" + vehicleCostParams;
|
return "[typeId="+typeId+"][capacity="+capacity+"]" + vehicleCostParams;
|
||||||
|
|
@ -206,12 +187,14 @@ public class VehicleImpl implements Vehicle {
|
||||||
public static class VehicleBuilder {
|
public static class VehicleBuilder {
|
||||||
static Logger log = Logger.getLogger(VehicleBuilder.class);
|
static Logger log = Logger.getLogger(VehicleBuilder.class);
|
||||||
private String id;
|
private String id;
|
||||||
private VehicleType type;
|
|
||||||
private String locationId;
|
private String locationId;
|
||||||
private Coordinate locationCoord;
|
private Coordinate locationCoord;
|
||||||
private double earliestStart = 0.0;
|
private double earliestStart = 0.0;
|
||||||
private double latestArrival = Double.MAX_VALUE;
|
private double latestArrival = Double.MAX_VALUE;
|
||||||
|
|
||||||
|
private VehicleType type = VehicleType.Builder.newInstance("default", 0).build();
|
||||||
|
|
||||||
private VehicleBuilder(String id) {
|
private VehicleBuilder(String id) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
@ -243,7 +226,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehicleImpl build(){
|
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) locationId = locationCoord.toString();
|
||||||
if(locationId == null && locationCoord == null) throw new IllegalStateException("locationId and locationCoord is missing.");
|
if(locationId == null && locationCoord == null) throw new IllegalStateException("locationId and locationCoord is missing.");
|
||||||
if(locationCoord == null) log.warn("locationCoord for vehicle " + id + " is missing.");
|
if(locationCoord == null) log.warn("locationCoord for vehicle " + id + " is missing.");
|
||||||
|
|
@ -291,14 +273,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
return coord;
|
return coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setCoord(Coordinate coord) {
|
|
||||||
// this.coord = coord;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void setLocationId(String locationId) {
|
|
||||||
// this.locationId = locationId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
@ -309,18 +283,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
return earliestDeparture;
|
return earliestDeparture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.matsim.contrib.freight.vrp.basics.Vehicle#setEarliestDeparture(double
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
|
|
||||||
// public void setEarliestDeparture(double earliestDeparture) {
|
|
||||||
// this.earliestDeparture = earliestDeparture;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
@ -331,17 +293,6 @@ public class VehicleImpl implements Vehicle {
|
||||||
return latestArrival;
|
return latestArrival;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.matsim.contrib.freight.vrp.basics.Vehicle#setLatestArrival(double)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// public void setLatestArrival(double latestArrival) {
|
|
||||||
// this.latestArrival = latestArrival;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,12 @@ public class ManhattanCosts implements VehicleRoutingTransportCosts {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getTransportCost(String fromId, String toId, double time,
|
public double getTransportCost(String fromId, String toId, double time,Driver driver, Vehicle vehicle) {
|
||||||
Driver driver, Vehicle vehicle) {
|
|
||||||
return calculateDistance(fromId, toId);
|
return calculateDistance(fromId, toId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getTransportTime(String fromId, String toId, double time,
|
public double getTransportTime(String fromId, String toId, double time,Driver driver, Vehicle vehicle) {
|
||||||
Driver driver, Vehicle vehicle) {
|
|
||||||
double transportTime = calculateDistance(fromId, toId) / speed;
|
double transportTime = calculateDistance(fromId, toId) / speed;
|
||||||
return transportTime;
|
return transportTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue