Resource capacity not updating as expected?

Resource capacity not updating as expected?

craig_dickson
Not applicable
104 Views
3 Replies
Message 1 of 4

Resource capacity not updating as expected?

craig_dickson
Not applicable

[ FlexSim 16.2.2 ]

resource-capacity.jpgIn a process flow model, I have a resource. In the Count field I have an integer global variable. The variable default is 1, but the value is set higher immediately when the model starts (eg, 300). However getstat(<resource>,"ResourceAvailable",STAT_CURRENT ) continues to return 1, even after putting a few Delay(0) activities, until the time changes. In fact, when I graphed it on a dashboard, it stayed at one for a full 150 seconds (which is when it was called again.This is causing problems in some other calculations I am doing.

Is this a bug, and if not is there a way I can force it to update so my other calculations work correctly?

0 Likes
Accepted solutions (1)
105 Views
3 Replies
Replies (3)
Message 2 of 4

sam_stubbsYXX86
Community Manager
Community Manager
Accepted solution

The resource quantity does not update dynamically during the runtime of a model as far as I understand. As an alternative, I would try using a list, have the number of items pushed to a list. If you're just using a numeric resource you could easily set this up by having Scheduled source in your process flow, with the number of tokens created equal to your Global Variable. Then just have the next activity be a Push to List, and push that number onto the list.

Then instead of Acquire and Release activities, just have Pull and Push to list activities instead.

0 Likes
Message 3 of 4

craig_dickson
Not applicable
@Sam Stubbs

Actually, in Process Flow resource Counts absolutely do update dynamically. I used a variable, which happened to be set elsewhere, but there is even the option to write custom code. It's a very useful feature, especially when the capacity is based on a combination of other conditions rather than on a schedule (which is the case here).

Just as your reply came in I solved my own problem: it turns out that the count is only evaluated/updated when a token seizes the resource. However it is not updated when you look at the capacity using getstat(). So to fix my problem, I had to add a Seize and a Release activity block immediately following the Custom code activity block where I set the variable that represents the resource count. (Note that this would not be possible if I used the Custom code option within the Resource itself, since FS does not let you seize a resource using code (or do anything else that might take time).)

I do think this is a bug though: if the resource happened to be full when I changed it down, the token doing the changing would then be stuck until enough other tokens released the resource which could cause problems if that token was intended to do other things in the time between.

0 Likes
Message 4 of 4

sam_stubbsYXX86
Community Manager
Community Manager

Ah, that's interesting ,thanks for the update. As I said, before I've seen people use lists in similar situations instead of Resources. That's good to know though.

0 Likes