0

I am getting java.lang.IllegalStateException: The move thread with moveThreadIndex (0) has thrown an exception. Relayed here in the parent thread., The move thread with moveThreadIndex (0) has thrown an exception. Relayed here in the parent thread.

I am trying to access getArrivalTime of a different entity to arrive at the ready time for the entity in question. I am using the VRP example. This is called from UpdateListener from afterEntityAdded and afterEntityChanged. The same works in PRODUCTION mode.

private Long calculateArrivalTime(ScoreDirector scoreDirector, Task Task, Long previousDepartureTime) {
    if (Task == null || Task.getPreviousStandstill() == null) {
        return null;
    }
    long  readyTime = Task.getReadyTime();


    if (Task.getGroupType().equalsIgnoreCase("NONGPMS") && Task.getIsMegaTask() == false) {

        ResourceRoutingSolution sol = (ResourceRoutingSolution)scoreDirector.getWorkingSolution();

        List<Task> list = sol.getTasks();

        for (Task tx : list) {

            Task megaTask = (Task)scoreDirector.lookUpWorkingObjectOrReturnNull(tx);

            Task nonMegaTask = (Task)scoreDirector.lookUpWorkingObjectOrReturnNull(Task);

            if (megaTask.getIsMegaTask() == true && nonMegaTask.getGroupKey().equals(megaTask.getGroupKey())) {
                readyTime = megaTask.getArrivalTime()  == null ? 0 : megaTask.getArrivalTime();
            }

        }

    }

    if (Task.getPreviousStandstill() instanceof Resource) {
        // PreviousStandstill is the Resource, so we leave from the Depot at the best
        // suitable time
        // Helper.logDebug("Depot Ready time: " +
        // Helper.CovertEpochSecondsToDateTime(previousDepartureTime).toString());
        // Helper.logDebug("Task Ready time: " +
        // Helper.CovertEpochSecondsToDateTime(Task.getReadyTime()).toString());
        return Math.max(readyTime, previousDepartureTime + Task.getDistanceFromPreviousStandstill());
    }

    // return (previousDepartureTime == null ? 0 : previousDepartureTime) +
    // Task.getDistanceFromPreviousStandstill();
    return Math.max(readyTime,
            (previousDepartureTime == null ? 0 : previousDepartureTime) + Task.getDistanceFromPreviousStandstill());

}
yurloc
  • 2,268
  • 1
  • 15
  • 20
Pinakin Shah
  • 877
  • 2
  • 12
  • 25
  • If it fails in FULL_ASSERT, something is terrible wrong - even if production (=non-reproducible) mode doesn't detect it (because that skips some fail fast checks for performance reasons). – Geoffrey De Smet Jul 29 '19 at 08:46
  • Thanks Geoffrey. Is it legit to access other entities in the arrival time listener methods? Threading issues? – Pinakin Shah Jul 30 '19 at 02:39
  • Yes, it is ok to read properties of other entities in the variable listener (unless you have a shadow var that source on another shadow var and you're reading the **later** shadow var in the var listener of the source shadow var. All the shadow variables have a *trigger order* - see docs.) There are no threading issues because a working solution is modified and calculated within a single thread (with multithreaded solving there are multiple working solutions). – Geoffrey De Smet Jul 30 '19 at 06:56

0 Answers0