question

mikelmb avatar image
0 Likes"
mikelmb asked Jason Lightfoot edited

Error in condition doesn't close the port when needed

Hello,

We are trying to simulate a demand, and have defined a condition in the sink (on entry):

gettablenum(label(current,"ItemCounts"),item.Type,1)>=gettablenum("demand",CurrentHour+1,item.Type)

The values of both sides of the condition are going good but then the port is not closed as needed. The variables affecting the condition are also correct and we do not know why the port is closing when the "demand" table has not reach all the units.

I attach the model in case you can give me a hand: Warehouse.fsm

Thanks,

FlexSim 22.1.4
portssinkinput portoutput portcondition
warehouse.fsm (63.2 KiB)
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

The first time the condition evaluates true your item's Type is 2 and you are using the input port 2 of the sink to determine which object's port to close. The sink only has one input so the involved pointer is invalid. You may want to try replacing

inobject(current, item.Type) 

with

current.inObjects[1].inObjects[item.Type]

which will refer to the object feeding the Queue on the specified port.

· 9
5 |100000

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

mikelmb avatar image mikelmb commented ·

Hi Jason,

Thanks for your response.

I have changed that code and the port is still stopping when it does not have to:

1685549209917.png

0 Likes 0 ·
1685549209917.png (56.5 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦♦ mikelmb commented ·
Place a breakpoint in your code and step through it to check that the involved object is the one you want to close output. Use watch expressions to check your logic.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ mikelmb commented ·

Looking at this some more it seems you're not event seperating the Types into different racks so you can't just close a rack's port and stem the flow of one type.

Instead you can:

  • Use a pull requirement instead to determine which items can flow.
  • Decide where you want them to sit when demand is met - in the Queue or on the rack - to determine where the pull requirement should be set.
  • Every hour open the input of the object with the pull requirement to re-trigger it to check the items to pull (even though it is already open - this action forces it to happen rather than wait for a send request).
0 Likes 0 ·
mikelmb avatar image mikelmb Jason Lightfoot ♦♦ commented ·
Hi Jason,

I'm going for the pull requirement solution as i see it easier. I'll put that in the queue2, pulling from any port (all of the racks), but i don't really see how can I define the requirement for the flow items to enter, taking into account the demand global table. I only see option for pulling specific labels or ranges.

0 Likes 0 ·
Show more comments
Helen avatar image Helen commented ·

Thanks @Jason Lightfoot . I'm working together with Mikel on the model. We tried to pull from the global table based , but it doesn't really work.

We have created two variables to control the row and column of the global table demand that needs to take. It does not take all the parts that are needed. We used this code:


TableQty += 1;

if(TableQty == Table("demand")[CurrentHour+1][TableColumn])

{

TableColumn += 1; // Increment Column

TableQty = 0; // Reset table qty

}

// If end of global table... close input port of processor

if(TableColumn > Table("demand").numCols)

{

current.input.close();

TableColumn=1;

}


And initialize both variables in Global Variables at the simulation start. It seems that the problem is that the TableColumn is not correctly running. Can you help us with this?

definitiboooooooo2.fsm


Thank you,

Helen



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

I said to "Use a pull requirement instead to determine which items can flow".

You have put your code in the pull strategy, not the pull requirement, and therefore does not consider each item. The pull strategy says which ports to consider - you can use "Any Port" for now. Also - it looks like you have not moved your item count table from the sink to the queue which means you need to reference that on another object - it might be easier to add it to the queue.

The code will be similar to your sink entry code in the first model, it will just return true or false for each item trying to be pulled (ie. the requirement has been met or has not been met)


1685617592286.png


0 Likes 0 ·
1685617592286.png (7.8 KiB)
mikelmb avatar image mikelmb Jason Lightfoot ♦♦ commented ·

Good afternoon,

We did this following a guide in the forum: Pull by Global Table. In that thread @Jeff Nordgren attaches a model that pulls from a global table. In their example the use the Global Lookup is defined in the Pull Strategy.


Maybe it's something obvious but It's not clear for me how to put the code in the pull requirement. Also, if we use the global variable, does it make any sense to move the variable that we had in the sink in the previous model to the queue?

0 Likes 0 ·
Show more comments