I have a case, where I need to ignore the first leg of the route, and just start considering the route/distance, etc., starting from the first point found
I think about add it on contrains, but, i don’t know what to add …
constraintManager.addConstraint(object : HardRouteConstraint {
override fun fulfilled(insertionContext: JobInsertionContext?): Boolean {
val shipment2insert = (insertionContext!!.job as Shipment)
// This is just a test....
val pickupLatitude = shipment2insert.pickupLocation.coordinate.y
val pickupLongitude = shipment2insert.pickupLocation.coordinate.x
val deliveryLatitude = shipment2insert.deliveryLocation.coordinate.y
val deliveryLongitude = shipment2insert.deliveryLocation.coordinate.x
if (insertionContext.newVehicle.id.equals("v1")) {
if (pickupLongitude > 15.0 || deliveryLongitude > 15.0) {
return false
}
}
if (insertionContext.newVehicle.id.equals("v2")) {
if (pickupLongitude < 15.0 || deliveryLongitude < 15.0) {
return false
}
}
return true
}
})
for each vehicles, I have some limitations, like max time travel:
for (i in 1..numVehicles) {
val vehicleType = VehicleTypeImpl.Builder.newInstance("vehicleType_$i")
.addCapacityDimension(0, maxStopsPerVehicle)
.build()
val vehicle = VehicleImpl.Builder.newInstance("vehicle_$i")
.setStartLocation(Location.Builder.newInstance().setId("location_vehicle_$i").setCoordinate(Coordinate.newInstance(midLon, midLat)).build())
.setType(vehicleType)
.setReturnToDepot(false)
.setLatestArrival(10*60.0)
.build()
vrpBuilder.addVehicle(vehicle)
}