1
0
Fork 0
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:
oblonski 2016-11-14 10:11:27 +01:00
parent 392167051f
commit ab0acfb1d6
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -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