Hi,
a beginner's problem.
I have a stock variable which has 2 outflows. Now I want to make sure that the stock never reaches something below zero.
stock ... population
outflow 1 ... moveing
outflow 2 ... deaths
Both outflows are influced by some other varibales.
What I have done is this: for both outflows I used an IF_THEN_ELSE like
IF Stock-myCurrentOutFlow>0 THE myCurrentOutFlow ELSE Stock
Are there any other (better) solutions? What really troubles me is that there are 2 outflows.
Maybe both checks are done and after that the execution of both statements takes place. The checks would be ok but the stock could drop below zero!!!
BTW: is there something like user-defined-function? I do not want external DLLs, just a combination of some built-in functions.
Best regards,
jmu
Stock variabel with 2 outflows
Stock variable with tow stocks
Hi
If you have two differentiated outflows, you cannot agregate them and write total outflow = if then else (original total outflow > stock, stock, original total outflow) and that's all. You still have to decide what outflow will support the reduction of its original outflow to meet the requirement of reducing the total outflow by the amount original total outflow - stock.
It is then a question of policy. you can decide that both outflows will support half of the reduction or anything else.
In that case, you will have total original outflow = original outflow1 + original outflow 2. You will then have definitive outflow1 = original outflow1 -
((total original outflow - stock) / 2) provided that outflow 1 is positive, and the same for outflow2.
If it is not positive you have to build another way of repartition may be by weighting the reduction proportionnaly to the original outflow.
To my opiniong there is no predefined function to do thal, taking in consideration the infinite number of policies.
All this is common sense, there is no magic in it.
Regards.
JJ
[Edited on 14-11-2008 by LAUJJL]
If you have two differentiated outflows, you cannot agregate them and write total outflow = if then else (original total outflow > stock, stock, original total outflow) and that's all. You still have to decide what outflow will support the reduction of its original outflow to meet the requirement of reducing the total outflow by the amount original total outflow - stock.
It is then a question of policy. you can decide that both outflows will support half of the reduction or anything else.
In that case, you will have total original outflow = original outflow1 + original outflow 2. You will then have definitive outflow1 = original outflow1 -
((total original outflow - stock) / 2) provided that outflow 1 is positive, and the same for outflow2.
If it is not positive you have to build another way of repartition may be by weighting the reduction proportionnaly to the original outflow.
To my opiniong there is no predefined function to do thal, taking in consideration the infinite number of policies.
All this is common sense, there is no magic in it.
Regards.
JJ
[Edited on 14-11-2008 by LAUJJL]
Thanks for your answer - I see how much I still have to learn ....
But the problem was completly different. I really wondered about the drop below zero in my small model (it was just a single value at the second step). But when I switch from Euler to Runge-Kutta then everything works as expected. A newbie pitfall it seems.
Thanks,
jmu
But the problem was completly different. I really wondered about the drop below zero in my small model (it was just a single value at the second step). But when I switch from Euler to Runge-Kutta then everything works as expected. A newbie pitfall it seems.
Thanks,
jmu