order of calculation of subscripts

Use this forum to post Vensim related questions.
Post Reply
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

order of calculation of subscripts

Post by LAUJJL »

Hi

When you have a suscript like say period: (p1-p100) and vensim has to calculate for instance the variable var[period] it starts to calculate p1 then p2 etc…
Is there anyway to make Vensim calculate backwards p100 then p99 etc…

Regards.

JJ
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: order of calculation of subscripts

Post by Administrator »

You can force the calculation order.

some calc[P99] = a + B + 0 * some calc[P100]
some calc[P98] = a + B + 0 * some calc[P99]
some calc[P97] = a + B + 0 * some calc[P98]
some calc[P96] = a + B + 0 * some calc[P97]
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
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: order of calculation of subscripts

Post by LAUJJL »

Hi

This solution works if the subscript size is limited, although entering 100 individual equations is rather cumbersome, but if you have a subscript period: (p1-p1000) it is not tractable, especially if you want to modify the size of the subscript.

Regards.

JJ
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: order of calculation of subscripts

Post by Administrator »

If you can give me an example of what you have (and why you need to do this), I can probably figure something out for you.
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
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: order of calculation of subscripts

Post by LAUJJL »

Hi

The subscript represents time.

I need this to calculate optimal policies each time period, using dynamic programming methods starting most of the time in the past (infinite horizon or not) and going backwards to the present.
When one uses traditionnal mapping going from the past, if the number of periods is to big, after about 1000 periods, Vensim stops and warns about too many recursions. These recursions are generated by the way Vensim calculates the subscripted variables. If it was calculated going from the future there would be no recursion.

The solution I have found so far is to build a special variable that inverses the order of the subscripts: invers var[p0] = var[p100], invers var[p1] = var[p99] etc… et make the calculation from the invers var with forward going subscripts that does not generate any recursion. Once the calculation is done I invers the invers var back to the var.

my objective is to keep the readability of the model and use a subscript value equal to the time.

I could use an invers subscript right at the beginning something that works too but it makes the model difficult to read.

See joined a simplistic model summarising the method but with 10000 periods, long to analyse when one load it, but generating no recursion.

Best regards.
Attachments
essai.mdl
(2.69 KiB) Downloaded 189 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: order of calculation of subscripts

Post by tomfid »

I think inverting the order of the subscript is the only easy option.

It might be easier to do with VECTOR ELM MAP.
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: order of calculation of subscripts

Post by LAUJJL »

Hi

thank you for your answers.

Regards.

JJ
Post Reply