Reputation: 75
Good day!
Please, help me understand how the Delay block works in AnyLogic. Suppose we deal with a multichannel transmission network. The model has 2 sources. Suppose these sources generate packets every 1 sec. Packets from different sources have different priorities and need different quantities of resources to be served (it is set up with Priority and Resource_quantity parameters respectively). The Priority_queue in the model is priority-based. The proposed model put the packets into the channels in accordance with Resource availability in the channel. Firstly, it tries to put the packet to the first channel. If there are no available resources it puts the packet into the second channel. If there are no resources in both channels it waits (it is realized with Hold block).
I noticed that if I set delays in blocks delay1 and delay2 with static parameters (for ex. 2 sec) the model works ok. But then I try to calculate it before these blocks the model doesn't take into consideration it at all. And in this case, the model works without any delays. What did I do wrong here?
I will appreciate any help.
The delay is calculated in Exit block and is written into the variable delay of the agent. I tried to add traceln(agent.delay) as @Jaco-Ben suggested right after calculation of the delay and it showed zero. In this case it doesn't also seize resources :(
Upvotes: 0
Views: 769
Reputation: 75
Thank @Jaco-Ben for the useful comments.
The delay is zero because
the result of division in Java depends on the types of the operands. If both operands are integer, the result will be integer as well. To let Java perform real division (and get a real number as a result) at least one of the operands must be of real type.
So it was my problem.
To solve it I assigned double
to one of the operands :
agent.delay = (double)agent.Resource_quantity/ChannelResources1.idle();
However, it is strange why it shows correct values in the database.
Upvotes: 1