0

I created a simple model to study how lifts behave when they are failed: agents arrive on a ground level conveyor and continue to either one of the two higher conveyors, using a lift. Fail() and repair() functions are called when I click a button (Action: if (lift.isFailed()) lift.repair(); else lift.fail();) I'm using version 8.7.4 PLE. (Edit: the problem persists with 8.7.6 too)

Everything works fine except if I manage to fail the lift just before pickup, then I get the following error message when I click the button again to repair it:

Exception during discrete event execution:

java.util.NoSuchElementException

java.util.NoSuchElementException

    at java.base/java.util.LinkedList.getFirst(LinkedList.java:248)

    at com.anylogic.libraries.material_handling.LiftController_xjal$f.b(Unknown Source)

    at com.anylogic.libraries.material_handling.LiftController_xjal$f.d(Unknown Source)

    at com.anylogic.libraries.material_handling.LiftController_xjal.d(Unknown Source)

    at com.anylogic.libraries.material_handling.LiftController_xjal.d(Unknown Source)

    at com.anylogic.libraries.material_handling.LiftController_xjal$12.onTargetReach(Unknown Source)

    at com.anylogic.libraries.material_handling.MoveTo_xjal.c(Unknown Source)

    at com.anylogic.libraries.material_handling.MoveTo_xjal.a(Unknown Source)

    at com.anylogic.libraries.material_handling.MoveTo_xjal$d.a(Unknown Source)

    at com.anylogic.libraries.material_handling.EventExecutor$b.execute(Unknown Source)

    at com.anylogic.engine.Engine.i(Unknown Source)

    at com.anylogic.engine.Engine.if(Unknown Source)

    at com.anylogic.engine.Engine.e(Unknown Source)

    at com.anylogic.engine.Engine$n.run(Unknown Source)

Here's how the model looks when I get the error

What I've tried so far:

  1. Setting pickup time to 0. Maybe this would be worth another question but if the lift is failed during dropoff, the simulation throws a RuntimeException. Altough not very sophisticated, setting dropoff time to zero seems to get rid of the problem as I can't call fail() during dropoff. The error in question doesn't happen during pickup, but before it so this doesn't work. (I say this because I print to console at the lift actions "On pickup", "On failed" and "On repaired" to know in which order the events happened)
  2. Finding a way to delay calling fail() if the lift is in a specific state. Unfortunately I didn't find any method in the API reference which could tell me specifically what the lift is doing at the moment.

Obviously later on I plan to call fail() automatically from an Event or something similar, so I'd be interested in a solution which helps me avoid this error.

mczandrea
  • 463
  • 3
  • 12
  • is there a blue link in the console error msg that takes you to the actual code line causing the error? (java 248). This can help isolate the problem... – Benjamin Jul 29 '21 at 16:19
  • This appears to be an error internal to the logic of the lift. `NoSuchElementException` is thrown by `LinkedList.getFirst` when the list is empty. And you are not in control of this list as it is internal. First try and update to the latest version 8.7.6 If the error persists then contact AnyLogic support and submit your model to them to review. – Jaco-Ben Vosloo Jul 29 '21 at 17:18
  • Benjamin, it only says that "248 is not a valid line number in java.util.LinkedList", I feel like that's not useful. Jaco-Ben, I have now the latest version and the problem still persists, I'm going to contact support. – mczandrea Jul 30 '21 at 06:17
  • Thank you for the update @mczandrea. If my comment was more insightful I would have posted it as an answer ;-) but please feel free to answer your own question once you managed to fix it or identify it as a bug with the help from AnyLogic support. They are very good and usually very quick. – Jaco-Ben Vosloo Jul 30 '21 at 06:24

1 Answers1

0

I think this is only an issue in case of actual button clicks from a user, and the fail() function called for example by timed Events cannot crash the simulation.

I contacted the support team and I think they weren't able to reproduce the problem. So I wanted to send them back a model where the button action is called by an Event at the right time and thus on the next click the simulation fails. After a bit of playing around I found out that I got the error when I clicked at the exact moment of pickup start, so I scheduled an Event for the right moment aaand... it didn't crash. I was careful to get rid of everything that included probability distributions so the timing was right, but fortunately AnyLogic can handle unfortunate event scheduling – just not when a human is clicking away on the simulation controls.

mczandrea
  • 463
  • 3
  • 12