Getting only 2 solution which have also same cost?

I try various factor to up and down but the only two solutions I get. So why this is?

You have to be more specific. Include example code or everything which reduces the work for the reader or the one which should answer this :slight_smile:

Sorry but I had tested all the examples give same 2 solutions.

for (VehicleRoutingProblemSolution s : solutions){
	    System.out.println("Solution Cost \n");
        SolutionPrinter.print(problem, s, SolutionPrinter.Print.VERBOSE);
    }
public class SolomonExample {

public static void main(String[] args) {
    /*
     * some preparation - create output folder
	 */
    Examples.createOutputFolder();

	/*
     * Build the problem.
	 *
	 * But define a problem-builder first.
	 */
    VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();

	/*
     * A solomonReader reads solomon-instance files, and stores the required information in the builder.
	 */
    new SolomonReader(vrpBuilder).read("../jsprit/jsprit-examples/input/C101_solomon.txt");


	/*
     * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
	 */
    VehicleRoutingProblem vrp = vrpBuilder.build();

    new Plotter(vrp).plot("output/solomon_C101.png", "C101");

	/*
     * Define the required vehicle-routing algorithms to solve the above problem.
	 *
	 * The algorithm can be defined and configured in an xml-file.
	 */
    VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
    vra.setMaxIterations(20);
	/*
     * Solve the problem.
	 *
	 *
	 */
    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

	/*
     * Retrieve best solution.
	 */

    for (VehicleRoutingProblemSolution s : solutions){
        System.out.println("Solution Cost \n");
        SolutionPrinter.print( s);
    }
}

}

2017-05-30 15:53:28,993 INFO [main] algorithm.VehicleRoutingAlgorithm - iterations end at 200000 iteration
2017-05-30 15:53:28,995 INFO [main] algorithm.VehicleRoutingAlgorithm - took 632.81 seconds
Solution Cost

   [costs=828.936866942834]
   [#vehicles=10]

Solution Cost

[costs=828.936866942834]
[#vehicles=10]

2017-05-30 15:54:07,939 INFO [main] algorithm.VehicleRoutingAlgorithm - took 2.053 seconds
Solution Cost

 [costs=828.9368669428343]
 [#vehicles=10]

Solution Cost

[costs=828.9368669428343]
[#vehicles=10]

The number of solutions returned is defined by the solution memory parameter.
It can be edited using the algorithm xml-file

1 Like

I have also been wondering about the same thing for some time, and this helped figuring that out. However, I am unable to edit the XML file (for another algorithm though). I am using IntelliJ for my project and have imported jsprint (core, analysis, and io) as external libraries. Are you supposed to import them as modules instead, as suggested in the link below?
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206821415-How-to-modify-source-code-for-external-libraries

What is actually the problem here? Do you just need a reason why there are 2 solutions and not n solutions?

Originally, I wanted to know if you could increase the number of solutions up from 2, so that I could have 5 or 10, or more, solutions available to choose from, if I so wanted to.
The problem now is how to do the change.

EDIT: clarification in first sentence

Currently, you can do so by setting your own solution acceptor or you need to modify this line (replace 1 by the number you want). The question is still what you want to achieve by increasing the solution memory. If you just increase the memory of this SchrimpfAcceptor, I assume that the solutions tend to be very similar, i.e. you do not get more info.

In case you are wondering why there are 2 solutions even solution memory is set to 1: The global best is solution will always be memorized additionally. Usually, these 2 solutions are the same. However, there are cases where they differ.

2 Likes

Aah, that helped a lot! Thank you! :smiley: