Hi,
I'm using a FloorStorage inside a taskexecuter flowitem to simulate a container vessel for a port simulation model. The objective for the model is to simulate the utilization of equipment such as cranes and trucks inside a container port. The reason for using a FloorStorage inside the flowitem is that it allows me to store containers in specific slots and positions on the vessel and find containers in specific slots which is easier than of using the packing method on a flowitem.
The downside of this method is that it doesn't allow me to use the "Find Slot" and "Find Item" functions in Process Flow because only the storageObjects in the flowitembin are add to the StorageSystem in the tree. The storageObjects in flowitems created in the model are not added to the tree and can't be queried with the basic functions. It would be a bonus if someone knows a way to get these items added in the tree and it would be possible to use the basic functions.
My solution to this is to use custom code and point to the specific subnodes (FloorStorage) on the flowitem to assign slots to items. This works as intended but now I've come across a problem I can't figure out.
First I'll start with explaining my approach and then I'll come to the problem.
When a vessel arrives at the port I create the vessel flowitem and create a container flow items for each 20ft and 40 ft container on the vessel. When I search for a slot on the vessel I do this first for the front deck and than for the rear deck because these are two different FloorStorage objects inside the vessel. I use the following code FindRandomSlotVesselCreation.png
This works as long as the number containers doesn't exceed the storage capacity. When the vessel arrives I create a shopping list for the containers which need to be loaded onto the vessel after unloading is finished. The shopping list looks for the same amount of 20 and 40 foot containers but will have different distributions of empty and full containers depending on the destination of the vessel. Once I have the shopping list I search the container yard for the appropriate containers and put them on the list. After the ship is unloaded I start to process of assigning storage slots to the containers. This can only be done after the ship is empty because otherwise the ship will be to full and containers will not receive a slot.
In this last process is where I encounter a problem which I don't understand. The code for finding slots is almost identical as the one used when the vessel is created. Find Random Slot Cargo - Custom Code.png However the difference is that the item state is different and the container is not created in the model but already stored in a FloorStorage object in the container yard. After 196 containers at time (61666.25) it fails to assign slots to 40ft containers and when I look into this it seems that the following evaluation gives an unexpected result:
if(!slot.isStorable || !slot.hasSpace(item)) continue;
The result of the if statement keeps being true and therefore the while loop will run until the counter is at 10001 and then stops.
When I look into this the "!slot.hasSpace(item)" returns 1 which I can't explain. When I check the last container it evaluated and the last slot it evaluated I come to the conclusion that:
- The slot is storable so !slot.isStorable return false, which is good
- The !slot.hasSpace returns 1. However it only has 1 40ft container assigned to it so should return false. The size of the slot is [14.2, 2.5, 12.5] and a 40ft container is [12.2, 2.44, 2.5].
- The slot has 1 item of the same Type
- The orientation of the item is equal to all previous containers so the orientation can't be the reason the slot doesn't have space.
So in my view the slot must have been assigned to the item but it didn't. Can someone help me with figuring out why this happens?