コード例 #1
0
 private void updateInsertionData(
     final TreeSet<VersionedInsertionData>[] priorityQueues,
     final Collection<VehicleRoute> routes,
     List<Job> unassignedJobList,
     final int updateRound) {
   List<Callable<Boolean>> tasks = new ArrayList<Callable<Boolean>>();
   for (final Job unassignedJob : unassignedJobList) {
     if (priorityQueues[unassignedJob.getIndex()] == null) {
       priorityQueues[unassignedJob.getIndex()] =
           new TreeSet<VersionedInsertionData>(InsertionDataUpdater.getComparator());
     }
     final TreeSet<VersionedInsertionData> priorityQueue =
         priorityQueues[unassignedJob.getIndex()];
     tasks.add(
         new Callable<Boolean>() {
           @Override
           public Boolean call() throws Exception {
             return InsertionDataUpdater.update(
                 switchAllowed,
                 initialVehicleIds,
                 fleetManager,
                 insertionCostsCalculator,
                 priorityQueue,
                 updateRound,
                 unassignedJob,
                 routes);
           }
         });
   }
   try {
     List<Future<Boolean>> futures = executor.invokeAll(tasks);
   } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
ファイル: AvgServiceDistance.java プロジェクト: muzuro/jsprit
 /**
  * Calculates and returns the average distance between two jobs based on the input-transport
  * costs.
  *
  * <p>
  *
  * <p>If the distance between two jobs cannot be calculated with input-transport costs, it tries
  * the euclidean distance between these jobs.
  */
 @Override
 public double getDistance(Job i, Job j) {
   double avgCost = 0.0;
   if (i instanceof Service && j instanceof Service) {
     if (i.equals(j)) {
       avgCost = 0.0;
     } else {
       Service s_i = (Service) i;
       Service s_j = (Service) j;
       avgCost = calcDist(s_i, s_j);
     }
   } else {
     throw new UnsupportedOperationException("currently, this class just works services.");
   }
   return avgCost;
 }