當前位置: 首頁>>代碼示例>>Java>>正文


Java VehicleRoutingAlgorithm類代碼示例

本文整理匯總了Java中com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm的典型用法代碼示例。如果您正苦於以下問題:Java VehicleRoutingAlgorithm類的具體用法?Java VehicleRoutingAlgorithm怎麽用?Java VehicleRoutingAlgorithm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VehicleRoutingAlgorithm類屬於com.graphhopper.jsprit.core.algorithm包,在下文中一共展示了VehicleRoutingAlgorithm類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sort

import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm; //導入依賴的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);
}
 
開發者ID:MayerTh,項目名稱:RVRPSimulator,代碼行數:23,代碼來源:JspritUnloadContainerSorter.java

示例2: solve

import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm; //導入依賴的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;
}
 
開發者ID:MayerTh,項目名稱:RVRPSimulator,代碼行數:33,代碼來源:JspritSolver.java

示例3: solve

import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm; //導入依賴的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;

	}
 
開發者ID:MayerTh,項目名稱:RVRPSimulator,代碼行數:29,代碼來源:JspritVRPREPInstanceSolver.java


注:本文中的com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。