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


Java VehicleRoutingProblem類代碼示例

本文整理匯總了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);
}
 
開發者ID:MayerTh,項目名稱:RVRPSimulator,代碼行數:23,代碼來源:JspritUnloadContainerSorter.java

示例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;
}
 
開發者ID:MayerTh,項目名稱:RVRPSimulator,代碼行數:33,代碼來源:JspritSolver.java

示例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();
	}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:34,代碼來源:VRPBuilder.java

示例4: getJspritProblem

import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; //導入依賴的package包/類
public VehicleRoutingProblem getJspritProblem() {
	return vrpProblem;
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:4,代碼來源:VRPBuilder.java

示例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;

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


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