mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added internal doc
This commit is contained in:
parent
b125c22619
commit
8ec2e7459a
1 changed files with 35 additions and 1 deletions
|
|
@ -28,25 +28,53 @@ import jsprit.core.util.CalculationUtils;
|
||||||
@Override
|
@Override
|
||||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||||
double latestVehicleArrival = iFacts.getNewVehicle().getLatestArrival();
|
double latestVehicleArrival = iFacts.getNewVehicle().getLatestArrival();
|
||||||
|
/*
|
||||||
|
* if latest arrival of vehicle (at its end) is smaller than earliest operation start times of activities,
|
||||||
|
* then vehicle can never conduct activities.
|
||||||
|
*
|
||||||
|
* |--- vehicle's operation time ---|
|
||||||
|
* |--- prevAct or newAct or nextAct ---|
|
||||||
|
*/
|
||||||
if(latestVehicleArrival < prevAct.getTheoreticalEarliestOperationStartTime() ||
|
if(latestVehicleArrival < prevAct.getTheoreticalEarliestOperationStartTime() ||
|
||||||
latestVehicleArrival < newAct.getTheoreticalEarliestOperationStartTime() ||
|
latestVehicleArrival < newAct.getTheoreticalEarliestOperationStartTime() ||
|
||||||
latestVehicleArrival < nextAct.getTheoreticalEarliestOperationStartTime()){
|
latestVehicleArrival < nextAct.getTheoreticalEarliestOperationStartTime()){
|
||||||
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* if the latest operation start-time of new activity is smaller than the earliest start of prev. activity,
|
||||||
|
* then
|
||||||
|
*
|
||||||
|
* |--- prevAct ---|
|
||||||
|
* |--- newAct ---|
|
||||||
|
*/
|
||||||
if(newAct.getTheoreticalLatestOperationStartTime() < prevAct.getTheoreticalEarliestOperationStartTime()){
|
if(newAct.getTheoreticalLatestOperationStartTime() < prevAct.getTheoreticalEarliestOperationStartTime()){
|
||||||
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* |--- prevAct ---|
|
||||||
|
* |- earliest arrival of vehicle
|
||||||
|
* |--- nextAct ---|
|
||||||
|
*/
|
||||||
double arrTimeAtNextOnDirectRouteWithNewVehicle = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
double arrTimeAtNextOnDirectRouteWithNewVehicle = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), nextAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
||||||
if(arrTimeAtNextOnDirectRouteWithNewVehicle > nextAct.getTheoreticalLatestOperationStartTime()){
|
if(arrTimeAtNextOnDirectRouteWithNewVehicle > nextAct.getTheoreticalLatestOperationStartTime()){
|
||||||
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* |--- newAct ---|
|
||||||
|
* |--- nextAct ---|
|
||||||
|
*/
|
||||||
if(newAct.getTheoreticalEarliestOperationStartTime() > nextAct.getTheoreticalLatestOperationStartTime()){
|
if(newAct.getTheoreticalEarliestOperationStartTime() > nextAct.getTheoreticalLatestOperationStartTime()){
|
||||||
return ConstraintsStatus.NOT_FULFILLED;
|
return ConstraintsStatus.NOT_FULFILLED;
|
||||||
}
|
}
|
||||||
// log.info("check insertion of " + newAct + " between " + prevAct + " and " + nextAct + ". prevActDepTime=" + prevActDepTime);
|
// log.info("check insertion of " + newAct + " between " + prevAct + " and " + nextAct + ". prevActDepTime=" + prevActDepTime);
|
||||||
double arrTimeAtNewAct = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
double arrTimeAtNewAct = prevActDepTime + routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
||||||
double latestArrTimeAtNewAct = states.getActivityState(newAct, StateFactory.LATEST_OPERATION_START_TIME, Double.class);
|
double latestArrTimeAtNewAct = states.getActivityState(newAct, StateFactory.LATEST_OPERATION_START_TIME, Double.class);
|
||||||
|
/*
|
||||||
|
* |--- prevAct ---|
|
||||||
|
* |--- vehicle's arrival @newAct
|
||||||
|
* latest arrival of vehicle @newAct ---|
|
||||||
|
*/
|
||||||
if(arrTimeAtNewAct > latestArrTimeAtNewAct){
|
if(arrTimeAtNewAct > latestArrTimeAtNewAct){
|
||||||
return ConstraintsStatus.NOT_FULFILLED;
|
return ConstraintsStatus.NOT_FULFILLED;
|
||||||
}
|
}
|
||||||
|
|
@ -54,9 +82,15 @@ import jsprit.core.util.CalculationUtils;
|
||||||
double endTimeAtNewAct = CalculationUtils.getActivityEndTime(arrTimeAtNewAct, newAct);
|
double endTimeAtNewAct = CalculationUtils.getActivityEndTime(arrTimeAtNewAct, newAct);
|
||||||
double arrTimeAtNextAct = endTimeAtNewAct + routingCosts.getTransportTime(newAct.getLocationId(), nextAct.getLocationId(), endTimeAtNewAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
double arrTimeAtNextAct = endTimeAtNewAct + routingCosts.getTransportTime(newAct.getLocationId(), nextAct.getLocationId(), endTimeAtNewAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
|
||||||
double latestArrTimeAtNextAct = states.getActivityState(nextAct, StateFactory.LATEST_OPERATION_START_TIME, Double.class);
|
double latestArrTimeAtNextAct = states.getActivityState(nextAct, StateFactory.LATEST_OPERATION_START_TIME, Double.class);
|
||||||
|
/*
|
||||||
|
* |--- newAct ---|
|
||||||
|
* |--- vehicle's arrival @nextAct
|
||||||
|
* latest arrival of vehicle @nextAct ---|
|
||||||
|
*/
|
||||||
if(arrTimeAtNextAct > latestArrTimeAtNextAct){
|
if(arrTimeAtNextAct > latestArrTimeAtNextAct){
|
||||||
return ConstraintsStatus.NOT_FULFILLED;
|
return ConstraintsStatus.NOT_FULFILLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if vehicle cannot even manage direct-route - break
|
// if vehicle cannot even manage direct-route - break
|
||||||
if(arrTimeAtNextOnDirectRouteWithNewVehicle > latestArrTimeAtNextAct){
|
if(arrTimeAtNextOnDirectRouteWithNewVehicle > latestArrTimeAtNextAct){
|
||||||
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
return ConstraintsStatus.NOT_FULFILLED_BREAK;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue