mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
reproduce bug #297
This commit is contained in:
parent
392167051f
commit
ab0acfb1d6
1 changed files with 25 additions and 0 deletions
|
|
@ -30,6 +30,8 @@ import com.graphhopper.jsprit.core.problem.job.Pickup;
|
||||||
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
||||||
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
import com.graphhopper.jsprit.core.problem.misc.JobInsertionContext;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||||
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.End;
|
||||||
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.Start;
|
||||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||||
|
|
@ -109,6 +111,29 @@ public class VehicleDependentTraveledDistanceTest {
|
||||||
stateManager.informInsertionStarts(Arrays.asList(route), Collections.<Job>emptyList());
|
stateManager.informInsertionStarts(Arrays.asList(route), Collections.<Job>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenEndLocationIsSet_constraintShouldWork(){
|
||||||
|
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0))
|
||||||
|
.setEndLocation(Location.newInstance(10,0)).build();
|
||||||
|
Pickup pickup = Pickup.Builder.newInstance("pickup").setLocation(Location.newInstance(10,0)).build();
|
||||||
|
vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).addJob(pickup).build();
|
||||||
|
route = VehicleRoute.emptyRoute();
|
||||||
|
maxDistanceMap = new HashMap<>();
|
||||||
|
maxDistanceMap.put(vehicle,5d);
|
||||||
|
|
||||||
|
MaxDistanceConstraint maxDistanceConstraint =
|
||||||
|
new MaxDistanceConstraint(new StateManager(vrp), traveledDistanceId, new TransportDistance() {
|
||||||
|
@Override
|
||||||
|
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||||
|
return vrp.getTransportCosts().getTransportTime(from,to,departureTime, null, vehicle);
|
||||||
|
}
|
||||||
|
},maxDistanceMap);
|
||||||
|
JobInsertionContext context = new JobInsertionContext(route,pickup,vehicle,null,0);
|
||||||
|
Assert.assertTrue(maxDistanceConstraint.fulfilled(context,
|
||||||
|
new Start(vehicle.getStartLocation(),0,Double.MAX_VALUE),vrp.getActivities(pickup).get(0),
|
||||||
|
new End(vehicle.getEndLocation(),0,Double.MAX_VALUE),0).equals(HardActivityConstraint.ConstraintsStatus.NOT_FULFILLED));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
vehicle: 200.0
|
vehicle: 200.0
|
||||||
vehicle (max distance): 200.0
|
vehicle (max distance): 200.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue