question

Craig DIckson avatar image
0 Likes"
Craig DIckson asked Sam Stubbs commented

Resource capacity not updating as expected?

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?

FlexSim 16.2.2
process flowresources
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Sam Stubbs avatar image
0 Likes"
Sam Stubbs answered Sam Stubbs commented

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.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Craig DIckson avatar image Craig DIckson commented ·
@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 0 ·
Sam Stubbs avatar image Sam Stubbs ♦ Craig DIckson commented ·

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 0 ·