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

shift from vehicle.getLocation() to vehicle.getStartLocation() and

vehicle.getCoord() to vehicle.getStartLocationCoordinate()
This commit is contained in:
Stefan Schroeder 2014-01-28 17:40:13 +01:00
parent e5dabbdf64
commit a234bb54c9
36 changed files with 195 additions and 137 deletions

View file

@ -86,9 +86,15 @@ class InsertionFactory {
String weight = config.getString("considerFixedCosts[@weight]");
if(weight == null) weight = config.getString("considerFixedCost[@weight]");
if(weight != null) fixedCostWeight = Double.parseDouble(weight);
else log.warn("parameter considerFixedCosts[@weight] is missing. by default, it is 0.5.");
else throw new IllegalStateException("fixedCostsParameter 'weight' must be set, e.g. <considerFixedCosts weight=1.0>true</considerFixedCosts>.\n" +
"this has to be changed in algorithm-config-xml-file.");
iBuilder.considerFixedCosts(fixedCostWeight);
}
else if(val.equals("false")){
}
else throw new IllegalStateException("considerFixedCosts must either be true or false, i.e. <considerFixedCosts weight=1.0>true</considerFixedCosts> or \n<considerFixedCosts weight=1.0>false</considerFixedCosts>. " +
"if latter, you can also omit the tag. this has to be changed in algorithm-config-xml-file");
}
String timeSliceString = config.getString("experimental[@timeSlice]");
String neighbors = config.getString("experimental[@neighboringSlices]");

View file

@ -481,9 +481,6 @@ public class VehicleRoutingAlgorithms {
@Override
public void finish() {
if(firstAct){
assert vehicle.getLocationId() == end.getLocationId() : "route end and last activity are not equal even route is open. this should not be.";
}
firstAct = true;
}

View file

@ -106,9 +106,9 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
TourActivity deliveryAct2Insert = activityFactory.createActivity(service);
Start start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime);
End end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival());
End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
TourActivity prevAct = start;
double prevActStartTime = newVehicleDepartureTime;

View file

@ -314,22 +314,22 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
*/
private void initialiseStartAndEnd(final Vehicle newVehicle, double newVehicleDepartureTime) {
if(start == null){
start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime);
}
else{
start.setLocationId(newVehicle.getLocationId());
start.setLocationId(newVehicle.getStartLocationId());
start.setTheoreticalEarliestOperationStartTime(newVehicle.getEarliestDeparture());
start.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival());
start.setTheoreticalLatestOperationStartTime(Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime);
}
if(end == null){
end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival());
end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
}
else{
end.setLocationId(newVehicle.getLocationId());
end.setTheoreticalEarliestOperationStartTime(newVehicleDepartureTime);
end.setLocationId(newVehicle.getEndLocationId());
end.setTheoreticalEarliestOperationStartTime(0.0);
end.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival());
}
}

View file

@ -100,10 +100,10 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator{
int pickupInsertionIndex = InsertionData.NO_INDEX;
int deliveryInsertionIndex = InsertionData.NO_INDEX;
Start start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
start.setEndTime(newVehicleDepartureTime);
End end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival());
End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
TourActivity prevAct = start;
double prevActEndTime = newVehicleDepartureTime;

View file

