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);
vrpXMLReader.setSchemaValidation(false);
vrpXMLReader.read(initialSolutionStream);
VehicleRoutingProblem solutionProblem = problemBuilder.build();

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

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(..)....build() 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.

I know this comment was written a long time ago, but for anyone struggling with this problem, the following line of code will help

You should explicity say to your builder what is the initial solution (propably you want the best):

vrpBuilder.addInitialVehicleRoutes(solutions.get(0).getRoutes());

Then you can set initial solution:

algorithm.addInitialSolution(initialSolution);

full code for reading solution from xml

        ArrayList<VehicleRoutingProblemSolution> solutions = new ArrayList<>();
        VrpXMLReader vrpXMLReader = new VrpXMLReader(vrpBuilder, solutions);
        vrpXMLReader.read("testFile.xml");
        vrpBuilder.addInitialVehicleRoutes(solutions.get(0).getRoutes());