本文整理汇总了Java中com.graphhopper.jsprit.core.util.Solutions类的典型用法代码示例。如果您正苦于以下问题:Java Solutions类的具体用法?Java Solutions怎么用?Java Solutions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Solutions类属于com.graphhopper.jsprit.core.util包,在下文中一共展示了Solutions类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sort
import com.graphhopper.jsprit.core.util.Solutions; //导入依赖的package包/类
public List<CustomersStillToServe> sort(List<CustomersStillToServe> containersToSort, CustomersStillToServe newCustomer, IVehicle vehicle, vrpsim.core.model.network.Location currentLocationOfVehicle,
vrpsim.core.model.network.Location depot, String instanceName, String statisticsOutputFolder, boolean createStatistics) {
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
try {
vrpBuilder.addAllVehicles(buildJspritVehicles(vehicle, currentLocationOfVehicle));
vrpBuilder.addAllJobs(buildJspritServices(containersToSort));
} catch (VRPArithmeticException e) {
logger.error("Can not build vehicles/jobs for Jsprit sorter. ");
e.printStackTrace();
}
VehicleRoutingProblem problem = vrpBuilder.build();
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions);
return translate(bestSolution, containersToSort);
}
示例2: solve
import com.graphhopper.jsprit.core.util.Solutions; //导入依赖的package包/类
public VehicleRoutingProblemSolution solve(StructureService structureService, String instanceName, String statisticsOutputFolder, boolean createStatistics)
throws VRPArithmeticException {
String name = instanceName;
// Double maxCapa = null;
// if (overwriteVehicleCapacityWithMaxCapacity) {
// maxCapa = getMaxNeededCapacity(structureService.getCustomers());
// }
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addAllVehicles(buildJspritVehicles(structureService.getVehicles()));
vrpBuilder.addAllJobs(buildJspritServices(structureService.getCustomers()));
VehicleRoutingProblem problem = vrpBuilder.build();
if (createStatistics) {
new Plotter(problem).plot(statisticsOutputFolder + "/jsprit-problem" + name + ".png", instanceName + " problem");
}
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions);
Double cost = bestSolution.getCost();
if (createStatistics) {
new Plotter(problem, Solutions.bestOf(solutions)).plot(statisticsOutputFolder + "/jsprit-solution" + name + "_cost=" + round(cost, 2) + ".png",
instanceName + " cost=" + cost);
SolutionPrinter.print(problem, bestSolution, Print.VERBOSE);
}
return bestSolution;
}
示例3: solve
import com.graphhopper.jsprit.core.util.Solutions; //导入依赖的package包/类
public VehicleRoutingProblemSolution solve(Instance instance, String statisticsOutputFolder, boolean overwriteVehicleCapacityWithMaxCapacity) {
String name = instance.getInfo().getName();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addAllJobs(buildJspritServices(instance.getRequests().getRequest(), instance.getNetwork()));
Double maxCapa = null;
if(overwriteVehicleCapacityWithMaxCapacity) {
maxCapa = getMaxNeededCapacity(instance.getRequests().getRequest());
}
vrpBuilder.addAllVehicles(buildJspritVehicles(instance.getFleet().getVehicleProfile(), instance.getNetwork(), maxCapa));
VehicleRoutingProblem problem = vrpBuilder.build();
new Plotter(problem).plot(statisticsOutputFolder + "/jsprit-problem-" + name + ".png", "problem01");
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
VehicleRoutingProblemSolution bestSolution = Solutions.bestOf(solutions);
Double cost = bestSolution.getCost();
new Plotter(problem, Solutions.bestOf(solutions)).plot(statisticsOutputFolder + "/jsprit-solution-" + name + "-cost=" + cost + ".png", name + " cost=" + cost);
SolutionPrinter.print(problem, bestSolution, Print.VERBOSE);
return bestSolution;
}