I’ve sent you my code to export into JSON privatly as a start. Did you get it? It needs gson library.
It exports the solution into JSON.
To tell you the truth, it is not clear what you wished to write. I don’t see how distance matrix calls interfere with solution export?
Using Jsprit, being a genetic algorithm is time consuming by itself. (You can’t help it.) I don’t really see how any export/import tasks would cause any real time impact compared to the time consumption by running jspit.
If your distance matrix calls are time-expensive, but static (doesn’t depend on the current solution), you could choose one of these.
(1) Pre-render the whole distance matrix before running Jsplit. It
(2) Cache the calculated values while running Jsplit. This is best, when there are many dependencies and you suspect that just a small percentage of the whole matrix will ever be queried. This usually needs less memory (than whole matrix), requires only a Map<> object.
Although the possibility to do any of this depends on the number of different locations in the problem you are about to solve. The feasibility of using any of the above strongly depends on other factors, like how expensive to calculate it, how many iterations Jsprit will do, what are the mutation parameters of the algorithm.
But as a main rule: if distance calculation is static (doesn’t depends on any solution parameters) and not extremely fast, it is always the caching is the best solution.