setting max and minimums

Use this forum to post Vensim related questions.
Post Reply
gastoncoma
Junior Member
Posts: 13
Joined: Mon Aug 17, 2009 4:07 am

setting max and minimums

Post by gastoncoma »

Hi guys, first time here.

How do you set the minimum population so to not get negative numbers?

Cheers
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Population is normally a level and can only be decreased by deaths which in turn depend on population. That feedback guarantees it will never go negative. If you are having numerical problems you might switch to Runge-Kutta integration or decrease TIME STEP. If it is more than just numerical problems double check your equations.
karankhosla
Senior Member
Posts: 107
Joined: Wed Nov 26, 2008 6:12 am

Post by karankhosla »

One way to prevent negative stocks is to use MIN and MAX functions in the following way:

For Inflow (IR): IR = MAX(0, Desired Inflow),
where Desired Inflow could be whatever. This way if Desired Inflow is negative the flow constrains it self to 0.

For Outfow (OR): OR = MIN(Maximum Outflow, Desired Outflow),
where Maximum Outflow is, for example, the (Stock)/(Min. Time to Process Each Stock Member). Desired Outflow can be whatever; hence, if Desired Outflow is greater than Maximum outflow, the OR chooses Maximum Outflow and the Stock cannot be drained into the negative.

Best Wishes,

Karan
gastoncoma
Junior Member
Posts: 13
Joined: Mon Aug 17, 2009 4:07 am

Post by gastoncoma »

thanks karan!!
Post Reply