error messages related to lookups

Use this forum to post Vensim related questions.
Post Reply
mehdi_Asa
Junior Member
Posts: 6
Joined: Fri Mar 23, 2012 8:03 am

error messages related to lookups

Post by mehdi_Asa »

Dear all,

I used to develop system dynamic models in good old dynamo software which was fairly simple and stright forward. I have now re-written a SD model developed in Dynamo in Vensim which is an application of optimal contril theory to a macroeconomic model but have encountered with problems in simulating the model. In the model several lookups (table functions in dynamo terms, tables of trajectories for elements of Riccati and Tracking equation, CKij in the model) come together to make an auxiliary variable (Cdelta in the model). But while the same model would work in dynamo when simulating in Vensim an error message appears saying that the variable (CK21) is of a special type and cannot be used as a normal variable. The equation is ok in the equation editor window. I apreciate any helpful suggestion.

Mehdi
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: error messages related to lookups

Post by Administrator »

Can you post the equation or model so we can take a look?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
mehdi_Asa
Junior Member
Posts: 6
Joined: Fri Mar 23, 2012 8:03 am

Re: error messages related to lookups

Post by mehdi_Asa »

Dear Admin.

Thank you very much for your reply. Please find below equations of my model. I have got message of error saying that CKij in equation 004 are lookups and cannot b e used as normal variables. I am looking for a remedy.

Kind regards,

Mehdi

(001) BoP=
(Or+GD+X-M)/ita
Units: **undefined**

(002) Cap= INTEG (
I,
500)
Units: **undefined**

(003) cap0=
500
Units: **undefined**
planned path of capital stock

(004) CDelta=
1*(((r11*r22)+(r11+r22)*Ck11-(0.1*r11+r22)*Ck21-(0.1*r11+r22)*Ck12+(0.01*
r11+r22)*Ck22+0.81*(Ck11)*(Ck22)-0.81*(Ck12)*(
Ck21)))
Units: Dmnl
CDelta is the calculated delta from CKij

(005) Cg1(
[(0,-800)-(10,20000)],(0,1170.1),(2,10320),(4,14350),(6,9393.5),(8,3553),
(10,-750))
Units: **undefined**

(006) Cg2(
[(0,-6000)-(10,10)],(0,-4714),(2,-4723.9),(4,-4461.5),(6,-3828.7),(8,-2706.8
),(10,-1008))
Units: **undefined**

(007) Ck11(
[(0,0)-(10,400)],(0,320.3),(2,319.98),(4,319.52),(6,318.77),(8,316.47),(10
,300))
Units: **undefined**

(008) Ck12(
[(0,-0.2)-(10,10)],(0,2.8126),(2,2.3234),(4,1.6488),(6,0.76635),(8,-0.19925
),(10,0))
Units: **undefined**
tables of trajectories for the elements of the Riccati and
Tracking eq.

(009) Ck21(
[(0,-0.2)-(10,10)],(0,2.8126),(2,2.3234),(4,1.6488),(6,0.76635),(8,-0.19925
),(10,0))
Units: Dmnl

(010) Ck22(
[(0,0)-(10,10)],(0,7.9673),(2,7.2243),(4,6.1965),(6,4.8246),(8,3.0802),(10
,1))
Units: **undefined**

