Page 1 of 1

Exporting Equations in Computational Order PLE

Posted: Sun Aug 27, 2017 1:58 pm
by mar898989
Hey there,
I am using Vensim PLE for my master thesis. Now for my work it is essential to export the equations of my model in computational order to a txt file. As I am only using Vensim PLE I cannot simply rightclick "document" and then use the document options tool to export the equations using the comp sorting ("cannot change tool options in Vensim PLE"). So I figured I could simply, manually, export the equations from the standard document window, however I am a bit puzzled as to how exactly the computational sorting works (how it sorts stocks and flows etc.).

Any help would be greatly appreciated!

cheers

Re: Exporting Equations in Computational Order PLE

Posted: Sun Aug 27, 2017 5:49 pm
by tomfid

Re: Exporting Equations in Computational Order PLE

Posted: Sun Aug 27, 2017 6:01 pm
by tomfid
If you can post the model, we can dump the ordered equations in about 10 seconds.

Re: Exporting Equations in Computational Order PLE

Posted: Thu Nov 02, 2017 3:25 pm
by mar898989
Thanks for the quick reply! And sorry for the delayed response :roll:
My model is almost complete by now. I have one issue left though. I want to include a customizable change in an elasticity over time, into my model. The current version works with a look up variable, where the change in the elasiticy is not customizable:


[(1980,0)-(2050,100)],(1980,3.34),(2015,3.34),(2020,1.2),(2050,1.2)

I would like to change the 1.2 into something like a*3.34 and the 2020 into 2015+b. However, when typing 3.34*a instead of 1.2, I get the "expecting an operator"-error.

Re: Exporting Equations in Computational Order PLE

Posted: Thu Nov 02, 2017 3:41 pm
by Administrator
You cannot have equations in a lookup definition.

Re: Exporting Equations in Computational Order PLE

Posted: Thu Nov 02, 2017 4:16 pm
by tomfid
That's possible with VECTOR LOOKUP, but not in PLE.

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 11:09 am
by mar898989
tomfid wrote:If you can post the model, we can dump the ordered equations in about 10 seconds.
tomfid wrote:If you can post the model, we can dump the ordered equations in about 10 seconds.
Seems like I am using the wrong version :lol:
Anyway, as time is become a factor (for my thesis) I am posting the model.

{UTF-8}
"% reduction in max income"=
0
~ Dmnl
~ |

Adjusted maximum income=
Initial maximum income-step(Initial maximum income*"% reduction in max income",2015)
~ dollar/person
~ -step(100000,2015) The carrying capacity of the environment. Defined as 1 \
for testing (100% of its value).
|

