question

Gabriela Buestan Yanez avatar image
0 Likes"
Gabriela Buestan Yanez asked Joerg Vogel edited

Capacity of racks

Good morning, I have a problem with the code, it is already assigned to each bay but in the first bays it is randomly stored and exceeds the capacity. Please, if you can help me with the program. Thank you

modelo-mm-copia.fsm

/**Custom Code*/


treenode item = param(1);
treenode current = ownerobject(c);
int cellcap = 2;
int baynum;


if (getitemtype(item)==1)
{
	baynum=duniform(1,10);
	break;
}
if (getitemtype(item)==2)
{
	baynum=duniform(11,18);
}
if (getitemtype(item)==3)
{
	baynum=duniform(19,30);


}
if (getitemtype(item)==4)
{
	baynum=duniform(31,50);


}


int flag = 2;
int bays = 2;
while(flag<=2) // loop limit
{
	if(rackgetbaycontent(current,baynum) < cellcap*rackgetnroflevels(current,baynum))// enough capacity
	{
		return baynum;
	}
	else
	{
	flag++;
	baynum = fmod(baynum,bays)+1 + (getitemtype(item) - 1)*bays ;//find next bay
	}
	break;
}
	
return (getitemtype(item) - 1)*bays + 1; //no right bay will goto first bay of specified itemtype

rackscapacitybayplace in bay
modelo-mm-copia.fsm (100.5 KiB)
· 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 ·

The rack has got a parameter which defines the maximum capacity, but not a capacity of a defined area. If there is capacity left, the item will be stored anyway. You can find an available rack cell and in this the bay. Or your source code will execute in the end you last return value. In this statement your itemtypes are in the range of [1..4], the integer variable bays is still 2. The return values can be 1, 3, 5 or 7. This way the first bay area of the bay numbers 1 to 10 are populated with all items which are not matching the conditions in the while loop. And the place in Level function returns in the standard the level 1 if there isn't any capacity left in the transmitted bay. The method of @Jeff Nordgren takes this into account. If you use a rack for each different itemtype the capacity parameter will evaluated correct in your matter and the item stays in the previous object. In your situation you have to check before you could send an item to the rack if there is capacity for the itemtype. If there isn't , the item stays in the queue. If an item leaves the rack you have to release an item of the same itemtype. Therefore you must have a list or a table of items, which are ready for release and you choose the right item for release and delete the item entry from the list.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Joerg Vogel commented ·

If you use the list approach you will find some suitable source code templates under the picklist items: Push to List, Pull from List. But you should enhance the code because the standard works without of the use of the list method. The list should you use only if an item of the previous queue is ready for release but there isn't any itemtype capacity left in the rack.

0 Likes 0 ·

1 Answer

Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered

@Gabriela Buestan Yanez,

In your code you do not have any cell (bay/level) maximum specified. You are just picking a random bay and putting it into a level on that by without any concern for limits.

In your modified model (modelo-mm-copia-jn1.fsm) I changed the single rack to be four separate racks with their own max content and a bay content limit. I do a Pull from each of these racks to get just the flowitem types matching their criteria. I also put a dwell time on each of the racks so that flowitems would eventually exit and not stop model execution. I connected the racks to the far left queue and that queue to the sink. This way, the model continues to run.

Take a look at the model and see if it is doing what you were wanting it to do. If you have any questions, please let us know.


5 |100000

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