Error in condition doesn't close the port when needed

Error in condition doesn't close the port when needed

mikelmb
Not applicable
43 Views
10 Replies
Message 1 of 11

Error in condition doesn't close the port when needed

mikelmb
Not applicable

[ FlexSim 22.1.4 ]

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,

0 Likes
Accepted solutions (1)
44 Views
10 Replies
Replies (10)
Message 2 of 11

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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.

0 Likes
Message 3 of 11

mikelmb
Not applicable

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
Message 4 of 11

jason_lightfootVL7B4
Autodesk
Autodesk
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
Message 5 of 11

jason_lightfootVL7B4
Autodesk
Autodesk

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
Message 6 of 11

mikelmb
Not applicable
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
Message 7 of 11

jason_lightfootVL7B4
Autodesk
Autodesk
The pull requirement fires for each item - so you can look up the table based on the hour, the item type and the accumulated demand so far and return zero if it cannot enter and one if it can.
0 Likes
Message 8 of 11

myriam_srdg
Not applicable

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 += 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
Message 9 of 11

jason_lightfootVL7B4
Autodesk
Autodesk

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
Message 10 of 11

mikelmb
Not applicable

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
Message 11 of 11

jason_lightfootVL7B4
Autodesk
Autodesk

Since your racks have mixed types and you want to restrict the types by hour you need to use the pull requirement, as I said.

You already had the logic in your sink entry trigger, as I explained above - all you need to do is decide when to return 0 instead of trying to close an output. At all other times when demand is not met return 1, meaning the requirement (to have remaining demand) is met.

Please read the answers we provide thoroughly and follow them to have the best experience on this site. While it would be easier to just give you the answer in a model, we try to encourage students to implement guidance we offer where possible.

0 Likes