stock

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

stock

Post by deltroya »

I am trying to count the actual stock in the system (with the priority system of the last topic). Lets assume that i have a stock of 15 products and if a products arrives then the stock is 15 - 1 = 14. After finishing a product at the machine the stock will go back to 15. I want to count the actual stock, so actual stock = stock - # in queue - product at machine.

So, I created the following , but now i only put a count in a table so, 0 and sometimes it is 1,2 or 3 and then again 0. But it would be better if it is 15 - .... so startvalue of 15 (i could not fix that...) . Furthermore:

how can i get the average? because i can not simply sum it up and devide it by time, because when should I sum it up? every second or every 10 sec. how can i deal with that?
Attachments
try3.mod
(28.12 KiB) Downloaded 307 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: stock

Post by MarvinH »

Hello again!
deltroya wrote:So, I created the following , but now i only put a count in a table so, 0 and sometimes it is 1,2 or 3 and then again 0. But it would be better if it is 15 - .... so startvalue of 15 (i could not fix that...) .
In your model you have already introduced the Initialize atom, well done. Currently, on reset you empty the tabel and increase the value in the table on exit of the sources and decrease the value on exit of the server. To model your system, simply set the value of the cell in the Initialize atom to 15. On exit of the sources you should then decrease the table value and increase the table value on exit of the server. This way it will start at 15 and decrease/increase when products move through your system.
deltroya wrote:Furthermore:

how can i get the average? because i can not simply sum it up and devide it by time, because when should I sum it up? every second or every 10 sec. how can i deal with that?
There are several ways to determine the average. I would propose the following:
  • - Store the current stock on the first cell;
    - Store the last time the stock changed on the second cell;
    - Store the sum until the last change time in the third cell;
    - Store the average until the last change in the fourth cell.
Now every time the first cell is to be updated (increased or decreased), you should update the other cells as well. First update the sum in the third cell. The sum equals the old sum, increased by the current stock (first cell) multiplied by the difference between the previous update time (second cell) and the current time (use function Time). Then update the second and fourth cell, and finally update the first cell, being the new stock. Obviously the average stock equals the sum divided by the time.

As you are getting more experienced now, I assume you can model this yourself! ;)

Kind regards,

Marvin
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

Re: stock

Post by deltroya »

Marvin, is created something, and i have the idea that it works :-), can you please have a look? (Sometimes it is possible that 15 < 0, how can i easily solve this? By saying, if(cell(1,1,Refuitvoertabel) < 0, 0, cell(1,1, Refuitvoertabel). I think this works, but is it the smartest way? Does the function max work for example?
Attachments
try4.mod
(29.42 KiB) Downloaded 283 times
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

Re: stock

Post by deltroya »

Marvin, I also included the backorder numbers, but help, the simulation will not go very fast... Is there a way to fix that? Because, now i have the idea that i have to wait for 10 hours...
Attachments
try5.mod
(31.46 KiB) Downloaded 275 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: stock

Post by MarvinH »

Hello!
deltroya wrote:Marvin, is created something, and i have the idea that it works :-), can you please have a look?
It's close, but there is a small error in the way you calculate your values. The formula for each cell value is correct, only the order in which the cell values are determined should be different. Have a look at my previous post (see below) again! ;)
MarvinH wrote:Now every time the first cell is to be updated (increased or decreased), you should update the other cells as well. First update the sum in the third cell. The sum equals the old sum, increased by the current stock (first cell) multiplied by the difference between the previous update time (second cell) and the current time (use function Time). Then update the second and fourth cell, and finally update the first cell, being the new stock.
deltroya wrote:Sometimes it is possible that 15 < 0, how can i easily solve this? By saying, if(cell(1,1,Refuitvoertabel) < 0, 0, cell(1,1, Refuitvoertabel).
This should work indeed! I don't know whether it is possible to have a stock < 0 in your system. Otherwise, you should solve it in another way, i.e. avoid products to enter the model in case the stock equals 0.
deltroya wrote:I think this works, but is it the smartest way? Does the function max work for example?
Max function or the if statement would return the same values, so that does not matter in this situation. For information about specific Enterprise Dynamics functions, please refer to the Help file (F1).
deltroya wrote:Marvin, I also included the backorder numbers, but help, the simulation will not go very fast... Is there a way to fix that?
Try closing the table when your running the model, and only view the table values when your simulation is finished.

Regards,

Marvin
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

Re: stock

Post by deltroya »

Thanks again, hopefully the latest file now is o.k.? I also stored the so called backorders, (if stock level < 0). So in fact i can now obtain the costs for both situations! Is it also possible to simulate for several p - values (the p values of the last topic, with 0.5 etc.) so for example the simulation starts with p1 = 0.1 and p2 = 0.9 then receive some answers and then go further with p1 = 0.2 ... etc. or should i do that by hand? :lol:
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

Re: stock

Post by deltroya »

deltroya wrote:Thanks again, hopefully the latest file now is o.k.? I also stored the so called backorders, (if stock level < 0). So in fact i can now obtain the costs for both situations! Is it also possible to simulate for several p - values (the p values of the last topic, with 0.5 etc.) so for example the simulation starts with p1 = 0.1 and p2 = 0.9 then receive some answers and then go further with p1 = 0.2 ... etc. or should i do that by hand? :lol:
Attachments
try5.mod
(31.56 KiB) Downloaded 280 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: stock

Post by MarvinH »

Hello!
deltroya wrote:Thanks again, hopefully the latest file now is o.k.?
Yes, I think it is correct now.
deltroya wrote:Is it also possible to simulate for several p - values (the p values of the last topic, with 0.5 etc.) so for example the simulation starts with p1 = 0.1 and p2 = 0.9 then receive some answers and then go further with p1 = 0.2 ... etc. or should i do that by hand? :lol:
Yes, this possible. You should have a look at the Experiment Wizard. On start of a new run, you can execute some code. In your case, you can change the p1 value. In order to be able to use one general p1 value, it would be better to use a global variable or cell value in the script in the input trigger of the server. So on start of the run you do not have to change the complete code, but only the value of the global variable of the cell value. For more information about the Experiment Wizard or global variables, please have a look in the Help-file.

Good luck!
deltroya
Posts: 21
Joined: Monday 26 December, 2011 - 15:11

Re: stock

Post by deltroya »

Thank you marvin!
Post Reply