jsprit icon indicating copy to clipboard operation
jsprit copied to clipboard

UnassignedJobReasonTracker gives wrong reason

Open grantm009 opened this issue 5 years ago • 1 comments

Hi folks

Attn: @oblonski

Im finding that sometimes the reason tracker is giving the wrong reason for the unassigned job. This small snippet (below) shows that I am iterating over the unassigned jobs and using the getMostLikelyReasonCode and getMostLikelyReason methods to get the reasons. However I am finding that the reason does not match the actual cause.

An example is a job that has a skill required of "FORK". Thats the only skill added and there are plenty of trucks with that skill assigned (and being used for other jobs with skill requirement of FORK). However the reason given was that "cannot serve required skill". A similar thing happened with another job that had a requirement for skill "TRUCK". There are no trucks in the system with skill "TRUCK" but the rejection description was "does not fit into any vehicle due to capacity" but should have been "cannot serve required skill"

/* initialisation */ UnassignedJobReasonTracker reasonTracker = new UnassignedJobReasonTracker(); algorithm.addListener(reasonTracker);

` /* end of job processing */

	routeJSONArray = new JSONArray();
	if (!solution.getUnassignedJobs().isEmpty()) {
		LOGGER.log(Level.INFO, "printJSON: processing unassigned items: " + solution.getUnassignedJobs().size());
		for (Job j : solution.getUnassignedJobs()) {
			JSONObject routeJson = new JSONObject();
			routeJson.put("jobID", j.getId());
			if (reasonTracker.getMostLikelyReasonCode(j.getId()) > 0){
				routeJson.put("reasonCode", reasonTracker.getMostLikelyReasonCode(j.getId()));
				routeJson.put("reason", reasonTracker.getMostLikelyReason(j.getId()));
			}
			routeJSONArray.add(routeJson);
		}
	}

` Any thoughts folks?

regards Grant

grantm009 avatar Jul 17 '18 01:07 grantm009

As the method .getMostLikelyReason suggests it returns a reason that is most likely the actual reason. This also means that there is a probability that it returns the wrong or a misleading reason. It basically works as follows. When inserting job x, it counts the hard constraints causing the job to be unassigned. If job x is more often rejected by the capacity constraint rather than the skill constraint, it returns the capacity constraint as reason, even though the decisive constraint might be the skill one.

oblonski avatar Sep 17 '18 12:09 oblonski