Dear Geoffrey and OptaPlanner,
Today I would like to revisit this thread about NullPointerException in NearbyDistanceMatrix.getDestination() and, first of all, I would like to apologize for not including a simple way to practically reproduce the crash in my previous email.
In the filter, for simplicity, only those customers that are not directly attached to a vehicle are accepted. This is artificial, but it allows to show the problem with minimal changes to the code. In our real life scenario, we had work orders that were composed of a short sequence of pickups followed by a short sequence of deliveries and we used the filter, for instance, to not accept single deliveries for consideration, as they cannot be moved by themselves if they have an associated pickup, and this is how we discovered the crash in June last year.
In order to reproduce the crash, just run the examples, select vehicle routing, open "cvrp-32customers" and start solving, after which it should soon crash. A log with the crash is attached for convenience. There we can see that the crash happened after CustomerChangeFilter.accept() on "Customer-22" returned "true" and we can see towards the top of the log that, when NearbyDistanceMatrix was constructed, CustomerChangeFilter.accept() on "Customer-22" returned "false". We can also observe there that CustomerNearbyDistanceMeter.getNearbyDistance() was not called for entities for which CustomerChangeFilter.accept() returned "false".
So having this practical example, I would like to kindly ask you to consider the question in my previous email:
However, we are a bit confused here - is CustomerChangeFilter meant to be called at every step? Experiments show that it is called at every step. But then why is it used to filter out entities from NearbyDistanceMatrix in the very beginning? An entity that may not be suitable for a move in the beginning, may become suitable for a move later on. Therefore, if CustomerChangeFilter is meant to be called at every step and filter out entities based on the current situation, it seems incorrect to use it for the purposes of constructing NearbyDistanceMatrix in the beginning.
If it is a bug and not a misunderstanding on my part, I would be happy to report it on the issue tracker.
Best regards,
Aleksandrs