0

I have a source and a variable. in the "on exit" source section there is "variable=source.count()". The source generates n agents by inject fuction, but the variable has value n-1. why? thanks for the help.

1 Answers1

0

so I assume you want to count the agents that have been generated on that source.

Using a variable is in the first place redundant since you can use source.count() everywhere in your model instead of the variable, and it will work.

Nevertheless if you insist in using a variable, you need to use the variable in the block AFTER the source since it seems that the count is made internally in anylogic after the "on exit" action.

so for instance if you have a delay block after the source, write variable=source.out.count(); in the "on enter" action of the delay block.

Felipe
  • 8,311
  • 2
  • 15
  • 31