0

I am learning Anylogic, at the moment I want to run a bus on a given route with certain bus stops. For this I am using the following logic: carSource->carMoveTo1->selectOutput->carMoveTo2->carDispose. carSource is the place where the bus appears; carMoveTo1 is the stop the bus goes to; selectOutPut is the condition under which the bus ends its route; carMoveTo2 is the road to which the bus follows when the route ends. Also in carMoveTo1 I specify the destination: bus.stops[bus.stop_value++] (this is how I pass the stop count to the bus). In selectOutPut I add a condition: bus.stops.length==bus.stop_value. For the bus I set agent "bus" which has two parameters: stops(type "other" - BusStop[], control type "one-dimensional array") is an array of stops; stop_value(int type) - stops counter. This logic causes an error: the stop_value counter exceeds the limits of stops[] array. As far as I understand, it happens because in carMoveTo1 I'm incrementing the stop_value counter within the bus class from each bus.stops[bus.stop_value++]. How can I make each bus have a separate counter?

P.S. I've tried to refer to this: bus.stops[this.stop_value++] pointer - another error occurs.

Dmitry
  • 3
  • 1
  • 1
    Hi Dmitry, welcome to SO, please provide more details to your question. Add a screenshot of the block where the error occurs, add the specific error details as text etc. If you are looking for some advice on how to ask better questions check here https://stackoverflow.com/help/how-to-ask – Jaco-Ben Vosloo Nov 18 '21 at 10:57
  • And also check here for how to ask good AnyLogic questions here: https://www.benjamin-schumann.com/blog/2021/4/1/how-to-win-at-anylogic-on-stackoverflow – Benjamin Nov 19 '21 at 10:08
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – MD. RAKIB HASAN Nov 23 '21 at 10:32

0 Answers0