Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Location l0 = Location.newInstance(43.237235, 76.915048);
- VehicleImpl v1 = VehicleImpl.Builder
- .newInstance("1")
- .setStartLocation(l0)
- .setEarliestStart(0)
- .setReturnToDepot(true)
- .build();
- Location l1 = Location.newInstance(43.239652, 76.887614);
- Location l2 = Location.newInstance(43.25796, 76.911608);
- Location l3 = Location.newInstance(43.225228, 76.893875);
- Location l4 = Location.newInstance(43.25796, 76.911608);
- ManhattanCosts costs = new ManhattanCosts();
- costs.speed = 50;
- System.out.println(costs.getTransportCost(l1, l2, 160, null, v1));
- System.out.println(costs.getTransportTime(l1, l2, 160, null, v1));
- System.out.println(costs.getTransportCost(l1, l3, 160, null, v1));
- System.out.println(costs.getTransportTime(l1, l3, 160, null, v1));
- VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
- Service s1 = Service.Builder
- .newInstance("1")
- .setLocation(l1)
- .setTimeWindow(new TimeWindow(0, 300))
- .setServiceTime(10)
- .build();
- Service s2 = Service.Builder
- .newInstance("2")
- .setLocation(l2)
- .setTimeWindow(new TimeWindow(0, 300))
- .setServiceTime(10)
- .build();
- Service s3 = Service.Builder
- .newInstance("3")
- .setLocation(l3)
- .setTimeWindow(new TimeWindow(0, 300))
- .setServiceTime(10)
- .build();
- Service s4 = Service.Builder
- .newInstance("4")
- .setLocation(l4)
- .setTimeWindow(new TimeWindow(0, 300))
- .setServiceTime(10)
- .build();
- vrpBuilder.addJob(s1);
- vrpBuilder.addJob(s2);
- vrpBuilder.addJob(s3);
- vrpBuilder.addJob(s4);
- vrpBuilder.addVehicle(v1);
- vrpBuilder.setFleetSize(FleetSize.FINITE);
- vrpBuilder.setRoutingCost(new ManhattanCosts());
- VehicleRoutingProblem vrp = vrpBuilder.build();
- VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp)
- .setProperty(Jsprit.Parameter.FAST_REGRET, "true")
- .setProperty(Jsprit.Parameter.THREADS, "4")
- .buildAlgorithm();
- Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
- SolutionPrinter.print(vrp, Solutions.bestOf(solutions), SolutionPrinter.Print.VERBOSE);
- // new Plotter(vrp, Solutions.bestOf(solutions)).setLabel(Plotter.Label.ID).plot("output/p01_solution.png", "p01");
- new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement