Package jsprit.core.problem

Examples of jsprit.core.problem.VehicleRoutingProblem


   
    //set fleetsize finite
    vrpBuilder.setFleetSize(FleetSize.FINITE);
   
    //build problem
    VehicleRoutingProblem vrp = vrpBuilder.build();
   
    VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfigWithSchrimpfAcceptance.xml");
    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
   
    VehicleRoutingProblemSolution best = Solutions.bestOf(solutions);
View Full Code Here


    VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
    readDistances(matrixBuilder);

    vrpBuilder.setRoutingCost(matrixBuilder.build());
   
    VehicleRoutingProblem vrp = vrpBuilder.build();
   
    VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp);
    vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
   
View Full Code Here

    new SolomonReader(vrpBuilder).read("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();
   
    /*
     * Build algorithm
     */
    VehicleRoutingAlgorithm vra = buildAlgorithmFromScratch(vrp);
View Full Code Here

    vrpBuilder.setFleetSize(FleetSize.FINITE);
   
    /*
     * build the problem
     */
    VehicleRoutingProblem vrp = vrpBuilder.build();
   
    /*
     * plot to see how the problem looks like
     */
//    SolutionPlotter.plotVrpAsPNG(vrp, "output/problem08.png", "p08");
View Full Code Here

   
    VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
    vrpBuilder.addVehicle(vehicle);
    vrpBuilder.addJob(shipment1).addJob(shipment2).addJob(shipment3).addJob(shipment4);
   
    VehicleRoutingProblem problem = vrpBuilder.build();
   
    /*
     * get the algorithm out-of-the-box.
     */
    VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(problem);
View Full Code Here

   

    /*
     * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
     */
    final VehicleRoutingProblem vrp = vrpBuilder.build();
   
//    new Plotter(vrp).plot("output/vrpwbh_christophides_vrpnc1.png", "pd_vrpnc1");
   
   
    /*
     * Define the required vehicle-routing algorithms to solve the above problem.
     *
     * The algorithm can be defined and configured in an xml-file.
     */
//    VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");

        VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"input/algorithmConfig_solomon.xml");
        vraBuilder.addDefaultCostCalculators();
        vraBuilder.addCoreConstraints();

        StateManager stateManager = new StateManager(vrp);
        ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
        constraintManager.addConstraint(new ServiceDeliveriesFirstConstraint(), ConstraintManager.Priority.CRITICAL);

        vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
        VehicleRoutingAlgorithm vra = vraBuilder.build();



    /*
     * Solve the problem.
     *
     *
     */
    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()){
View Full Code Here

    costMatrixBuilder.addTransportTime("1", "3", 1.0);
    costMatrixBuilder.addTransportTime("2", "3", 2.0);
   
    VehicleRoutingTransportCosts costMatrix = costMatrixBuilder.build();
   
    VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().setFleetSize(FleetSize.INFINITE).setRoutingCost(costMatrix)
        .addVehicle(vehicle).addJob(s1).addJob(s2).addJob(s3).build();
   
    VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/fastAlgo.xml");
   
    Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
View Full Code Here

   
    VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
    vrpBuilder.addVehicle(vehicle).addVehicle(vehicle2);
    vrpBuilder.addJob(service1).addJob(service2).addJob(service3).addJob(service4);
   
    VehicleRoutingProblem problem = vrpBuilder.build();
   
    /*
     * get the algorithm out-of-the-box.
     */
        VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem,"input/algorithmConfig.xml");
View Full Code Here

    Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").addSizeDimension(0, 15).setLocationId("0,10").build();

    VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 50).setCostPerDistance(1).build();
    VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build();

        final VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(delivery).addJob(pickup).addVehicle(vehicle).build();

        VehicleRoute route = VehicleRoute.emptyRoute();
    route.setVehicleAndDepartureTime(vehicle, 0.0);
   
    Inserter inserter = new Inserter(new InsertionListeners(), vrp);
        inserter.insertJob(delivery, new InsertionData(0,0,0,vehicle,null), route);

        JobActivityFactory activityFactory = new JobActivityFactory() {
            @Override
            public List<AbstractActivity> createActivities(Job job) {
                return vrp.copyAndGetActivities(job);
            }
        };

    StateManager stateManager = new StateManager(vrp);
    stateManager.updateLoadStates();
View Full Code Here

                .setType(type2)
                .setReturnToDepot(false)
                .addSkill("joo")
                .build();

        final VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addJob(service2)
                .addVehicle(v1).addVehicle(v2).build();
        new VrpJsonWriter(vrp).write(new File("output/vrp.json"));
//        System.out.println(new VrpJsonWriter(vrp).toString());

        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() {
View Full Code Here

TOP

Related Classes of jsprit.core.problem.VehicleRoutingProblem

Copyright © 2018 www.massapicom. 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.