当前位置: 首页>>代码示例>>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;未经允许,请勿转载。