@Override public Iterator<Job> getNearestNeighborsIterator(int nNeighbors, Job neighborTo) { int[] neighbors = this.neighbors[neighborTo.getIndex()-1]; return new ArrayIterator(nNeighbors,neighbors,jobs); }
public void setDependencyType(String jobId, DependencyType dependencyType){ Job job = vrp.getJobs().get(jobId); if(job != null) { dependencyTypes[job.getIndex()] = dependencyType; } }
public DependencyType getDependencyType(String jobId){ Job job = vrp.getJobs().get(jobId); if(job != null){ return dependencyTypes[job.getIndex()]; } return DependencyType.NO_TYPE; }
private void updateInsertionData(TreeSet<VersionedInsertionData>[] priorityQueues, Collection<VehicleRoute> routes, List<Job> unassignedJobList, int updateRound, boolean firstRun, VehicleRoute lastModified, Map<VehicleRoute, Integer> updates) { for (Job unassignedJob : unassignedJobList) { if(priorityQueues[unassignedJob.getIndex()] == null){ priorityQueues[unassignedJob.getIndex()] = new TreeSet<>(InsertionDataUpdater.getComparator()); } if(firstRun) { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes); for(VehicleRoute r : routes) updates.put(r,updateRound); } else{ if(dependencyTypes == null || dependencyTypes[unassignedJob.getIndex()] == null){ InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, Arrays.asList(lastModified)); updates.put(lastModified,updateRound); } else { DependencyType dependencyType = dependencyTypes[unassignedJob.getIndex()]; if (dependencyType.equals(DependencyType.INTER_ROUTE) || dependencyType.equals(DependencyType.INTRA_ROUTE)) { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes); for(VehicleRoute r : routes) updates.put(r,updateRound); } else { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, Arrays.asList(lastModified)); updates.put(lastModified,updateRound); } } } } }
boolean updatedAllRoutes = false; for (final Job unassignedJob : unassignedJobList) { if(priorityQueues[unassignedJob.getIndex()] == null){ priorityQueues[unassignedJob.getIndex()] = new TreeSet<>(InsertionDataUpdater.getComparator()); makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); if(dependencyTypes == null || dependencyTypes[unassignedJob.getIndex()] == null){ makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); DependencyType dependencyType = dependencyTypes[unassignedJob.getIndex()]; if (dependencyType.equals(DependencyType.INTER_ROUTE) || dependencyType.equals(DependencyType.INTRA_ROUTE)) { updatedAllRoutes = true; makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); } else { makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified);
private void calculateDistancesFromJob2Job() { logger.debug("pre-process distances between locations ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (Job job_i : vrp.getJobsInclusiveInitialJobsInRoutes().values()) { jobs[job_i.getIndex()] = job_i; List<ReferencedJob> jobList = new ArrayList<ReferencedJob>(vrp.getJobsInclusiveInitialJobsInRoutes().values().size()); for (Job job_j : vrp.getJobsInclusiveInitialJobsInRoutes().values()) { if (job_i == job_j) continue; double distance = jobDistance.getDistance(job_i, job_j); if (distance > maxDistance) maxDistance = distance; ReferencedJob referencedJob = new ReferencedJob(job_j, distance); jobList.add(referencedJob); } Collections.sort(jobList,getComparator()); int[] jobIndices = new int[capacity]; for(int index=0;index<capacity;index++){ jobIndices[index] = jobList.get(index).getJob().getIndex(); } neighbors[job_i.getIndex()-1] = jobIndices; } stopWatch.stop(); logger.debug("pre-processing comp-time: {}", stopWatch); }
InsertionData best = null; InsertionData secondBest = null; TreeSet<VersionedInsertionData> priorityQueue = priorityQueues[j.getIndex()]; Iterator<VersionedInsertionData> iterator = priorityQueue.iterator(); List<String> failedConstraintNames = new ArrayList<>();
public void setDependencyType(String jobId, DependencyType dependencyType){ Job job = vrp.getJobs().get(jobId); if(job != null) { dependencyTypes[job.getIndex()] = dependencyType; } }
@Override public Iterator<Job> getNearestNeighborsIterator(int nNeighbors, Job neighborTo) { int[] neighbors = this.neighbors[neighborTo.getIndex()-1]; return new ArrayIterator(nNeighbors,neighbors,jobs); }
public DependencyType getDependencyType(String jobId){ Job job = vrp.getJobs().get(jobId); if(job != null){ return dependencyTypes[job.getIndex()]; } return DependencyType.NO_TYPE; }
private void updateInsertionData(TreeSet<VersionedInsertionData>[] priorityQueues, Collection<VehicleRoute> routes, List<Job> unassignedJobList, int updateRound, boolean firstRun, VehicleRoute lastModified, Map<VehicleRoute, Integer> updates) { for (Job unassignedJob : unassignedJobList) { if(priorityQueues[unassignedJob.getIndex()] == null){ priorityQueues[unassignedJob.getIndex()] = new TreeSet<>(InsertionDataUpdater.getComparator()); } if(firstRun) { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes); for(VehicleRoute r : routes) updates.put(r,updateRound); } else{ if(dependencyTypes == null || dependencyTypes[unassignedJob.getIndex()] == null){ InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, Arrays.asList(lastModified)); updates.put(lastModified,updateRound); } else { DependencyType dependencyType = dependencyTypes[unassignedJob.getIndex()]; if (dependencyType.equals(DependencyType.INTER_ROUTE) || dependencyType.equals(DependencyType.INTRA_ROUTE)) { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes); for(VehicleRoute r : routes) updates.put(r,updateRound); } else { InsertionDataUpdater.update(switchAllowed, initialVehicleIds, fleetManager, insertionCostsCalculator, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, Arrays.asList(lastModified)); updates.put(lastModified,updateRound); } } } } }
boolean updatedAllRoutes = false; for (final Job unassignedJob : unassignedJobList) { if(priorityQueues[unassignedJob.getIndex()] == null){ priorityQueues[unassignedJob.getIndex()] = new TreeSet<>(InsertionDataUpdater.getComparator()); makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); if(dependencyTypes == null || dependencyTypes[unassignedJob.getIndex()] == null){ makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); DependencyType dependencyType = dependencyTypes[unassignedJob.getIndex()]; if (dependencyType.equals(DependencyType.INTER_ROUTE) || dependencyType.equals(DependencyType.INTRA_ROUTE)) { updatedAllRoutes = true; makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified); } else { makeCallables(tasks, updatedAllRoutes, priorityQueues[unassignedJob.getIndex()], updateRound, unassignedJob, routes, lastModified);
private void calculateDistancesFromJob2Job() { logger.debug("pre-process distances between locations ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (Job job_i : vrp.getJobsInclusiveInitialJobsInRoutes().values()) { jobs[job_i.getIndex()] = job_i; List<ReferencedJob> jobList = new ArrayList<ReferencedJob>(vrp.getJobsInclusiveInitialJobsInRoutes().values().size()); for (Job job_j : vrp.getJobsInclusiveInitialJobsInRoutes().values()) { if (job_i == job_j) continue; double distance = jobDistance.getDistance(job_i, job_j); if (distance > maxDistance) maxDistance = distance; ReferencedJob referencedJob = new ReferencedJob(job_j, distance); jobList.add(referencedJob); } Collections.sort(jobList,getComparator()); int[] jobIndices = new int[capacity]; for(int index=0;index<capacity;index++){ jobIndices[index] = jobList.get(index).getJob().getIndex(); } neighbors[job_i.getIndex()-1] = jobIndices; } stopWatch.stop(); logger.debug("pre-processing comp-time: {}", stopWatch); }
InsertionData best = null; InsertionData secondBest = null; TreeSet<VersionedInsertionData> priorityQueue = priorityQueues[j.getIndex()]; Iterator<VersionedInsertionData> iterator = priorityQueue.iterator(); List<String> failedConstraintNames = new ArrayList<>();