Problems defining an initial route with services and with break

I need to define an initial route listing the sequence of services and also including the break,
My vehicle includes a break:

private static VehicleImpl.Builder createVehicle(String nombre, String codigo, double coordx, double coordy,
String codigofinal, double coordxfinal, double coordyfinal,
boolean retornoBase, VehicleType vehicleType) {

    VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(nombre);
    jsprit.core.problem.Location locationStart = jsprit.core.problem.Location.Builder.newInstance().setId(codigo)
            .setCoordinate(jsprit.core.util.Coordinate.newInstance(coordx, coordy)).build();
    vehicleBuilder.setStartLocation(locationStart);
    jsprit.core.problem.Location locationEnd = jsprit.core.problem.Location.Builder.newInstance().setId(codigofinal)
            .setCoordinate(jsprit.core.util.Coordinate.newInstance(coordxfinal, coordyfinal)).build();
    vehicleBuilder.setEndLocation(locationEnd);
    vehicleBuilder.setReturnToDepot(retornoBase);
    vehicleBuilder.setEarliestStart(8.00);
    vehicleBuilder.setLatestArrival(17.00);
  
        Break almuerzo = Break.Builder.newInstance("AL_" + nombre)
                .setTimeWindow(TimeWindow.newInstance(12.00, 14.00)).setPriority(1).setServiceTime(0.57).build();
        vehicleBuilder.setBreak(almuerzo);
        
    vehicleBuilder.setType(vehicleType);
    return vehicleBuilder;
}

My initial route is:

VehicleRoute.Builder rutab = VehicleRoute.Builder.newInstance(getVehicle(nombreV, vrpBuilder));
// if add this sentence lounch an error in vehicleroute
// Break almuerzo = Break.Builder.newInstance(“AL_00”)
// .setTimeWindow(TimeWindow.newInstance(hor_inic_prin_A, hor_finl_prin_A - 0.05)).setPriority(1).setServiceTime(tiemporefrigerio).build();
// rutab.addBreak(almuerzo);
while (resultado1.next()) {
String servicio = resultado1.getInt(“cod_servicio_final”) + “”;
Service servicio2 = null;
servicio2 = getService(servicio, vrpBuilder);
rutab.addService(servicio2);
}
VehicleRoute ruta = rutab.build();
vrpBuilder.addInitialVehicleRoute(ruta);

if I define only the services of the initial route, the result is a route without break, if I add to the initial route a break out or error in the definition of the vehiculeroute

How can I do this operation

Thanks

Everything is correct, was my mistake to use the break service in 30 minutes, typing 30 and not 0.5 hours because my unit of time is hour

Thank you

1 Like