never_stop_learning
never_stop_learning

Reputation: 33

Dynamically adjusting arrival rate in source

the basic idea behind the modeling issue is a breakdown of a production machine.

I would like to model this by setting the arrival rate (simply arrivals per second) to zero (Source.rate = 0). After the machine is repaired, the arrival rate is set to its actual value again (e.g., Source.rate = 5). While the first command does the job, the second does not seem to have any effect, i.e. new agents are not created.

The segment of the model is rather simple: Source --> Select Output (decision about breakdown) --> true: go on in production; false: delay (repair machine) --> go on in production.

Source.rate = 0 is called at the out port (false) of "breakdown" and Source.rate = 5 at the out port of "repair".

https://i.sstatic.net/hqGoI.png

Of cause, this issue might be modeled differently (e.g., using hold with disabled "forced pushing"), however, it is not clear for me why my approach does not work.

Thanks in advance!

Upvotes: 2

Views: 1563

Answers (3)

Stuart Rossiter
Stuart Rossiter

Reputation: 2517

To expand on Felipe's answer with an explanation:

Instead of using source.rate=5; use source.set_rate(5);

rate is effectively a Parameter (in the AnyLogic sense) of the Source block. (All AnyLogic's Process Modeling blocks are actually themselves Agents developed by AnyLogic, and thus with Parameters, Variables, etc.)

You can set an AnyLogic Parameter directly (via just assigning a value as you did), but they also all have a set_<parameter name> method (function) which should really always be used instead because this triggers any internal on-change logic for this Parameter. It is only this triggered logic (internal to the Source block) which causes the Source to 're-evaluate' the rate properly.

(You can use on-change logic for Parameters in your own models, and need to do so when altering a parameter requires some 'adjustments' to the rest of the model; i.e., in situations where the change doesn't 'just work' due to other bits of the model reading the new value after the change point.)

Upvotes: 2

Felipe
Felipe

Reputation: 9421

Instead of using source.rate=5; use source.set_rate(5);

Upvotes: 2

Mohammad Hasan N.
Mohammad Hasan N.

Reputation: 224

I don't know why your model doesn't work (maybe more details of your model is needed), but a simple solution which I tested and worked, is as below:

You can set the source's "Type of arrival" to "calls of inject() function", add an event to your model and set its "Trigger type" to "Rate" and set its rate value to 5. Then in action code of the event use below code:

if(yourCondition)
{
    source.inject(1);
}

I hope it helps you.

Upvotes: 0

Related Questions