本文整理汇总了Java中com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute类的典型用法代码示例。如果您正苦于以下问题:Java VehicleRoute类的具体用法?Java VehicleRoute怎么用?Java VehicleRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VehicleRoute类属于com.graphhopper.jsprit.core.problem.solution.route包,在下文中一共展示了VehicleRoute类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
private List<CustomersStillToServe> translate(VehicleRoutingProblemSolution solution, List<CustomersStillToServe> containersToSort) {
logger.info("Unsorted customers {}", containersToSort);
if (solution.getUnassignedJobs().size() > 0) {
logger.error("There unassigned joby in the Jsprit solution.");
throw new RuntimeException("There unassigned joby in the Jsprit solution.");
}
List<CustomersStillToServe> sorted = new ArrayList<>();
for (VehicleRoute vehicleRoute : solution.getRoutes()) {
for (TourActivity tourActivity : vehicleRoute.getActivities()) {
if (tourActivity instanceof DeliverService) {
CustomersStillToServe unloadBy = getUnloadByByLocation(containersToSort, tourActivity.getLocation());
int amount = tourActivity.getSize().getNuOfDimensions();
sorted.add(new CustomersStillToServe(unloadBy.getCustomer(), unloadBy.getStoreableParameters(), amount));
}
}
}
if (sorted.size() != containersToSort.size()) {
logger.error("There are not searverd customers in the Jsprit solution.");
throw new RuntimeException("There are not searverd customers in the Jsprit solution.");
}
logger.info("Sorted customers {}", sorted);
return sorted;
}
示例2: fillInRouteStats
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
private void fillInRouteStats() {
for (final RouteDetail rd : vehicleIdToRouteDetails.values()) {
VehicleRoute vr = rd.temp.jspritRoute;
rd.travelCosts[TravelCostType.DISTANCE_KM.ordinal()] = jspritSA.getDistance(vr);
rd.travelCosts[TravelCostType.TIME.ordinal()] = jspritSA.getTransportTime(vr);
rd.travelCosts[TravelCostType.COST.ordinal()] = jspritSA.getVariableTransportCosts(vr);
rd.waitingTime = jspritSA.getWaitingTime(vr);
rd.timeWindowViolation = jspritSA.getTimeWindowViolation(vr);
copyQuantities(jspritSA.getCapacityViolation(vr), rd.capacityViolation);
copyQuantities(jspritSA.getLoadDelivered(vr), rd.deliveredQuantities);
copyQuantities(jspritSA.getLoadPickedUp(vr), rd.pickedUpQuantities);
copyQuantities(jspritSA.getLoadAtBeginning(vr), rd.startQuantities);
rd.pickupsCount = jspritSA.getNumberOfPickups(vr);
rd.deliveriesCount = jspritSA.getNumberOfDeliveries(vr);
// start and end times
if(vr.getStart()!=null){
rd.startTime = vr.getStart().getEndTime();
}
if(vr.getEnd()!=null){
rd.endTime = vr.getEnd().getArrTime();
}
rd.time = rd.endTime - rd.startTime;
// update hasViolation
for (StopDetail sd : rd.stops) {
if (sd.hasViolation == 1) {
rd.hasViolation = 1;
}
}
if ((config.isDeliveriesBeforePickups() && jspritSA.hasBackhaulConstraintViolation(vr)) || jspritSA.hasShipmentConstraintViolation(vr) || jspritSA.hasSkillConstraintViolation(vr)) {
rd.hasViolation = 1;
}
}
}
示例3: informBeforeJobInsertion
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void informBeforeJobInsertion(Job job, InsertionData id, VehicleRoute vr) {}
示例4: getStopOrder
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
private static List<StopOrder> getStopOrder(ODLApi api, ODLDatastore<? extends ODLTable> ioDb, VRPConfig conf,
VRPBuilder built, VehicleRoutingProblemSolution bestSolution) {
ArrayList<StopOrder> ret = new ArrayList<>();
final InputTablesDfn dfn = new InputTablesDfn(api, conf);
ODLTableReadOnly jobsTable = ioDb.getTableByImmutableId(dfn.stops.tableId);
// Get map of vehicle ids to original vehicle records
ODLTableReadOnly vehiclesTable = ioDb.getTableByImmutableId(dfn.vehicles.tableId);
Map<String, RowVehicleIndex> vehicleRowIndices = dfn.vehicles.getVehicleIdToRowIndex(vehiclesTable);
Set<String> usedVehicleIds = api.stringConventions().createStandardisedSet();
for (VehicleRoute route : bestSolution.getRoutes()) {
Vehicle vehicle = route.getVehicle();
// // consider this route a not-load if this is a penalty vehicle ... don't output it....
// if (PenaltyVehicleType.class.isInstance(vehicle.getType())) {
// continue;
// }
// If fleet size is infinite we have repeated vehicle ids and should use the naming convention to append a
// number
String vehicleId = vehicle.getId();
if (conf.isInfiniteFleetSize()) {
RowVehicleIndex rvi = vehicleRowIndices.get(vehicleId);
String baseId = dfn.vehicles.getBaseId(vehiclesTable, rvi.row);
// find the lowest unused index
int index = 0;
while (true) {
vehicleId = api.stringConventions().getVehicleId(baseId, Integer.MAX_VALUE, index);
if (usedVehicleIds.contains(vehicleId) == false) {
break;
}
index++;
}
}
usedVehicleIds.add(vehicleId);
// add entry for each stop and work out initial quantities
List<TourActivity> activities = route.getActivities();
int na = activities.size();
for (int i = 0; i < na; i++) {
TourActivity activity = activities.get(i);
if (JobActivity.class.isInstance(activity)) {
// create order object
StopOrder order = new StopOrder();
order.vehicleId = vehicleId;
BuiltStopRec builtStop = built.getBuiltStop((JobActivity) activity);
if (builtStop == null) {
throw new RuntimeException("Could not identify stop with JSPRIT job id "
+ ((JobActivity) activity).getJob().getId());
}
order.stopId = builtStop.getStopIdInStopsTable();
ret.add(order);
}
}
}
return ret;
}
示例5: ruinStarts
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void ruinStarts(Collection<VehicleRoute> clctn) {
sendClearSignal();
for (VehicleRoute vr : clctn) sendDataList(vr);
}
示例6: ruinEnds
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void ruinEnds(Collection<VehicleRoute> clctn, Collection<Job> clctn1) {
sendClearSignal();
for (VehicleRoute vr : clctn) sendDataList(vr);
}
示例7: informInsertionStarts
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void informInsertionStarts(Collection<VehicleRoute> clctn, Collection<Job> clctn1) {
sendClearSignal();
for (VehicleRoute vr : clctn) sendDataList(vr);
}
示例8: informInsertionEnds
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void informInsertionEnds(Collection<VehicleRoute> clctn) {
sendClearSignal();
for (VehicleRoute vr : clctn) sendDataList(vr);
}
示例9: informJobInserted
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void informJobInserted(Job job, VehicleRoute vr, double d, double d1) {
try {
int vehicleId = Integer.parseInt(vr.getVehicle().getId());
List<Job> tmp = new ArrayList<>();
tmp.add(job);
sendData(new VehicleCurrentJobs(vehicleId, tmp));
}
catch (Exception e) { }
}
示例10: removed
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
@Override
public void removed(Job job, VehicleRoute vr) {
try {
int vehicleId = Integer.parseInt(vr.getVehicle().getId());
List<Job> tmp = new ArrayList<>();
tmp.add(job);
sendDataRemove(new VehicleCurrentJobs(vehicleId, tmp));
}
catch (Exception e) { }
}
示例11: sendDataList
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; //导入依赖的package包/类
/**
* Wysłanie listy danych do obiektu macierzy kosztów
* @param vr Bieżąca trasa pojazdu
*/
private void sendDataList(VehicleRoute vr) {
try {
int vehicleId = Integer.parseInt(vr.getVehicle().getId());
List<Job> jobs = new ArrayList<>(vr.getTourActivities().getJobs());
sendData(new VehicleCurrentJobs(vehicleId, jobs));
}
catch (Exception e) { }
}