carrying capacity=
50000
~ rhino
~ 27837=4454/0.16 (0.16 proportion of carrying capacity rhinos 1985 \
(Milner-Gulland&Leader Williams 1992) 4454 estimated population 1985) but \
this is for LV, Zambia. Need to get better estimate of K (perhaps by \
obtaining area of game reserves and multiply by MG&LW's figure of 0.4km2 \
for K)
|

change in price=
IF THEN ELSE(target price > price,
(target price - price)/time to adjust price up,
(target price-price)/time to adjust price down)
~ dollar/kg/year
~ |

conv rhino to kg=
1
~ kg/rhino
~ |

demand=
(reference demand * effect price demand+reference demand*effect income demand)
~ rhino/year
~ |

effect income demand=
EXP(IncomeElasticity* LN(Income/reference income))
~ Dmnl
~ |

effect price demand=
EXP(-price elasticity * LN(price/reference price))
~ Dmnl
~ |

expected demand=
MIN(max(SMOOTH(demand,time to form expectations),0),Rhino population/time to adjust
)*SimpleAcceptance
~ rhino/year
~ |

fraction of carrying capacity=
(Rhino population/(carrying capacity))^(z)
~ Dmnl
~ |

Fractional Net Income=
Maximum Fractional Net income * (1 - Income/Adjusted maximum income)
~ 1/year
~ The fractional net birth rate is a linearly declining function of the \
population relative to carrying capacity.
|

Income= INTEG (
Increase in income,
Initial income Fraction * Adjusted maximum income)
~ dollar/person
~ The population accumulates the net birth rate. Initialized to a fraction \
of the carrying capacity.
|

IncomeElasticity=
LookUp(Time)
~
~ |

Increase in income=
Fractional Net Income * Income
~ dollar/person/year
~ The net birth rate is the product of the fractional net birth rate and \
population.
|

Initial income Fraction=
0.001
~ Dmnl
~ The initial population as a fraction of the carrying capacity.
|

Initial maximum income=
216000
~ dollar/person
~ |

initial price=
1762
~ dollar/kg
~ 100
|

intrinsic growth rate=
0.061
~ 1/year
~ 0.16 (MG&LW)
|

LookUp(
[(1980,0)-(2050,10)],(1980,3.34),(2017,3.34),(2022,1.5),(2050,1.5))
~
~ |

Maximum Fractional Net income=
0.094
~ 1/year
~ The maximum fractional growth rate is set to 1, thus scaling time so that \
1 time unit = 1/g* (yielding the standard logistic curve).
|

maximum price=
135000
~ dollar/kg
~ |

net birth rate=
max(intrinsic growth rate*Rhino population,0)
~ rhino/year
~ |

price= INTEG (
change in price,
initial price)
~ dollar/kg
~ |

price elasticity=
0.1
~ Dmnl
~ |

reference demand=
10
~ rhino/year
~ |

reference income=
840
~ dollar/person
~ 100
|

reference price=
100
~ dollar/kg
~ |

removals=
MIN(IF THEN ELSE((Rhino population/time to adjust)>((fraction of carrying capacity)*\
Rhino population/time to adjust+expected demand
),(fraction of carrying capacity)*Rhino population/time to adjust+expected demand,Rhino population\
/time to adjust),Rhino population*(1+intrinsic growth rate))
~ rhino/year
~ |

Rhino population= INTEG (
net birth rate-removals,
3525)
~ rhino
~ 0.6289
|

SimpleAcceptance=
1
~
~ |

target price=
MIN(
XIDZ(target revenue,expected demand*conv rhino to kg,maximum price),
maximum price)
~ dollar/kg
~ |

target revenue=
5e+007
~ dollar/year
~ 10000+STEP(5000, 10)
|

time to adjust=
0.7
~ year
~ 1
|

time to adjust price down=
6
~ year
~ |

time to adjust price up=
50
~ year
~ 4
|

time to form expectations=
4.7
~ year
~ 1
|

z=
7
~ Dmnl
~ 7 MG&LW92
|

********************************************************
.Control
********************************************************~
Simulation Control Parameters
|

FINAL TIME = 2050
~ year
~ The final time for the simulation.
|

INITIAL TIME = 1980
~ year
~ The initial time for the simulation.
|

SAVEPER =
TIME STEP
~ year [0,?]
~ The frequency with which output is stored.
|

TIME STEP = 1
~ year [0,?]
~ The time step for the simulation.
|

\\\---/// Sketch information - do not modify anything except names
V300 Do not put anything below this section - it will be ignored
*View 1
$192-192-192,0,Times New Roman|12||0-0-0|0-0-0|0-0-255|-1--1--1|-1--1--1|96,96,100,0
10,1,Rhino population,487,197,40,20,3,3,0,0,0,0,0,0
10,2,carrying capacity,405,282,53,11,8,3,0,0,0,0,0,0
10,3,fraction of carrying capacity,534,279,60,19,8,3,0,0,0,0,0,0
10,4,intrinsic growth rate,305,87,48,19,8,3,0,0,0,0,0,0
12,5,48,291,197,10,8,0,3,0,0,-1,0,0,0
1,6,8,1,4,0,0,22,0,0,0,-1--1--1,,1|(413,197)|
1,7,8,5,100,0,0,22,0,0,0,-1--1--1,,1|(334,197)|
11,8,48,374,197,6,8,34,3,0,0,1,0,0,0
10,9,net birth rate,374,216,40,11,40,3,0,0,-1,0,0,0
1,10,1,8,1,0,0,0,0,64,0,-1--1--1,,1|(409,146)|
10,11,z,454,345,5,11,8,3,0,0,-1,0,0,0
1,12,2,3,1,0,0,0,0,64,0,-1--1--1,,1|(488,255)|
1,13,11,3,1,0,0,0,0,64,0,-1--1--1,,1|(529,285)|
12,14,48,687,197,10,8,0,3,0,0,-1,0,0,0
1,15,17,14,4,0,0,22,0,0,0,-1--1--1,,1|(642,197)|
1,16,17,1,100,0,0,22,0,0,0,-1--1--1,,1|(561,197)|
11,17,48,602,197,6,8,34,3,0,0,1,0,0,0
10,18,removals,602,216,29,11,40,3,0,0,-1,0,0,0
1,19,4,9,1,0,0,0,0,64,0,-1--1--1,,1|(366,155)|
1,20,1,3,1,0,0,0,0,64,0,-1--1--1,,1|(488,232)|
1,21,3,18,1,0,0,0,0,64,0,-1--1--1,,1|(604,255)|
1,22,1,18,1,0,0,0,0,64,0,-1--1--1,,1|(562,156)|
10,23,time to adjust,685,152,43,11,8,3,0,0,-1,0,0,0
1,24,23,18,1,0,0,0,0,64,0,-1--1--1,,1|(634,166)|
10,25,effect price demand,1021,438,36,19,8,3,0,0,0,0,0,0
10,26,price,944,495,40,20,3,3,0,0,0,0,0,0
10,27,demand,891,432,26,11,8,3,0,0,0,0,0,0
10,28,time to adjust price up,688,561,43,19,8,3,0,0,0,0,0,0
1,29,25,27,1,0,0,0,0,64,0,-1--1--1,,1|(977,437)|
1,30,26,25,1,0,0,0,0,64,0,-1--1--1,,1|(967,456)|
10,31,price elasticity,1104,487,45,11,8,3,0,0,0,0,0,0
1,32,31,25,1,0,0,0,0,64,0,-1--1--1,,1|(1064,488)|
1,33,28,39,1,0,0,0,0,64,0,-1--1--1,,1|(789,541)|
10,34,initial price,956,545,34,11,8,3,0,0,0,0,0,0
12,35,48,768,494,10,8,0,3,0,0,-1,0,0,0
1,36,38,26,4,0,0,22,0,0,0,-1--1--1,,1|(875,494)|
1,37,38,35,68,0,0,22,2,0,0,-1--1--1,|12||0-0-0,1|(806,494)|
11,38,48,840,494,6,8,34,3,0,0,1,0,0,0
10,39,change in price,840,513,47,11,40,3,0,0,-1,0,0,0
1,40,26,39,1,0,0,0,0,0,0,-1--1--1,,1|(896,533)|
10,41,reference price,1172,454,47,11,8,3,0,0,-1,0,0,0
1,42,41,25,1,0,0,0,0,0,0,-1--1--1,,1|(1158,443)|
10,43,time to adjust price down,797,588,43,19,8,3,0,0,0,0,0,0
1,44,43,39,1,0,0,0,0,64,0,-1--1--1,,1|(828,541)|
1,45,34,26,0,0,0,0,0,0,1,-1--1--1,,1|(953,531)|
10,46,expected demand,796,434,40,20,3,3,0,0,0,0,0,0
1,47,27,46,0,0,0,0,0,64,0,-1--1--1,,1|(857,432)|
10,48,time to form expectations,617,375,40,19,8,3,0,0,0,0,0,0
1,49,48,46,1,0,0,0,0,64,0,-1--1--1,,1|(715,377)|
10,50,reference demand,1028,399,56,11,8,131,0,0,0,0,0,0
1,51,50,27,1,0,0,0,0,64,0,-1--1--1,,1|(902,402)|
10,52,target revenue,633,421,45,11,8,3,0,0,0,0,0,0
10,53,target price,694,471,36,11,8,3,0,0,0,0,0,0
1,54,52,53,1,0,0,0,0,64,0,-1--1--1,,1|(666,455)|
1,55,46,53,1,0,0,0,0,64,0,-1--1--1,,1|(726,454)|
1,56,53,39,1,0,0,0,0,64,0,-1--1--1,,1|(770,507)|
10,57,maximum price,585,572,48,11,8,3,0,0,0,0,0,0
1,58,57,53,1,0,0,0,0,64,0,-1--1--1,,1|(619,482)|
10,59,effect income demand,845,348,43,19,8,3,0,0,0,0,0,0
10,60,reference income,1031,323,54,11,8,3,0,0,0,0,0,0
1,61,60,59,1,0,0,0,0,64,0,-1--1--1,,1|(932,347)|
1,62,59,27,1,0,0,0,0,64,0,-1--1--1,,1|(847,405)|
1,63,46,18,1,0,0,0,0,64,0,-1--1--1,,1|(656,249)|
10,64,Income,995,194,40,20,3,3,0,0,0,0,0,0
12,65,48,832,194,10,8,0,3,0,0,-1,0,0,0
1,66,68,64,4,0,0,22,0,0,0,-1--1--1,,1|(929,194)|
1,67,68,65,100,0,0,22,0,0,0,-1--1--1,,1|(866,194)|
11,68,48,897,194,6,8,34,3,0,0,1,0,0,0
10,69,Increase in income,897,222,58,11,40,3,0,0,-1,0,0,0
10,70,Adjusted maximum income,987,83,61,19,8,3,0,0,0,0,0,0
10,71,Fractional Net Income,857,126,46,19,8,3,0,0,0,0,0,0
1,72,64,69,1,0,0,0,2,192,0,-1--1--1,|12||0-0-0,1|(979,254)|
1,73,71,69,1,0,0,0,2,192,0,-1--1--1,|12||0-0-0,1|(854,193)|
1,74,70,71,1,0,0,0,2,192,0,-1--1--1,|12||0-0-0,1|(915,95)|
1,75,64,71,1,0,0,0,2,192,0,-1--1--1,|12||0-0-0,1|(937,120)|
10,76,Maximum Fractional Net income,734,82,66,19,8,3,0,0,0,0,0,0
1,77,76,71,1,0,0,0,2,192,0,-1--1--1,|12||0-0-0,1|(826,119)|
10,78,Initial income Fraction,1127,195,42,19,8,3,0,0,0,0,0,0
1,79,70,64,0,0,0,0,0,64,1,-1--1--1,,1|(990,131)|
1,80,78,64,0,0,0,0,0,64,1,-1--1--1,,1|(1066,194)|
10,81,Initial maximum income,1135,52,49,19,8,3,0,0,0,0,0,0
1,82,81,70,1,0,0,0,0,64,0,-1--1--1,,1|(1059,58)|
10,83,"% reduction in max income",1147,135,61,19,8,3,0,0,0,0,0,0
1,84,83,70,1,0,0,0,0,64,0,-1--1--1,,1|(1050,136)|
1,85,64,59,1,0,0,0,0,64,0,-1--1--1,,1|(1000,221)|
1,86,1,46,1,0,0,0,0,64,0,-1--1--1,,1|(527,391)|
1,87,23,46,1,0,0,0,0,64,0,-1--1--1,,1|(778,287)|
1,88,4,18,1,0,0,0,0,64,0,-1--1--1,,1|(477,101)|
10,89,conv rhino to kg,530,477,51,11,8,3,0,0,0,0,0,0
1,90,89,53,1,0,0,0,0,64,0,-1--1--1,,1|(588,464)|
12,91,0,620,144,40,20,8,3,0,0,-1,0,0,0
10,92,Time,866,264,26,11,8,2,0,3,-1,0,0,0,128-128-128,0-0-0,|12||128-128-128
10,93,LookUp,791,266,28,11,8,3,0,0,0,0,0,0
10,94,IncomeElasticity,849,303,51,11,8,3,0,0,0,0,0,0
1,95,93,94,0,0,0,0,0,64,0,-1--1--1,,1|(813,280)|
1,96,92,94,0,0,0,0,0,64,0,-1--1--1,,1|(860,277)|
1,97,94,59,0,0,0,0,0,64,0,-1--1--1,,1|(848,314)|
10,98,SimpleAcceptance,646,333,59,11,8,3,0,0,0,0,0,0
1,99,98,46,0,0,0,0,0,64,0,-1--1--1,,1|(708,375)|
///---\\\
:L<%^E!@
1:CurrentCBM.vdf
1:CurrentNoCBM.vdf
1:Current.vdf
9:CurrentCBM
23:0
15:0,0,0,0,0,0
19:100,0
27:0,
34:0,
4:Time
5:SimpleAcceptance
35:Date
36:YYYY-MM-DD
37:2000
38:1
39:1
40:0
41:0
42:1
24:1980
25:2050
26:2050


Thanks a lot!

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 11:21 am
by Administrator
The output of the document tool is below (with the computation order switch enabled). But I don't think it's right.

Code: Select all

(01)	INITIAL INCOME FRACTION - 
	
(02)	INITIAL MAXIMUM INCOME - 
(03)	% REDUCTION IN MAX INCOME - 
(04)	adjusted maximum income - 
(05)	Income - 
(06)	INITIAL PRICE - 
(07)	Price - 
(08)	Rhino Population - 
(09)	CARRYING CAPACITY - 
(10)	TARGET REVENUE - 
(11)	REFERENCE DEMAND - 
(12)	PRICE ELASTICITY - 
(13)	REFERENCE PRICE - 
(14)	effect price demand - 
(15)	LOOKUP - 
(16)	incomeelasticity - 
(17)	REFERENCE INCOME - 
(18)	effect income demand - 
(19)	demand - 
(20)	#expected Demand>smooth# - 
(21)	TIME TO ADJUST - 
(22)	SIMPLEACCEPTANCE - 
(23)	expected demand - 
(24)	CONV RHINO TO KG - 
(25)	MAXIMUM PRICE - 
(26)	target price - 
(27)	TIME TO ADJUST PRICE UP - 
(28)	TIME TO ADJUST PRICE DOWN - 
(29)	change in price - 
(30)	FINAL TIME - 
(31)	Z - 
(32)	fraction of carrying capacity - 
(33)	MAXIMUM FRACTIONAL NET INCOME - 
(34)	fractional net income - 
(35)	increase in income - 
(36)	INITIAL TIME - 
(37)	INTRINSIC GROWTH RATE - 
(38)	net birth rate - 
(39)	removals - 
(40)	TIME STEP - 
(41)	saveper - 
(42)	TIME TO FORM EXPECTATIONS - 

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 11:29 am
by mar898989
Administrator wrote:The output of the document tool is below (with the computation order switch enabled). But I don't think it's right.
Thanks!
What makes you think it's not wright? Something wrong with the model? It simulates properly, or at least that's what I think :lol:

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 11:33 am
by Administrator
The order of equations does not seem correct to me. I don't think they are in the correct order.

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 2:23 pm
by tomfid
What do you need comp order for? You could take a look at PySD or SDeverywhere if you need to translate it to a programming language.

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 3:33 pm
by mar898989
tomfid wrote:What do you need comp order for? You could take a look at PySD or SDeverywhere if you need to translate it to a programming language.
I need the comp oder to translate the model into R code. In the meantime, I tried to do it manullay :roll: However I am not quite sure how to handle:

(20) #expected Demand>smooth# -

Thanks for the effort anyway :)

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 4:02 pm
by tomfid
SMOOTH(X,tau) = INTEG( (X-SMOOTHX)/tau, X )

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 4:03 pm
by tomfid
Does R's ODE solver need equations in order of computation? That seems rather stone age.

Re: Exporting Equations in Computational Order PLE

Posted: Fri Nov 03, 2017 4:33 pm
by mar898989
tomfid wrote:Does R's ODE solver need equations in order of computation? That seems rather stone age.
Thank you, Tom.

If it doesn't require them to be in comp order, all the better! For some reason, I was thinking so. :roll: :D