Page 1 of 1

What kind of variable to use

Posted: Tue Feb 21, 2017 7:17 pm
by Priscila
Good afternoon,
I need to create a variable (can be level) where I have an initial value and need to go discounting this value, for example:
X = 30 initial value
Y = 1,2,3,4
Z = 20 at the end of the simulation

How Do I Get Z?

Re: What kind of variable to use

Posted: Tue Feb 21, 2017 7:55 pm
by tomfid
I think you'll have to supply some more detail here. What are x, y and z and their units? What is this system doing?

Re: What kind of variable to use

Posted: Tue Feb 21, 2017 8:19 pm
by Priscila
X is an initial value, amount of raw material that the company receives per month
Y is the amount of raw material consumed over the month
Z is what still has available raw material
What has available (Z) is used for the production of the product (W) that will supply the amount of raw material used (Y).
The units are all liters.

Re: What kind of variable to use

Posted: Tue Feb 21, 2017 9:18 pm
by tomfid
So, putting this in SD language,
X is the inflow of material supply
Y is the outflow of material consumption
Z is the stock of material on hand

Then:
Z = INTEG(X-Y, initial Z)

If the units for Z are liters, then X and Y must be in liters/month.

One way to frame this is as an optimization problem, using the optimizer to determine the X needed to provide enough material to serve Y and leave Z=20 at the end.

An approach that's more likely to be satisfying is to treat this as a dynamic stock management problem, like the "target production" decision in the workforce-inventory model distributed with Vensim:
https://www.vensim.com/documentation/21445.htm

Re: What kind of variable to use

Posted: Tue Feb 21, 2017 9:38 pm
by Priscila
Is Z a level variable?

Re: What kind of variable to use

Posted: Tue Feb 21, 2017 10:00 pm
by tomfid
Correct. Terminology varies unfortunately, but stock = level = state variable = integral, and flow = rate = derivative.

In Vensim, stocks are defined by the INTEG function, and usually a box on the diagram (though you can change the diagram to diverge from the convention).

Re: What kind of variable to use

Posted: Wed Feb 22, 2017 12:06 am
by Priscila
It is not working because the simulation runs in a period of 2683 (which is the period of a month of 15 in 15 minutes) and the variable X is a data that enters at t = 0 and decays as used (Y), however the Variable Z is accumulating at each t + 1 it increases the value of X and decreases Y. I need a variable that reduces the stock (initial value when t = 0) over time, as production increases.

Re: What kind of variable to use

Posted: Wed Feb 22, 2017 3:50 am
by tomfid
Can you post the model?

Re: What kind of variable to use

Posted: Wed Feb 22, 2017 9:43 am
by Priscila
The model is attached, the variables I am trying to adjust are in blue, contextualizing with the previous conversations the amount of fuel received is X, Y is the fuel output and Z represents stored alcohol.

Re: What kind of variable to use

Posted: Wed Feb 22, 2017 5:15 pm
by tomfid
I think the problem is that you don't have any feedback to determine the inflow (Quantidade de combustível recebido). Setting it to a constant won't work in general.

The generic form of what you need is something like:

inflow = expected outflow + (desired stock - stock)/stock adjustment time

There's an example of this in the workforce-inventory model link I posted above (except in that case, the inflow is not direct, but mediated by the labor force).