question

MikelST avatar image
0 Likes"
MikelST asked Jason Lightfoot edited

Pull until Subnode.length

Good afternoon, I am new to flexsim and I have several questions about a model.

In the case of the model below, I would like to know if it is possible to start producing a certain number of products when there are less than a certain number of producers in the rack.

For example,

When(Model.find("Rack2")subnodes.length<9)

Start producing until(Model.find("Rack2")subnodes.length=14) without stopping when it reaches to 9.

Thank you.

pullsubnodeslenght.fsm

FlexSim 23.0.2
pullsubnode.length
5 |100000

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

Kavika F avatar image
0 Likes"
Kavika F answered Jason Lightfoot commented

Hey @MikelST, with regards to the model you posted, there are several problems I see that will hinder your desired functionality. Firstly, you check the subnodes of a "Rack2", but there is only a "Rack3" and "Rack4" in your model. If you're trying to use "Rack3", then you have another problem when checking to see if the subnodes.length is == 14; Rack3 can only hold up to 12 of the items you are producing (due to their size). I suggest increasing the size of that Rack to hold more items.

As for your if/then statement, you can implement that in a Trigger. After clicking on Rack3, look in the Properties panel on the right of the screen; at the bottom there is a section called "Triggers". Here you can put custom code when an event happens on this Rack. I suggest you add two triggers: an OnEntry trigger and an OnExit trigger.

1674070778934.png

In the OnEntry trigger, click the green + button and go to "Control > Close and Open Ports". You can have the Rack close its input port after it reaches 14 boxes. That way it can't take in any more items.

1674071928920.png

You'll do a similar thing on the OnExit trigger, where you open the input port once the rack's subnodes.length is less than 9. That way it will take in boxes again. Just to be safe, we can also check if the input is currently open so we don't try to open it repeatedly. Your condition might look like this:

current.subnodes.length < 9 && !inputopen(current)

After fixing all the names (no calling Rack1 or Rack2 since they don't exist) and adding this logic, it seems to work as intended.


1674070778934.png (7.2 KiB)
1674071928920.png (9.6 KiB)
· 3
5 |100000

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

Jose433 avatar image Jose433 commented ·
Hello @Kavika F ,

I'm creating a similar model, but mine has different item Types, and each type has a different threshold. So the thing is that I only want to close input for the Types that are above of their threshold. I don't know how to do it. I have created a global table, where there is the threshold number that has each type, but I don't know how to continue.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Jose433 commented ·
@Jose433 , please ask a new question.

In the meantime you can elaborate with input pull or think about to use more queue objects. Sometimes a solution does not consist of more source code rather than more objects.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Jose433 commented ·
If you are pulling by matching type you won't need to close and open ports.
0 Likes 0 ·
Miguel49 avatar image
0 Likes"
Miguel49 answered Jason Lightfoot edited

Hello,

Regarding to this exercise, I have a doubt. What happens if we have different types for the items and for each one you have different number condition for the subnodes.lenght.

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

Joerg Vogel avatar image Joerg Vogel commented ·

@Miguel49 , please ask a new question, because such approach needs more than just closing an input of an object. You need a balance system. You need an input control mechanism. And you must evaluate events to continue input again after your input has been closed.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

If you are pulling by matching type you won't need to close and open ports.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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