graphhopper/jsprit

Some unassignedJob maybe not reason when using fastRegretInsertion

baiyyang opened this issue · 2 comments

Hi, oblonski,
  I'm using the Jsprit for VRP. But now, when I use fast regretInsertion strategy, maybe some unassigned jobs have no reason. I think the reason that the method of vehicleDependentInsertionCostCalculator.
  When calculating the best insertionData by vehicleDependentInsertionCostCalculator using FastRegretInsertion strategy, some unassignedJob can't be assigned on current routes and it has enough vehicle used for empty route. So which causes no reason of the unassignedJob.
  And I update the VehicleDependentInsertionCostCalculator below, maybe it will help you.

 for (Vehicle v : relevantVehicles) {   // relevantVehicles is empty
      // can't be assigned
  }
  if (relevantVehicles.isEmpty()) {
        bestIData.getFailedConstraintNames().add("HasNoEnoughVehicle");  // add reason
  }
  return bestIData; 

You can easily add your own reason handler via UnassignedJobReasonTracker like this:

UnassignedJobReasonTracker reasonTracker = new UnassignedJobReasonTracker();
reasonTracker.put("SimpleNameOfYourConstraint",21,"could not be assigned due to your constraint");

Oh, thank you for your reply. I think you may not understand my question. I think that maybe there are some unassigned jobs and UnassignedJobReasonTracker hasn't record any reason. In other word, the unassigned job hasn't reached the ConstraintManager to record the reason. In my submission it's a bug.
: )