@ -327,7 +327,11 @@ public class VehicleRoutingProblem {
if(!vehicleTypes.contains(vehicle.getType())){
vehicleTypes.add(vehicle.getType());
}
coordinates.put(vehicle.getLocationId(), vehicle.getCoord());
String startLocationId = vehicle.getStartLocationId();
coordinates.put(startLocationId, vehicle.getStartLocationCoordinate());
if(!vehicle.getEndLocationId().equals(startLocationId)){
coordinates.put(vehicle.getEndLocationId(), vehicle.getEndLocationCoordinate());
}
return this;
}
@ -373,7 +377,7 @@ public class VehicleRoutingProblem {
Set<LocTypeKey> locTypeKeys = new HashSet<LocTypeKey>();
List<Vehicle> uniqueVehicles = new ArrayList<Vehicle>();
for(Vehicle v : vehicles){
LocTypeKey key = new LocTypeKey(v.getLocationId(),v.getType().getTypeId());
LocTypeKey key = new LocTypeKey(v.getStartLocationId(),v.getType().getTypeId());
if(!locTypeKeys.contains(key)){
uniqueVehicles.add(v);
locTypeKeys.add(key);
@ -390,9 +394,10 @@ public class VehicleRoutingProblem {
.setFixedCost(fixed)
.build();
PenaltyVehicleType penType = new PenaltyVehicleType(t,penaltyFactor);
String vehicleId = "penaltyVehicle_" + v.getLocationId() + "_" + t.getTypeId();
String vehicleId = "penaltyVehicle_" + v.getStartLocationId() + "_" + t.getTypeId();
Vehicle penVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(v.getEarliestDeparture())
.setLatestArrival(v.getLatestArrival()).setLocationCoord(v.getCoord()).setLocationId(v.getLocationId())
.setLatestArrival(v.getLatestArrival()).setStartLocationCoordinate(v.getStartLocationCoordinate()).setLocationId(v.getStartLocationId())
.setEndLocationId(v.getEndLocationId()).setEndLocationCoordinate(v.getEndLocationCoordinate())
.setReturnToDepot(v.isReturnToDepot()).setType(penType).build();
addVehicle(penVehicle);
}

View file

@ -165,7 +165,7 @@ public class VehicleRoute {
this.driver = driver;
start = Start.newInstance(vehicle.getStartLocationId(), vehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(vehicle.getEarliestDeparture());
end = End.newInstance(vehicle.getLocationId(), 0.0, vehicle.getLatestArrival());
end = End.newInstance(vehicle.getEndLocationId(), 0.0, vehicle.getLatestArrival());
}
/**

View file

@ -47,7 +47,9 @@ public interface Vehicle {
* <p> Consequently, it should be the end-location of this vehicle, if returnToDepot is true.
*
* @return location-id of this vehicle
* @deprecated use getStartLocationId() instead
*/
@Deprecated
public abstract String getLocationId();
/**
@ -56,7 +58,9 @@ public interface Vehicle {
* <p> Consequently, it should be the coordinate of the end-location, if returnToDepot is true.
*
* @return coordinate of this vehicle
* @deprecated use getStartLocationCoordinate() instead
*/
@Deprecated
public abstract Coordinate getCoord();
/**

View file

@ -176,10 +176,8 @@ public class VehicleImpl implements Vehicle {
*
* @param coord
* @return this builder
* @throws IllegalArgumentException if start-coordinate is null
*/
public Builder setStartLocationCoordinate(Coordinate coord){
if(coord == null) throw new IllegalArgumentException("start-coordinate must not be null");
this.startLocationCoord = coord;
this.locationCoord = coord;
return this;
@ -190,10 +188,8 @@ public class VehicleImpl implements Vehicle {
*
* @param endLocationId
* @return this builder
* @throws IllegalArgumentException if endLocation is null
*/
public Builder setEndLocationId(String endLocationId){
if(endLocationId == null) throw new IllegalArgumentException("end-locationId must not be null");
this.endLocationId = endLocationId;
return this;
}
@ -203,10 +199,8 @@ public class VehicleImpl implements Vehicle {
*
* @param coord
* @return this builder
* @throws IllegalArgumentException if coord is null
*/
public Builder setEndLocationCoordinate(Coordinate coord){
if(coord == null) throw new IllegalArgumentException("end-coordinate must not be null");
this.endLocationCoord = coord;
return this;
}
@ -336,6 +330,10 @@ public class VehicleImpl implements Vehicle {
return "[id="+id+"][type="+type+"][locationId="+locationId+"][coord=" + coord + "][isReturnToDepot=" + isReturnToDepot() + "]";
}
/**
* @deprecated use getStartLocationCoordinate() instead
*/
@Deprecated
public Coordinate getCoord() {
return coord;
}
@ -350,6 +348,10 @@ public class VehicleImpl implements Vehicle {
return latestArrival;
}
/**
* @deprecated use getStartLocationId() instead
*/
@Deprecated
@Override
public String getLocationId() {
return locationId;

View file

@ -226,7 +226,8 @@
<xs:extension base="xs:string">
<xs:attribute name="weight" type="xs:double"/>
</xs:extension>
</xs:simpleContent>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="allowVehicleSwitch" type="xs:boolean" minOccurs="0" maxOccurs="1"/>