Sales with different dates

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Marthieka
Posts: 2
Joined: Friday 15 January, 2016 - 14:26

Sales with different dates

Post by Marthieka »

Hello,

I'm writing my master thesis atm and I'm using ED for it to model a chicken supply chain. The idea is to see the difference between a 'normal' use by date and a dynamic shelf life date, based on the time and temperature the product has experienced and with that indirectly the bacterial growth. The chain runs from packaging untill the final sales in the supermarket.
But for this last part, I want to model the behaviour of customers, a certain percentage buying LEFO(last to expire first out) and the rest buying FEFO(first to expire first out). I know there are a few ways of doing it, the most used is to have different queues with different use by dates and to model the customers by having an order picked. The problem now is that I will have so many different dates because of variations in time and temperature that is unfeasible to make different queues for each use by date.
The idea that I have so far is to make 2 different queues, one queue being a LEFO queue(with items sorted by use by date) and the other a FEFO. But the problem is how to get these products in there in the right way. What in my eyes would be easiest, is to have a queue ordered in a certain way(either LEFO or FEFO) and if there would be a send to code that would say 'the first ...% is sent to channel 1 and the rest is sent to channel 2'. But the different codes that are present as the 'send to' rules in ED don't really do this. The 'by percentage' sends a certain percentage to channel 1 and the rest to channel 2, but does this in a random order. Round robin sends the 1st product to the first channel, the 2nd to the second channel, the 3rd again to the first. Conditionally also doesn't work as it isn't the case that for example LEFO buyers would only buy products that have a use by date of no less than .. days.
I also tried to do this via order picking, to have different orders for LEFO and for FEFO, but I can give the orders the right label, but (as far as I see) can't give the products then a label that matches the LEFO or FEFO order so they can be splitted to go to different queues.

I really hope that someone has an idea of how to do this, or some ideas that I can try.
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Sales with different dates

Post by HarryBunnik »

Hello Marthieka,

Would it be an idea to store all products in one queue and then, based on the consumer type (LEFO or FEFO), take either the last or the first product in the row (you would have to place the last product in the queue to the first position, before reopening the queue again (SetRank(1, last(atmQueue))?

In case a consumer takes more then 1 product, you'll have to move the last product to the front every time a product entered the assembler (I would use this to unite the consumer with the product(s)).

Closing and opening of the queue you can do with CloseOutput and OpenOutput.

I hope this gives you some ideas,

Gr. Harry
Marthieka
Posts: 2
Joined: Friday 15 January, 2016 - 14:26

Re: Sales with different dates

Post by Marthieka »

Dear Harry,

Thank you for your reply.
Your idea would work if a new product that enters the queue always has a newer shelf life than the previous one. Unfortunately, this is not the case as they all go through a different temperature pattern. So to use your method, it would have to switch from label ascending to label descending every time the queue is opened again. I don't know if it is possible to write this in 4D script?

Thank you in advance
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Sales with different dates

Post by HarryBunnik »

Ha Marthieka,

I see your problem and think it can be solved, but also think that there might be an easier way, which I made a small example model for:
TakeFromQueueInOrderShelfLife.mod
(23.43 KiB) Downloaded 274 times
What I do now is that each product that arrives on the queue, I register in a table. This table I sort on the age of the atom (my shelf life. You might want to replace this with a more sophisticated formula ;-) ). Then when a client arrives in the Assembler, I check if the client is FEFO or LEFO. In case it's LEFO I take the last line in the table (the youngest one), else the first row (the oldest one). When the product leaves the Queue, I remove it's related row from the table.

in the model you'll see that I've written some extra code on the OnEntry and OnExit triggers of the "QueueOfProducts" (including a stop, so you can see what happens) and on the Assembler to assign the correct product to the client. As you see it takes a little of administration ;-)

The table you can open to see the effect of products coming in and going out.

I hope this helps you in getting further.

Cheers,

Harry
Post Reply