Package jsprit.core.algorithm

Source Code of jsprit.core.algorithm.ExternalInitialSolutionIsInValidTest

package jsprit.core.algorithm;

import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.reporting.SolutionPrinter;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collection;

/**
* Created by schroeder on 24.07.14.
*/
public class ExternalInitialSolutionIsInValidTest {

    @Test
    public void itShouldSolveProblemWithIniSolutionExternallyCreated(){

        Service s1 = Service.Builder.newInstance("s1").setCoord(Coordinate.newInstance(10,0)).build();
        Service s2 = Service.Builder.newInstance("s2").setCoord(Coordinate.newInstance(0,10)).build();

        VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v1").setStartLocationCoordinate(Coordinate.newInstance(0,0)).build();

        VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s1).addJob(s2).addVehicle(vehicle).build();

        VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithm_without_construction.xml");

        VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v1").setStartLocationCoordinate(Coordinate.newInstance(0,0)).build();
        /*
        create ini sol
         */
        VehicleRoute route1 = VehicleRoute.Builder.newInstance(vehicle).setJobActivityFactory(vrp.getJobActivityFactory()).addService(s1).build();

        vra.addInitialSolution(new VehicleRoutingProblemSolution(Arrays.asList(route1),20.));

        Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

        SolutionPrinter.print(vrp, Solutions.bestOf(solutions), SolutionPrinter.Print.VERBOSE);


    }

}
TOP

Related Classes of jsprit.core.algorithm.ExternalInitialSolutionIsInValidTest

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.