@Override public void informJobUnassigned(Job unassigned, Collection<String> failedConstraintNames) { if (!this.failedConstraintNamesFrequencyMapping.containsKey(unassigned.getId())) { this.failedConstraintNamesFrequencyMapping.put(unassigned.getId(), new Frequency()); } for (String r : failedConstraintNames) { if (failedConstraintNamesToBeIgnored.contains(r)) continue; this.failedConstraintNamesFrequencyMapping.get(unassigned.getId()).addValue(r); } }
private boolean isDeliverKey(TourActivity act) { if (!(act instanceof TourActivity.JobActivity)) return false; return ((TourActivity.JobActivity) act).getJob().getName().equals("deliver key"); }
private String getSkillString(Job job) { return createSkillString(job.getRequiredSkills()); }
static double score(Job unassignedJob, InsertionData best, InsertionData secondBest, ScoringFunction scoringFunction){ if (best == null) { throw new IllegalStateException("cannot insert job " + unassignedJob.getId()); } double score; if (secondBest == null) { //either there is only one vehicle or there are more vehicles, but they cannot load unassignedJob //if only one vehicle, I want the job to be inserted with min iCosts //if there are more vehicles, I want this job to be prioritized since there are no alternatives score = (11 - unassignedJob.getPriority()) * (Integer.MAX_VALUE - best.getInsertionCost()) + scoringFunction.score(best, unassignedJob); } else { score = (11 - unassignedJob.getPriority()) * (secondBest.getInsertionCost() - best.getInsertionCost()) + scoringFunction.score(best, unassignedJob); } return score; } }
if (job == ignore) continue; double actEndTime = openPickupEndTimesPerVehicle.get(vehicleIndex).get(job); double slackTime = job.getMaxTimeInVehicle() - (routeEnd - actEndTime); openDeliveries.put(job, slackTime); Job job = ((TourActivity.JobActivity) act).getJob(); if (act instanceof ServiceActivity || act instanceof PickupActivity) { String jobId = job.getId(); openDeliveries.remove(jobId); double minSlackTime = minSlackTime(openDeliveries);
String currIdentifier = makeId(job.getId(), act.getLocation().getId()); if (label.equals(Label.ACTIVITY)) { Node actNode = g.getNode(currIdentifier); } else if (label.equals(Label.JOB_NAME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", job.getName()); } else if (label.equals(Label.ARRIVAL_TIME)) { Node actNode = g.getNode(currIdentifier);
private String getSizeString(Job job) { StringBuilder builder = new StringBuilder(); builder.append("("); boolean firstDim = true; for (int i = 0; i < job.getSize().getNuOfDimensions(); i++) { if (firstDim) { builder.append(String.valueOf(job.getSize().get(i))); firstDim = false; } else { builder.append(","); builder.append(String.valueOf(job.getSize().get(i))); } } builder.append(")"); return builder.toString(); }
public void setDependencyType(String jobId, DependencyType dependencyType){ Job job = vrp.getJobs().get(jobId); if(job != null) { dependencyTypes[job.getIndex()] = dependencyType; } }
private double getMaxTimeInVehicle(TourActivity activity) { double maxTime = Double.MAX_VALUE; if(activity instanceof TourActivity.JobActivity){ maxTime = ((TourActivity.JobActivity) activity).getJob().getMaxTimeInVehicle(); } return maxTime; }
String currIdentifier = makeId(job.getId(), act.getLocation().getId()); if (label.equals(Label.ACTIVITY)) { Node actNode = g.getNode(currIdentifier); } else if (label.equals(Label.JOB_NAME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", job.getName()); } else if (label.equals(Label.ARRIVAL_TIME)) { Node actNode = g.getNode(currIdentifier);
static double score(Job unassignedJob, InsertionData best, InsertionData secondBest, ScoringFunction scoringFunction){ if (best == null) { throw new IllegalStateException("cannot insert job " + unassignedJob.getId()); } double score; if (secondBest == null) { //either there is only one vehicle or there are more vehicles, but they cannot load unassignedJob //if only one vehicle, I want the job to be inserted with min iCosts //if there are more vehicles, I want this job to be prioritized since there are no alternatives score = (11 - unassignedJob.getPriority()) * (Integer.MAX_VALUE - best.getInsertionCost()) + scoringFunction.score(best, unassignedJob); } else { score = (11 - unassignedJob.getPriority()) * (secondBest.getInsertionCost() - best.getInsertionCost()) + scoringFunction.score(best, unassignedJob); } return score; } }
@Override public void visit(TourActivity activity) { if (activity instanceof PickupActivity) { pickupCounter++; pickedUp = Capacity.addup(pickedUp, ((PickupActivity) activity).getJob().getSize()); if (activity instanceof PickupService) { deliverAtEndCounter++; } } else if (activity instanceof DeliveryActivity) { deliveryCounter++; delivered = Capacity.addup(delivered, ((DeliveryActivity) activity).getJob().getSize()); if (activity instanceof DeliverService) { pickupAtBeginningCounter++; } } }
@Override public Iterator<Job> getNearestNeighborsIterator(int nNeighbors, Job neighborTo) { int[] neighbors = this.neighbors[neighborTo.getIndex()-1]; return new ArrayIterator(nNeighbors,neighbors,jobs); }
for (Job job : openPickupEndTimesPerVehicle.get(vehicleIndex).keySet()) { double actEndTime = openPickupEndTimesPerVehicle.get(vehicleIndex).get(job); double slackTime = job.getMaxTimeInVehicle() - (routeEnd - actEndTime); openDeliveries.put(job, slackTime);
private static Service getService(String serviceId, Builder vrpBuilder) { for (Job j : vrpBuilder.getAddedJobs()) { if (j.getId().equals(serviceId)) { return (Service) j; } } return null; }
@Override public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { if (job2insert instanceof Delivery) { Capacity loadAtDepot = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.class); if (loadAtDepot == null) loadAtDepot = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_BEGINNING, Capacity.addup(loadAtDepot, job2insert.getSize())); } else if (job2insert instanceof Pickup || job2insert instanceof Service) { Capacity loadAtEnd = stateManager.getRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.class); if (loadAtEnd == null) loadAtEnd = defaultValue; stateManager.putTypedInternalRouteState(inRoute, InternalStates.LOAD_AT_END, Capacity.addup(loadAtEnd, job2insert.getSize())); } }
@Override public void visit(TourActivity activity) { if (activity instanceof TourActivity.JobActivity) { Skills skills = ((TourActivity.JobActivity) activity).getJob().getRequiredSkills(); skillBuilder.addAllSkills(skills.values()); } }
private boolean isPickupKey(TourActivity act) { if (!(act instanceof TourActivity.JobActivity)) return false; return ((TourActivity.JobActivity) act).getJob().getName().equals("get key"); }
public DependencyType getDependencyType(String jobId){ Job job = vrp.getJobs().get(jobId); if(job != null){ return dependencyTypes[job.getIndex()]; } return DependencyType.NO_TYPE; }
double maxTimeInVehicle = ((TourActivity.JobActivity)newAct).getJob().getMaxTimeInVehicle(); if(timeInVehicle > maxTimeInVehicle) return ConstraintsStatus.NOT_FULFILLED; double maxTimeInVehicle = ((TourActivity.JobActivity)newAct).getJob().getMaxTimeInVehicle();