NickA
NickA

Reputation: 433

Is there a way to stop the "Source" block from generating agents after a specific time in AnyLogic?

Utilizing a source generating agents on an Interarrival time basis, I would like to stop the source block from generating agents after a certain amount of time passing so that the model can continue to process the agents.

Upvotes: 0

Views: 522

Answers (2)

Benjamin
Benjamin

Reputation: 12793

Sure. If it is a inter-arrival source block, make it use a variable as the interrarrival time, of type double: enter image description here

Then, create an event that triggers once only, after your specific time. Make it change the variable to 0 as below. Make SURE to trigger it not at time 0 (as in the screen but when you need it!):

NOTE: Do not set myRate = 0;. Instead, set it to infinity` to actually have no more arrivals. enter image description here

Upvotes: 1

Jaco-Ben Vosloo
Jaco-Ben Vosloo

Reputation: 3930

One option to encapsulate all the logic inside the source block, without external events or variables, would be to select Multiple agents per arrival as true and then have a conditional statement for the number of agents, for example time() > 10 ? 0 : 1, so that after 10 model time units there will no agents arriving

enter image description here

Upvotes: 2

Related Questions