Optimization: data import format

Use this forum to post Vensim related questions.
Post Reply
tc20852
Junior Member
Posts: 17
Joined: Tue Jan 12, 2021 4:22 am
Vensim version: PRO

Optimization: data import format

Post by tc20852 »

Hello Vensim folks,

just started looking at the optimization functionality in Vensim and seem to have fallen at the first hurdle.
I set up a very simple test model A->B with first order rate (first attachment), then made a synthetic data set in excel for B (B(t)= Ao(1 - e^(-kt))

The data was copied into a notepad window with the first line describing the data.

B reaction curve
1 9.516258196
2 18.12692469
3 25.91817793
4 32.9679954
5 39.34693403
6 45.11883639
7 50.34146962
8 55.06710359
9 59.34303403
10 63.21205588
.
.
.
etc

file saved as B_reactionCurve.dat (I would like to attach it here as well but this webpage uploader will not accept it).
I then loaded it into Vensim using either Model > from .dat format OR Model> Import dataset; either works.
the import appears to work as i do get a window saying "writing 24 values for B reaction curve" etc etc see attached "screenAfterDataImport.png"
although I dont see any errors, there is no data displayed in the graph or the table.

Pretty sure something basic is wrong, not mentioned in the manual. Perhaps there is a command/button/setting to load the data into memory? The electric.mdl example in the manual is a bit frustrating as there are parts that dont seem to correspond to this version of Vensim.

for example:

Click OK in the message box and close the Output window.
Ø Double click on percent of US dwellings with electric power.
Ø Click on the Graph tool. Two datasets, run1 and electric, display lines for percent of US dwellings with electric power.

double click on what?? button? image? menu item?
A much simpler example with a stepwise procedure would help a lot. Perhaps this particular problem might form the basis of an Optimization tutorial?
Thanks for any help, or direct me to an alternative example?
Thomas
Attachments
ScreenAfterDataImport.PNG
ScreenAfterDataImport.PNG (55.56 KiB) Viewed 1898 times
AtoB_firstOrderData.xlsx
(15.79 KiB) Downloaded 148 times
AtoB.mdl
(2.02 KiB) Downloaded 146 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization: data import format

Post by tomfid »

What you've done seems right. My first guess would be that you're using a version that had a bug - are you on the latest?

I'll attempt to replicate.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization: data import format

Post by tomfid »

Oh, wait ... if your data looks like this:
B reaction curve
1 9.516258196
2 18.12692469
3 25.91817793
4 32.9679954
5 39.34693403
... your data variable will be "B reaction curve" which won't plot when your workbench variable is A or B. If you want to plot against simulated B, use
B
1 9.516258196
2 18.12692469
3 25.91817793
4 32.9679954
5 39.34693403
tc20852
Junior Member
Posts: 17
Joined: Tue Jan 12, 2021 4:22 am
Vensim version: PRO

Re: Optimization: data import format

Post by tc20852 »

Great, thanks tomfid. This has got me back on track.
tc20852
Junior Member
Posts: 17
Joined: Tue Jan 12, 2021 4:22 am
Vensim version: PRO

Re: Optimization: data import format

Post by tc20852 »

Here are my notes in a doc file in case there is someone else out there has difficulty getting started with Optimization.
Attachments
VensimOptimizationForBeginners.docx
(399.17 KiB) Downloaded 158 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Optimization: data import format

Post by tomfid »

Nice notes!

The general insight here is that imported data (from .dat, .tab, .csv, etc.) requires variable names that match model names, at least if you want to be able to plot the model variable and the data variable on the same graph.

Your original import created a valid dataset (mydata.vdfx or whatever you called it), but since the .dat source was formatted as:

Code: Select all

B reaction curve
1 9.516258196
2 18.12692469
3 25.91817793
4 32.9679954
the vdfx contained "B reaction curve" rather than just "B".

There are a couple ways around this. One is to rename the variable to "B" in the .dat, which then makes the vdfx directly comparable with simulated behavior.

Another option would be to create an explicit "B reaction curve" data variable in the model. Then you could plot B vs B reaction curve on a custom graph. More importantly in some cases, you could use B reaction curve to drive some aspect of model behavior. You can't do that if your data is named "B" because a variable can't be both data and simulated.

A third route would be to skip the dat->vdf import, and instead use the GET XLS or GET DIRECT calls to bring the data in.
Post Reply