Initial solution for VRP in jsprit

I’m solving a vehicle routing problem with jsprit, I want to set initial solution for it. I get old solution from a file, read it and when I set it as an initial solution I get an error. Here is my code.

  // setting up vrp reader
Collection<VehicleRoutingProblemSolution> solutions = new HashSet<>();
VehicleRoutingProblem.Builder problemBuilder = VehicleRoutingProblem.Builder.newInstance();
VrpXMLReader vrpXMLReader = new VrpXMLReader(problemBuilder, solutions);
VehicleRoutingProblem solutionProblem =;

// after reading solutions from stream
VehicleRoutingProblemSolution initialSolution = Solutions.bestOf(solutions);

And here is the error message

java.lang.IllegalStateException: act in initial solution has no index. activities are created and associated to their job in VehicleRoutingProblem. thus if you build vehicle-routes use the jobActivityFactory from vehicle routing problem like that VehicleRoute.Builder.newInstance(knownVehicle).setJobActivityFactory(vrp.getJobActivityFactory).addService(..) then the activities that are created to build the route are identical to the ones used in VehicleRoutingProblem

What does this mean and how can I fix this ? Thank you in advance.

Powered by Discourse