コード例 #1
0
ファイル: ToolsConstraint.java プロジェクト: vpillac/vroom
 /**
  * Check an insertion move feasibility
  *
  * @param tour
  * @param move
  * @return 1 if move is feasible, -1 if the technician does not have the required tools and no
  *     visit to main depot is planned, -2 if the required tools are not available at this point
  */
 private int checkInsFeasibility(ITRSPTour itour, InsertionMove move) {
   if (!TRSPTour.class.isAssignableFrom(itour.getClass())) {
     TRSPLogging.getOptimizationLogger()
         .warn(
             String.format(
                 "ToolsConstraint.checkInsFeasibility: unsupported tour class (%s)",
                 itour.getClass()));
     return 1;
   }
   TRSPTour tour = (TRSPTour) itour;
   InsertionMove m = move;
   if (m.isDepotTrip() || !tour.getInstance().isRequest(move.getNodeId())) return 1;
   if (!tour.isMainDepotVisited()
       && !m.isDepotTrip()
       && !tour.getInstance().hasRequiredTools(tour.getTechnician().getID(), m.getNodeId()))
     return -1;
   int pred = m.getInsertionPred();
   if (pred == ITRSPTour.UNDEFINED) {
     if (tour.getInstance().hasRequiredTools(tour.getTechnician().getID(), m.getNodeId()))
       return 1;
     else return -2;
   } else {
     for (int tool : itour.getInstance().getRequest(m.getNodeId()).getToolSet())
       if (!tour.isToolAvailable(pred, tool)) return -2;
   }
   return 1;
 }