optimization with subscripts

Use this forum to post Vensim related questions.
Post Reply
emiGS
Junior Member
Posts: 3
Joined: Mon Aug 23, 2010 6:29 pm

optimization with subscripts

Post by emiGS »

Hi,
I am trying to optimize an exponential decay with two simultaneous stocks for different data sets of decaying materials. So the same model but with different data. To make things easier I am using a single subscript applied to all parameters of the decay (stocks and rates) that encompasses all the data.
I tried to optimize to obtain the best rates and stocks for each data set but when Vensim does that it uses only one payoff for all the information (like the decays were all connected) and it basically takes an infinite time to optimize. If I run instead only one or a few datasets it takes only few minutes.
Is there any one who has some experience with this so I can make the subscripts independent and obtain one payoff per dataset?
I would really appreciate it!

Thanks!

[Edited on 8-23-2010 by emiGS]
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

The optimizer does indeed assume that the payoff is not separable, though this is usually not a problem if you have only a few (or even a few dozen) dimensions.

One way around this is to write a command script to automate the process of optimizing a few datasets at a time. You could also automate the process by using the Vensim .dll, called from a program (java, C, or VBS via Excel) to loop over the datasets.

A good trick is to build your model without subscripts (i.e. model a single decay process). Leave your data in a subscripted variable. Then use VECTOR ELM MAP or VECTOR SELECT to map your subscripted data to a single variable, using a constant to indicate which item you want. Then you can choose which dataset to fit by setting a constant, rather than changing your payoff and control files.

Tom
emiGS
Junior Member
Posts: 3
Joined: Mon Aug 23, 2010 6:29 pm

Post by emiGS »

Thanks Tom.

How can I put my data in a subscripted variable?

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

Post by tomfid »

I assumed that your data was already subscripted. For example:

dataset : (d1-d10)

quantity[d1] 0 1 .9 .7 .66 .7 .5 .3 ...
quantity[d2] 0 1 .8 .6 .3 .4 .2 .1 ...
...

Normally you'd either import this from a .tab delimited file, or use GET XLS DATA to import it. Either way, you'll have data equations with the [dataset] dimension.

Then you can pick out a single value with something like,

quantityUsed := VECTOR ELM MAP( quantity[d1], dataoffset )

Note that this uses the data equation operator := so that quantityUsed will also be a data variable, which is normally what you'd want for calibration. If you want to vary quantityUsed on the fly in synthesim, you'd want to make it a normal equation ( = operator ).

dataOffset would be a value between 0 and 9 (because VECTOR ELM MAP uses zero-based offsets).

Tom
emiGS
Junior Member
Posts: 3
Joined: Mon Aug 23, 2010 6:29 pm

Post by emiGS »

Thanks!
Does this mean that I can connect the quanityUsed (with VECTOR ELM MAP) to GET XLS DATA? and both of them have to have subscripts?
Also, does this mean that I need to change the payoff definition, i.e. according to your previous post I would have to write compare to: "quantityUsed"?
I did that but it does not find the name "quantityUsed" in the actual data file. Using only the GET XLS DATA I don't have that problem.

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

Post by tomfid »

My thinking was that you'd have

quantity[dataset] = GET XLS DATA(...)
quantityUsed := VECTOR ELM MAP( quantity[d1], dataoffset )

In other words, your data is subscripted, but the data actually used is not, for comparison to a model that is also not subscripted, with the dataoffset parameter determining which dataset gets fit.

There are probably several other ways to implement the same idea. How many datasets do you have?

Tom
Post Reply