本文整理汇总了Java中com.graphhopper.jsprit.core.problem.VehicleRoutingProblem类的典型用法代码示例。如果您正苦于以下问题:Java VehicleRoutingProblem类的具体用法?Java VehicleRoutingProblem怎么用?Java VehicleRoutingProblem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VehicleRoutingProblem类属于com.graphhopper.jsprit.core.problem包,在下文中一共展示了VehicleRoutingProblem类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sort
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; //导入依赖的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.problem.VehicleRoutingProblem; //导入依赖的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: buildProblem
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; //导入依赖的package包/类
private void buildProblem(ODLDatastore<? extends ODLTable> ioDb, VRPConfig config,Map<Integer,List<RowVehicleIndex>> overrideVehiclesToBuild,ComponentExecutionApi api) {
// // ensure we can't have stops with the depot names
// stopIdToRow.put(VRPComponent.START_DEPOT_ID, null);
// stopIdToRow.put(VRPComponent.END_DEPOT_ID, null);
this.ioDb = ioDb;
this.dfn = new InputTablesDfn(api.getApi(), config);
this.config = config;
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
if (config.isInfiniteFleetSize() && overrideVehiclesToBuild==null) {
vrpBuilder.setFleetSize(FleetSize.INFINITE);
} else {
vrpBuilder.setFleetSize(FleetSize.FINITE);
}
// build vehicles
BuildBlackboard bb = new BuildBlackboard();
vrpBuilder.addAllVehicles(buildVehicles(overrideVehiclesToBuild,bb));
vrpBuilder.setFleetSize(config.isInfiniteFleetSize() ? FleetSize.INFINITE : FleetSize.FINITE);
// build stops
vrpBuilder.addAllJobs(buildJobs());
// build travel matrix
double meanCostPerMilli = bb.costsPerMillisecond.count>0?bb.costsPerMillisecond.getMean():1;
double meanCostPerMetre = bb.costsPerMetre.count>0? bb.costsPerMetre.getMean():1;
matrix = new VehicleRoutingTransportCostsImpl(config.getDistances(), api,meanCostPerMilli,meanCostPerMetre);
vrpBuilder.setRoutingCost(matrix);
vrpProblem = vrpBuilder.build();
}
示例4: getJspritProblem
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; //导入依赖的package包/类
public VehicleRoutingProblem getJspritProblem() {
return vrpProblem;
}
示例5: solve
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; //导入依赖的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;
}