Reading content in multiple atoms per label

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Mikkel
Posts: 2
Joined: Wednesday 25 March, 2015 - 16:56

Reading content in multiple atoms per label

Post by Mikkel »

Hi

We are quite new to enterprise dynamics and are currently struggling with an issue regarding how to count all products in multiple atoms in order to re-order products.

We have currently simplified the model to only contain 1 product with the following setup (the real model will contain above 10000 different products):

Source-->Queue1(Stock at supplier)-->Server1(delivery time from supplier)-->Queue2(Stock)-->Server2(delivery time to customer)-->Sink

Queue1 holds infinite stock of goods needed from the supplier.
Queue2 holds a amount of inventory based and is based on defined order quantities and re-order points (ROP).

The issue is that Queue2 should based on an order check whether the specific product is in stock (based on label) and then release to server2. When Queue2 reaches ROP it should order a defined order quantity (batch) from the Source which then goes into server1 and delivers to Queue2.
Yet, when products are "on the way" to Queue2 and have not yet been received at Queue2 it should not be ordered if the summarized amount is above the ROP. In other words ED should sum the quantity in stock+products on the way and evaluate whether these are below ROP.
All of this should function based on product labels.
What i am considering is to make an input strategy for server1 somewhat similar to the code below:

If(
(Label([ProductName])content(c))) + (Label([ProductName])content(out(1,c)))<ROP,
CloseInput(c),
OpenInput(c)
)

Additionally i don't know how it will open up for the specific order quantity defined.
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Reading content in multiple atoms per label

Post by HarryBunnik »

Ha,

I'm not entirely sure if I follow all, but to keep a stock with several entry and exits points, I would do the bookkeeping in a table (when your model gets more complicated, you otherwise will get trouble identifying where all products are and your code will become very big) and use the aliases at the different entry and exit points to in- or decrease the current content within your system. When this is exceeding a certain threshold, you can close the inputs of all the entry points. The tricky thing will be to identify all these entry points, perhaps a control atom with channels connected to all these points might be an option.
Once the stock gets below a minimum level, you can reopen these entry points again. Using OpenOutput and CloseOutput are the correct commands for something like this.

As far as your code goes. You have to use a atom reference (i, c, rank(3, c), first(c), Last(c), ....) to read out the value. So something like:

Code: Select all

Label([ProductName], first(c))
This would return the value of the label named ProductName (note that text or strings has to stand between square brackets "[" and "]", otherwise 4Dscrip will interpret is as a variable) that is defined on the first atom (a product) that is within the current atom (the atom on which you are running the code (a server or queue for instance).

I hope this helps you further,

Regards,

Harry
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Reading content in multiple atoms per label

Post by HarryBunnik »

And additionally, if you want to know the content of an atom, you're right in using:

Code: Select all

Content(c)  
or

Code: Select all

content(rank(1,c)) 
I'm not sure what you want with the:

Code: Select all

 Label([ProductName], content(c))
Cheers,

Harry
Mikkel
Posts: 2
Joined: Wednesday 25 March, 2015 - 16:56

Re: Reading content in multiple atoms per label

Post by Mikkel »

Hi Harry!

Thank you for the reply.

What it want with Label([ProductName], content(c)) is that i want a atom to only count the amount of atoms with a specific label within itself.
Is this possible in any way?

Best Regards
Mikkel
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Reading content in multiple atoms per label

Post by HarryBunnik »

Ha Mikkel,

Yes, that can be done, but is a bit more complicated.

I would use:

Code: Select all

Sum(content(c), If(Label([...],rank(count,c)) = 222, 1, 0))
This code counts all the atoms within the current atom(c), where the label([..], rank(count, c)) has a value of 222.

Regards,

Harry
Post Reply