Examples of VehicleRoutingProblemSolution


Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
   
    /*
     * Retrieve best solution.
     */
    VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
   
    /*
     * print solution
     */
    SolutionPrinter.print(solution);
   
    /*
     * Plot solution.
     */
//    SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/pd_solomon_r101_solution.png","pd_r101");
//    Plotter plotter = new Plotter(vrp, solution);
//    plotter.setLabel(Label.SIZE);
//    plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png","vrpwbh_vrpnc1");

        SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new SolutionAnalyser.DistanceCalculator() {

            @Override
            public double getDistance(String fromLocationId, String toLocationId) {
                return vrp.getTransportCosts().getTransportCost(fromLocationId,toLocationId,0.,null,null);
            }

        });

        for(VehicleRoute route : solution.getRoutes()){
            System.out.println("------");
            System.out.println("vehicleId: " + route.getVehicle().getId());
            System.out.println("vehicleCapacity: " + route.getVehicle().getType().getCapacityDimensions() + " maxLoad: " + analyser.getMaxLoad(route));
            System.out.println("totalDistance: " + analyser.getDistance(route));
            System.out.println("waitingTime: " + analyser.getWaitingTime(route));
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
   
    /*
     * get the best
     */
    VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions);
   
    new VrpXMLWriter(problem, solutions).write("output/problem-with-solution.xml");
   
    SolutionPrinter.print(problem, bestSolution, SolutionPrinter.Print.VERBOSE);
   
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

        VehicleRoutingProblem.Builder vrpBuilder_ = VehicleRoutingProblem.Builder.newInstance();
        new VrpJsonReader(vrpBuilder_).read("output/vpr.json");
        VehicleRoutingProblem vrp_ = vrpBuilder_.build();

        VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp_);
        VehicleRoutingProblemSolution solutions = Solutions.bestOf(vra.searchSolutions());

        new VrpJsonWriter(vrp,solutions,new SolutionAnalyser.DistanceCalculator() {

            @Override
            public double getDistance(String fromLocationId, String toLocationId) {
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

public class SelectBestTest {
 
  @Test
  public void whenHaving2Solutions_selectBest(){
    VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class);
    VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class);
    when(sol1.getCost()).thenReturn(1.0);
    when(sol2.getCost()).thenReturn(2.0);
    assertThat(new SelectBest().selectSolution(Arrays.asList(sol1,sol2)), is(sol1));
  }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

    assertThat(new SelectBest().selectSolution(Arrays.asList(sol1,sol2)), is(sol1));
  }
 
  @Test
  public void whenHavingOnly1Solutions_selectThisOne(){
    VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class);
    when(sol1.getCost()).thenReturn(1.0);
    assertThat(new SelectBest().selectSolution(Arrays.asList(sol1)), is(sol1));
  }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

        VehicleRoutingAlgorithm vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
        vra.addListener(stateManager);
        vra.addListener(new RemoveEmptyVehicles(fleetManager));

        VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
        vra.addInitialSolution(iniSolution);

        vra.setNuOfIterations(3);
    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
    assertTrue(!solutions.isEmpty());
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

public class SelectRandomlyTest {
 
  @Test
  public void whenHaving2Solutions_selectSecond(){
    VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class);
    VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class);
 
    when(sol1.getCost()).thenReturn(1.0);
    when(sol2.getCost()).thenReturn(2.0);
   
    Random random = mock(Random.class);
    when(random.nextInt(2)).thenReturn(1);

    SelectRandomly selectRandomly = new SelectRandomly();
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

  }
 
  @Test
  public void whenHaving2Solutions_selectFirst(){
   
    VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class);
    VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class);
   
    when(sol1.getCost()).thenReturn(1.0);
    when(sol2.getCost()).thenReturn(2.0);
   
    Random random = mock(Random.class);
    when(random.nextInt(2)).thenReturn(0);

    SelectRandomly selectRandomly = new SelectRandomly();
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

        VehicleRoutingProblem vrp = builder.build();
        VehicleRoutingAlgorithm algorithm = new GreedySchrimpfFactory().createAlgorithm(vrp);
        algorithm.setMaxIterations(10);
        Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();

        VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
        assertTrue(!solution.getUnassignedJobs().contains(job1));
        assertTrue(solution.getUnassignedJobs().contains(job2));
    }
View Full Code Here

Examples of jsprit.core.problem.solution.VehicleRoutingProblemSolution

        VehicleRoutingProblem vrp = builder.build();
        VehicleRoutingAlgorithm algorithm = new GreedySchrimpfFactory().createAlgorithm(vrp);
        algorithm.setMaxIterations(10);
        Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();

        VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
        assertTrue(!solution.getUnassignedJobs().contains(job1));
        assertTrue(solution.getUnassignedJobs().contains(job2));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.