TourActivity act = seedRoute.getActivities().get(i); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (vrp.getJobs().containsKey(job.getId())) { jobs2Remove.add(job);
if (JobActivity.class.isInstance(activity)) { JobActivity ja = (JobActivity) activity; List<StopDetail> stops = stopDetailsByJobId.get(ja.getJob().getId()); if (stops != null) { for (StopDetail sd : stops) {
if (builtStop == null) { throw new RuntimeException("Could not identify stop with JSPRIT job id " + ((JobActivity) activity).getJob().getId());
TourActivity act = seedRoute.getActivities().get(i); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (vrp.getJobs().containsKey(job.getId())) { jobs2Remove.add(job);
String jobId; if (act instanceof TourActivity.JobActivity) { jobId = ((TourActivity.JobActivity) act).getJob().getId(); } else { jobId = "-";
if(act instanceof ServiceActivity || act instanceof PickupService){ log.debug("Found ServiceActivity or PickupService : " + act.getName() + " at location " + act.getLocation().getId() + " : " + act.getLocation().getCoordinate() ); Service job = (Service) ((JobActivity) act).getJob(); CarrierService carrierService = createCarrierService(job); tourBuilder.addLeg(new Leg()); Shipment job = (Shipment) ((JobActivity) act).getJob(); CarrierShipment carrierShipment = createCarrierShipment(job); tourBuilder.addLeg(new Leg()); Shipment job = (Shipment) ((JobActivity) act).getJob(); CarrierShipment carrierShipment = createCarrierShipment(job); tourBuilder.addLeg(new Leg());
xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").act(" + actCounter + ")[@type]", act.getName()); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (job instanceof Break) { xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").act(" + actCounter + ").breakId", job.getId());
Job job = ((JobActivity) act).getJob(); String currIdentifier = makeId(job.getId(), act.getLocation().getId()); if (label.equals(Label.ACTIVITY)) {
TourActivity act = seedRoute.getActivities().get(i); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (vrp.getJobs().containsKey(job.getId())) { jobs2Remove.add(job);
/** * Removes job AND belonging activity from tour. Note that if job is a Service, it is assumed that there is only one belonging activity, * thus, it stops trying to remove activities once the first is found. * If you want to always look for belonging activities to be removed in the entire route, use removeJob(Job job, boolean enforceEntireRoute) * * @param job to be removed * @return true if job has been removed, otherwise false. */ public boolean removeJob(Job job) { boolean jobRemoved = false; if (!jobs.contains(job)) { return false; } else { jobRemoved = jobs.remove(job); } boolean activityRemoved = false; Iterator<TourActivity> iterator = tourActivities.iterator(); while (iterator.hasNext()) { TourActivity c = iterator.next(); if (c instanceof JobActivity) { Job underlyingJob = ((JobActivity) c).getJob(); if (job.equals(underlyingJob)) { iterator.remove(); activityRemoved = true; } } } assert jobRemoved == activityRemoved : "job removed, but belonging activity not."; return activityRemoved; }
xmlConfig.setProperty(path + "(" + routeCounter + ").act(" + actCounter + ")[@type]", act.getName()); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (job instanceof Service) { xmlConfig.setProperty(path + "(" + routeCounter + ").act(" + actCounter + ").serviceId", job.getId());
/** * Adds an initial vehicle route. * * @param route initial route * @return the builder */ public Builder addInitialVehicleRoute(VehicleRoute route) { if(!addedVehicleIds.contains(route.getVehicle().getId())){ addVehicle((AbstractVehicle) route.getVehicle()); addedVehicleIds.add(route.getVehicle().getId()); } for (TourActivity act : route.getActivities()) { AbstractActivity abstractAct = (AbstractActivity) act; abstractAct.setIndex(activityIndexCounter); incActivityIndexCounter(); if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); jobsInInitialRoutes.add(job.getId()); addLocationToTentativeLocations(job); registerJobAndActivity(abstractAct, job); } } initialRoutes.add(route); return this; }
private void handleVehicleSwitch(InsertionData data, VehicleRoute route) { boolean vehicleSwitch = false; if (!(route.getVehicle() instanceof VehicleImpl.NoVehicle)) { if (!route.getVehicle().getId().equals(data.getSelectedVehicle().getId())) { vehicleSwitch = true; } } if (vehicleSwitch && !route.getActivities().isEmpty()) { String oldStart = makeStartId(route.getVehicle()); String firstAct = ((TourActivity.JobActivity) route.getActivities().get(0)).getJob().getId(); String oldEnd = makeEndId(route.getVehicle()); String lastAct = ((TourActivity.JobActivity) route.getActivities().get(route.getActivities().size() - 1)).getJob().getId(); removeEdge(oldStart + "_" + firstAct); if (route.getVehicle().isReturnToDepot()) { removeEdge(lastAct + "_" + oldEnd); } String newStart = makeStartId(data.getSelectedVehicle()); String newEnd = makeEndId(data.getSelectedVehicle()); addEdge(newStart + "_" + firstAct, newStart, firstAct); if (data.getSelectedVehicle().isReturnToDepot()) { addEdge(lastAct + "_" + newEnd, lastAct, newEnd); } } }
private void log(VehicleRoutingProblemSolution solution) { logger.trace("solution costs: {}", solution.getCost()); for (VehicleRoute r : solution.getRoutes()) { StringBuilder b = new StringBuilder(); b.append(r.getVehicle().getId()).append(" : ").append("[ "); for (TourActivity act : r.getActivities()) { if (act instanceof TourActivity.JobActivity) { b.append(((TourActivity.JobActivity) act).getJob().getId()).append(" "); } } b.append("]"); logger.trace(b.toString()); } StringBuilder b = new StringBuilder(); b.append("unassigned : [ "); for (Job j : solution.getUnassignedJobs()) { b.append(j.getId()).append(" "); } b.append("]"); logger.trace(b.toString()); }
private List<LocationWrapper> getLocationWrappers(VehicleRoute route) { List<LocationWrapper> locations = new ArrayList<LocationWrapper>(route.getTourActivities().getJobs().size()); Map<Job, List<Location>> jobs2locations = new HashMap<Job, List<Location>>(); for (TourActivity act : route.getActivities()) { if (act instanceof TourActivity.JobActivity) { Job job = ((TourActivity.JobActivity) act).getJob(); if (!jobs2locations.containsKey(job)) { jobs2locations.put(job, new ArrayList<Location>()); } jobs2locations.get(job).add(act.getLocation()); } } for (Job j : jobs2locations.keySet()) { locations.add(new LocationWrapper(j, jobs2locations.get(j))); } return locations; }
BuiltStopRec getBuiltStop(JobActivity jobActivity){ List<BuiltStopRec> rows = jspritJobIdToStopRecords.get(jobActivity.getJob().getId()); if(rows==null){ throw new RuntimeException("Unknown " + PredefinedTags.STOP_ID + " or " + PredefinedTags.JOB_ID + ": " + jobActivity.getJob().getId()); } if(rows.size()==1){ return rows.get(0); } if(rows.size()>1 && PickupActivity.class.isInstance(jobActivity)){ return rows.get(0); } if(rows.size()>1 && DeliveryActivity.class.isInstance(jobActivity)){ return rows.get(1); } return null; }
@Override public void visit(TourActivity activity) { boolean violatedAtActivity = false; if (activity instanceof TourActivity.JobActivity) { Set<String> requiredForActivity = ((TourActivity.JobActivity) activity).getJob().getRequiredSkills().values(); for (String skill : requiredForActivity) { if (!route.getVehicle().getSkills().containsSkill(skill)) { violatedAtActivity = true; skillConstraintViolatedOnRoute = true; } } } stateManager.putActivityState(activity, skill_id, violatedAtActivity); }
@Override public double[] getPoint() { return new double[]{jobActivity.getLocation().getCoordinate().getX(), jobActivity.getLocation().getCoordinate().getY()}; }