(011) Delta=
(r11*r22)+(r11+r22)*K11-(0.1*r11+r22)*K21-(0.1*r11+r22)*K12+(0.01*r11+r22
)*K22+0.81*(K11)*K22-0.81*(K12)*(K21)
Units: **undefined**
Delta is the (R+B'KB) Matrix Determinant

(012) Di=
Ni-Tax
Units: **undefined**

(013) E11=
(r11+r22)*K11*K11+(0.01*r11+r22)*K12*K21-(0.1*r11+r22)*K11*K12-(0.1*r11+r22
)*K11*K21+0.81*K11*K11*K22-0.81*K11*K12*K21
Units: **undefined**
Definition of matrices K rate components

(014) E12=
(r11+r22)*K11*K12-(0.1*r11+r22)*K11*K22-(0.1*r11+r22)*K12*K12+(0.01*r11+r22
)*K12*K22-0.81*K12*K12*K21+0.81*K11*K12*K22
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(015) E21=
(r11+r22)*K11*K21-(0.1*r11+r22)*K11*K22+(0.01*r11+r22)*K21*K22-(0.1*r11+r22
)*K21*K21-0.81*K12*K21*K21+0.81*K11*K21*K22
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(016) E22=
(r11+r22)*K12*K21+(0.01*r11+r22)*K22*K22-(0.1*r11+r22)*K12*K22-(0.1*r11+r22
)*K21*K22-0.81*K12*K21*K22+0.81*(K11)*K22*K22
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(017) eir=
0.1
Units: **undefined**

(018) exco=
0.02
Units: **undefined**

(019) F11=
K11-(E11/Delta)
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(020) F12=
K12-(E12/Delta)
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(021) F21=
K21-(E21/Delta)
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(022) F22=
K22-(E22/Delta)
Units: **undefined**
Definition of matrix K rates components Fij and Eij

(023) Far= INTEG (
BoP,
2.5)
Units: **undefined**

(024) FE=
Ir*(1-eir)*Far
Units: **undefined**

(025) FINAL TIME = 100
Units: Month
The final time for the simulation.

(026) G1= INTEG (
G1+(PRg1-Rg11),
-q11*Pfarn)
Units: **undefined**
the tracking equations (appendix A original paper)

(027) G2= INTEG (
G2+(PRg2-Rg2),
-q22*Pfarn)
Units: **undefined**
the tracking equations

(028) GD=
Tax-Gi
Units: **undefined**

(029) GDP=
Icor*Cap
Units: **undefined**

(030) Gi=
-UM11*(IA11*Far+IA12*Cap)-UM12*(IA21*Far+IA22*Cap)+(UM11/r11)*(Cg1-Cg2)+(
UM11/r22)*(Cg1-0.1*Cg2)+(UM12/r11)*(-Cg1+Cg2)+(-0.1*UM12/r22)*(Cg1-0.1*Cg2
)+(Cg1/r11)-(Cg2/r11)-UM11*(-PGi+PTax+Or)-UM12*(PGi-0.1*PTax)+PGi
Units: **undefined**
The optimal Government Expenditure

(031) GM11=
(IA11*F11)+(IA21*F21)
Units: **undefined**
definition of the Tracking equation components

(032) GM12=
(IA11*F12)+(IA21*F22)
Units: **undefined**
definition of the treacking equation

(033) GM21=
(IA12*F11)+(IA22*F21)
Units: **undefined**
definition of tracking equation components

(034) GM22=
(IA12*F12)+(IA22*F22)
Units: **undefined**
definition of the tracking equation components

(035) I=
(Gi+pi+Pei)/ita
Units: **undefined**

(036) IA11=
1-mpi*Ir
Units: **undefined**
elements of unit matrix plus A matrix

(037) IA12=
exco-mpi*Icor
Units: **undefined**
elements of unit matrix plus A matrix

(038) IA21=
mps*Ir*(1-eir)+eir
Units: **undefined**
elements of unit matrix plus A matrix

(039) IA22=
1+mps*Icor
Units: **undefined**
elements of unit matrix plus A matrix

(040) Icor=
0.3
Units: **undefined**

(041) INITIAL TIME = 0
Units: Month
The initial time for the simulation.

(042) Inv11=
(r22+Ck11-0.1*Ck21-0.1*Ck12+0.01*Ck22)/CDelta
Units: **undefined**
Elements of the invers matrix (R+B'KB) R=Matrxix of coefficient
to control variables in objective function B=Matrix of
coefficient to state variables in dynamic system K=Matrix of
Riccati equation component

(043) Inv12=
(Ck11-Ck21-0.1*Ck12+0.1*Ck22)/CDelta
Units: **undefined**
Elements of the invers matrix (R+B'KB) R=Matrxix of coefficient
to control variables in objective function B=Matrix of
coefficient to state variables in dynamic system K=Matrix of
Riccati equation component

(044) Inv21=
(Ck11-0.1*Ck21-Ck12+0.1*Ck22)/CDelta
Units: **undefined**
Elements of the invers matrix (R+B'KB) R=Matrxix of coefficient
to control variables in objective function B=Matrix of
coefficient to state variables in dynamic system K=Matrix of
Riccati equation component

(045) Inv22=
(r11+Ck11-Ck21-Ck12+Ck22)/CDelta
Units: **undefined**
Elements of the invers matrix (R+B'KB) R=Matrxix of coefficient
to control variables in objective function B=Matrix of
coefficient to state variables in dynamic system K=Matrix of
Riccati equation component

(046) Ir=
0.1
Units: **undefined**

(047) irat=
0.07
Units: **undefined**

(048) ita=
1
Units: **undefined**

(049) J= INTEG (
J+Jr,
1)
Units: **undefined**
The Objective function of the model J

(050) Jr=
0.5*(q22*(Cap-PCap)*(Cap-PCap)+q11*(Far-PFar)*(Far-PFar)+r11*(Gi-PGi)*(Gi
-PGi)+r22*(Tax-Ptaxp)*(Tax-q11))
Units: **undefined**
Rate of changes to the Objective function of the model

(051) K11= INTEG (
K11+(PRk11-RK11),
q11)
Units: **undefined**
Calculating components of matrix K=(Riccati equation) in Dynamo
mode

(052) K12= INTEG (
K12+(PRk12-RK12),
q12)
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(053) K21= INTEG (
K21+(PRK21-RK21),
q21)
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(054) K22= INTEG (
K22+(PRK22-RK22),
q22)
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(055) LJ=
log(J)
Units: **undefined**

(056) M=
mpi*Ni
Units: **undefined**

(057) mpi=
0.35
Units: **undefined**

(058) mps=
0.1
Units: **undefined**

(059) Ni=
GDP+FE
Units: **undefined**

(060) one=
1
Units: **undefined**

(061) Or=
20
Units: **undefined**

(062) Pc=
(1-mps)*Di
Units: **undefined**

(063) PCap=
cap0*EXP(one*(rat)*Time)
Units: **undefined**
planned path of capital stock

(064) Pcapn=
1008
Units: **undefined**

(065) Pei=
eir*Far
Units: **undefined**

(066) PFar=
2.5
Units: **undefined**
planned path of foreign exchange reserve policy 2
pfar=tabhl(tpfar,time,0,10,1)
Tpfar=2.5/-10/-20/-45/-55/-55/-45/-35/-25/-15/5

(067) Pfarn=
2.5
Units: **undefined**

(068) Pfarp=
2.5
Units: **undefined**
invers planned path of foreign exchange reserves

(069) PGi=
Pgi0*EXP(one*(-irat)*Time)
Units: Month
planned path of the government expenditure

(070) Pgi0=
15
Units: **undefined**

(071) Pgip=
Pgip0*EXP(one(-irat)*Time)
Units: **undefined**
invers path of pgi

(072) Pgip0=
29.5
Units: **undefined**

(073) pi=
Ps
Units: **undefined**

(074) Pnip=
Icor*PPcap
Units: **undefined**

(075) PPcap=
Pcapn*(EXP(one*(-rat)*Time))
Units: **undefined**
invers path of pcap

(076) PRg1=
-((-GM11+GM12)/r11)*(-G1+G2)-((GM11-0.1*GM12)/r22)*(G1-0.1*G2)+(IA11*G1+IA21
*G2)+GM11*(-Pgip+Ptaxp+Or)+GM12*(Pgip-0.1*Ptaxp
)-(q11*Pfarp+q12*PPcap)
Units: **undefined**
the tracking equations (appendix A in original paper)

(077) PRg2=
-((GM21+GM22)/r11)*(-G1+G2)-((GM21-0.1*GM22)/r22)*(G1-0.1*G2)+(IA12*G1+IA22
*G2)+GM21*(-Pgip+Ptaxp+Or)+GM22*(Pgip-0.1*Ptaxp)-(q21*Pfarp+q22*PPcap)
Units: **undefined**
the tracking equations

(078) PRk11=
q11+(IA11*F11+IA21*F21)*IA11+(IA11*F12+IA21*F22)*IA21
Units: **undefined**
Rate equations of the matrix K

(079) PRk12=
q12+(IA11*F11+IA21*F21)*IA12+(IA11*F12+IA21*F22)*IA22
Units: **undefined**
rate equations of the matrix K

(080) PRK21=
q21+(IA12*F11+IA22*F21)*IA11+(IA12*F12+IA22*F22)*IA21
Units: **undefined**
rate equations of the matrix K

(081) PRK22=
q22+(IA12*F11+IA22*F21)*IA12+(IA12*F12+IA22*F22)*IA22
Units: **undefined**
rate of equations of the matrix K

(082) Ps=
mps*Di
Units: **undefined**

(083) PTax=
taxrp*(Icor*PCap+Ir*PFar)
Units: **undefined**
Planed path of the tax revenue

(084) Ptaxp=
taxrp*(Icor*PPcap+Ir*Pfarp)
Units: **undefined**
inverse path of planeed tax revenue

(085) q11=
300
Units: **undefined**
The penalty attached to the deviation of targets in objective
function

(086) q12=
0
Units: **undefined**
The penalty attached to the deviation of targets in objective
function

(087) q21=
0
Units: **undefined**
The penalty attached to the deviation of targets in objective
function

(088) q22=
1
Units: **undefined**
The penalty attached to the deviation of targets in objective
function

(089) r11=
40
Units: **undefined**

(090) r22=
40
Units: **undefined**

(091) rat=
0.07
Units: **undefined**

(092) Rg11=
G1/taj
Units: **undefined**
the tracking equation

(093) Rg2=
G2/taj
Units: **undefined**
the tracking equations (appendix A original paper)

(094) RK11=
K11/taj
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(095) RK12=
K12/taj
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(096) RK21=
K21/taj
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(097) RK22=
K22/taj
Units: **undefined**
calculating components of matrix k=(Riccati equation) in dynamo
mode

(098) SAVEPER =
TIME STEP
Units: Month [0,?]
The frequency with which output is stored.

(099) taj=
1
Units: **undefined**
time adjustment

(100) Tax=
-UM21*(IA11*Far+IA12*Cap)-UM22*(IA21*Far+IA22*Cap)+UM21*((-1/r11)*(-Cg1+Cg2
)+(1/r22)*(Cg1-0.1*Cg2))+UM22*((1/r11)*(-Cg1
+Cg2)-0.1*(1/r22)*(Cg1-0.1*Cg2))-(1/r22)*Cg1+0.1*(1/r22)*Cg2-UM21*(-PGi+PTax
+Or)-UM22*(PGi-0.1*PTax)+PTax
Units: **undefined**
The optimal taxation

(101) taxrp=
0.1
Units: **undefined**
0.20

(102) TIME STEP = 1
Units: Month [0,?]
The time step for the simulation.

(103) UM11=
(-Inv11+Inv12)*Ck11+(Inv11-0.1*Inv12)*(Ck21)
Units: **undefined**

(104) UM12=
(-Inv11+Inv12)*(Ck12)+(Inv11-0.1*Inv12)*(Ck22)
Units: **undefined**

(105) UM21=
(-Inv21+Inv22)*(Ck11)+(Inv21-0.1*Inv22)*(Ck21)
Units: **undefined**

(106) UM22=
(-Inv21+Inv22)*(Ck12)+(Inv21-0.1*Inv22)*(Ck22)
Units: **undefined**

(107) X=
exco*Cap
Units: **undefined**
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: error messages related to lookups

Post by Administrator »

Can you just post the equation causing the problems?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
mehdi_Asa
Junior Member
Posts: 6
Joined: Fri Mar 23, 2012 8:03 am

Re: error messages related to lookups

Post by mehdi_Asa »

The equation that causes an error mesage is equation No. 004
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: error messages related to lookups

Post by tomfid »

You need to pass an argument to your lookups, as in y = lookup(x)

You might take a look at the "LOOKUP functions.mdl" example in the help system, Reference Manual, Chapter 4, particularly the 'price with normal LOOKUP usage' variable.
mehdi_Asa
Junior Member
Posts: 6
Joined: Fri Mar 23, 2012 8:03 am

Re: error messages related to lookups

Post by mehdi_Asa »

Thank you for your reply,

I read Ch. 4 and 6 of the reference manual but still could not fixed the error. As I am a beginner working with Vensim I wonder if you could be kind enough to show me how a parameter can be passed to a lookup. In dynamo language I used to set an input variable to my table function. But here when tried to link time, the input variable to the lookup variable, it did not work. Also I tried the graphic window but unlike "iThink" here it is not allowed to put input variable in x axis and output on Y axis. I must say that I am a little bit confused. I am an econometrician and regularly work with Eviews. Whenever there is a question you go to the manual and in all chapters of the manual there are examples to show how the problem should be handeld. I really think that more examples in the reference manual would help the users to over come difficulties, particularly in early stages of their work with Vensim.

Best regards,

Mehdi
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: error messages related to lookups

Post by tomfid »

Vensim differs from iThink in that a lookup can be used in more than one place, so the lookup table is separate from the input and expressions that use the input. In that respect it is more like DYNAMO.

In DYNAMO you might write:

FCAOR = TABHL( FCAORT, NRFR, 0, 1, .1 )
FCAORT = 1/.9/.7/.5 ...

(borrowing from Dynamics of Growth in a Finite World)

FCAOR is the output, FCAORT is the lookup, NRFR is the input, and 0, 1, .1 are the min, max and step for the input.

In Vensim, you don't need the min, max, step, or TABHL function - you use the lookup like a function. So, the above would look like:

FCAOR = FCAORT(NRFR) {variable type is auxiliary}
FCAORT = ... {variable type is lookup, which you can edit graphically via the "As Graph" button}

Take a look at the model linked to the LOOKUP functions help item in Ch. 4.
mehdi_Asa
Junior Member
Posts: 6
Joined: Fri Mar 23, 2012 8:03 am

Re: error messages related to lookups

Post by mehdi_Asa »

Dear Administratr,

Thank you for tour kind reply and information but it seems that I cannot explain my problem adequately. In my model I have an axiliary variable (Cdelta) consisting of several (4) lookups (called Ck11, Ck12, Ck21 and Ck22). The model is sent before and equations are 004 and the following equations in the model. When simulating the model an error message appear saying that Ckij are "special types and cannot be used as a normal variable". Please tell me what is meant by this and what should I do to remedy this problm.

When I change the sub type from normal to "with lookup" in the editing equation window for Cdelta the window for the equation is divided to wo and lowwer panel which is called "lookup" is empty. What should be put here in order to the simulation continue. I tried several ideas but did not work.

Regards,

Mehdi
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: error messages related to lookups

Post by Administrator »

You really need to take a look at the model as Tom suggested.

If you have a lookup composed of X/Y pairs, quote often X is time.

sample lookup ( (2000,1), (2001,2), (2002,3), (2003,4) )

Now to actually use it, I need to tell Vensim what I want to look up. I need to tell Vensim what value of "X" I want.

sample variable = sample lookup ( x )

Does this make sense?

So in your model you need something like

cdelta = 1*(((r11*r22)+(r11+r22)*Ck11(time)-(0.1*r11+r22)*Ck21(time)-(0.1*r11+r22)*Ck12(time)+(0.01*
r11+r22)*Ck22(time)+0.81*(Ck11(time))*(Ck22(time))-0.81*(Ck12(time))*(
Ck21(time))))
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: error messages related to lookups

Post by tomfid »

Specifically, see:

http://www.vensim.com/documentation/fn_lookup_area.htm

There's a chapter in the User's Guide on lookups:

http://www.vensim.com/documentation/usr08.htm

For iThink users, the WITH LOOKUP syntax may be more familiar:

http://www.vensim.com/documentation/fn_with_lookup.htm
Post Reply