One template model to apply more

Use this forum to post Vensim related questions.
Post Reply
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

One template model to apply more

Post by yusuke »

I make a template model of one city. I want to apply this model more.
But I should change some constant and lookup table in every city.

Using a excel data by city is one way to do. The thread gives me good information.
"Edit equations using scripts"
http://www.ventanasystems.co.uk/forum/v ... f=2&t=3847

This way makes model and excel_file with link in every city.
In simulation, I want to change all constant from vensim.
So, I want to change constant value and save it default.

consvalue = 20
→ consvalue =30

My imagination procedure
++ my side (development)
1) make a template model
2) make a xls file in every city(to change constant and lookup)
3) make a model by city (embed xls data )
++ user side(distribution)
4) distribute a embed model(only mdl, not xls)

I want to know whether it is possible.

Best regard
Yusuke Tarumoto
tomfid
Administrator
Posts: 4000
Joined: Wed May 24, 2006 4:54 am

Re: One template model to apply more

Post by tomfid »

If I follow your requirements, you'd like to distribute the model without a linked Excel file, by instead embedding the constant/lookup changes in the model.

Are you avoiding the Excel linkage to keep things simple (one file), or to avoid the user expense of acquiring Excel, or some other reason?

If it is just Excel you are avoiding, there are several options. You could put the parameter changes in .cin files, or in .tab files accessed through GET DIRECT in place of GET XLS.

Another option (more complex) would be to write a script that would parse your template model and make changes to the .mdl text, saving a new modified .mdl for each city.

If your users don't have Vensim, and your model uses complex features like subscripts, you may need to distribute .vpm format so that they can use the free reader.

If a single-city model is not too big, another option would be to use subscripts to include the data for all cities in a single model, with a switch to determine which is active.
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Re: One template model to apply more

Post by yusuke »

Thank you answer and give me a hint.

Quest)
Are you avoiding the Excel linkage to keep things simple (one file),
or to avoid the user expense of acquiring Excel, or some other reason?
Answer)
In simulation or symthesim, constants witch have link with excel can't
change the value from vensim. Only to change by excel data.
I want to change the value which has link with excel, too.
So, I think to embed new constant value direct store in vensim.
This problem will come using cin or tab file, too.

I plan to make vpm file by city, and make package model vpa to distribute.
User use vensim model reader to open vpa application.

Your comment)
Another option (more complex) would be to write a script that would parse
your template model and make changes to the .mdl text, saving a new modified .mdl for each city.

I want to know the way to modify mdl.
I am using VensimDSS.
If the code is too complicate, please tell me some hint to do
(sample command script) .

Best regard
Yusuke Tarumoto
Administrator
Super Administrator
Posts: 4847
Joined: Wed Mar 05, 2003 3:10 am

Re: One template model to apply more

Post by Administrator »

Your comment)
Another option (more complex) would be to write a script that would parse
your template model and make changes to the .mdl text, saving a new modified .mdl for each city.

I want to know the way to modify mdl.
I am using VensimDSS.
If the code is too complicate, please tell me some hint to do
(sample command script) .
If you are intending to package a VPA, this will not work 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
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Re: One template model to apply more

Post by yusuke »

Thank you comment .
I understand the difficulty of copy and modify template model.

Thank you very much
tomfid
Administrator
Posts: 4000
Joined: Wed May 24, 2006 4:54 am

Re: One template model to apply more

Post by tomfid »

Constants that are imported from GET XLS CONSTANTS should work in synthesim, at least in recent versions of Vensim. (For example, running the GET XLS CONSTANTS sample model linked in the Functions section of the Reference Manual, all of the constants are editable). The same should be true for .cin files and .tab with GET DIRECT.
tomfid
Administrator
Posts: 4000
Joined: Wed May 24, 2006 4:54 am

Re: One template model to apply more

Post by tomfid »

The scripted editing of the mdl approach would not work for interactive changes, but if the models can be generated in advance, you could manually package the results. However, this method is cumbersome, so I would not recommend it if there is another viable option.

The basic idea is to write some kind of script that generates text equations in the format

myconst = 53 ~ unit ~ comment |

which is just the .mdl format for equations, which you can see in the text editor.

Excel is actually pretty good at this - put the variable names, values, units etc. in their own columns, have an equation that concatenates them with the needed separators, then copy & paste the result into a block in the model.
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Re: One template model to apply more

Post by yusuke »

Thank you Tom .

I use GET DIRECT CONSTSANTS with cin file.
1)make a vmf
2)package of vmf to vpa, but no need include cin file in Additional files.
3)The vpa work well.
In compile, function "GET DIRECT CONSTANTS" will change to actual value in cin, I think.
Is it true ?
For distribution, it is enough , thank you.

I have a one question.
For constant value, it is ok.
But I want to know how to do in lookup table using
GET DIRECT LOOKUPS .

I write in mdl
mylookuptable=GET DIRECT LOOKUPS( 'test.cin' , '=' , '1' , 'b3' ))

test.cin
const1 = 200
const2 = 3
mylookuptable = ((0,10),(30,11),(100,13),(200,13),(365,10))

This is no work .

I hope your support.
Best regard
tomfid
Administrator
Posts: 4000
Joined: Wed May 24, 2006 4:54 am

Re: One template model to apply more

Post by tomfid »

You're mixing two approaches here.

The .cin file format can be loaded at runtime (Model>Simulate... and name the .cin file on the Changes tab using Load Changes From...). In a venapp, you would use SIMULATE>READCIN and ADDCIN.

GET DIRECT calls will execute without specifying a .cin file. Normally the input for GET DIRECT would be a .tab or .csv file, though it can understand the .cin format for constants. However, it can't read the .cin format for lookups. Instead, it needs an array of time-value pairs with just one number per cell. See the GET DIRECT LOOKUPS sample model in the Help system.

Tom
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Re: One template model to apply more

Post by yusuke »

Thank you , good comment.

I make a base model and cin file by city.

Now, I want to know whether selected cin can be used continuously.

DSS can select cin and run using selected cin.
Sample model WRLD3-03.VCD, there are good sample.
"Choose a scenario on which to base your run"

But once it was SIMULATE, the changed value will go back to default.

I want to make a vcd code, once a cin(city name ) was selected at start time,
it will continue to use in READCIN with no more selection.

(1)
Select city (it mean "select cin" file)
(2)
Menu>RUN SIMULATE>READCIND|"select cin", show
(3)
continue to examin more sinario with "select cin"=selected city setting.

Is it possible only DSS ?

Best regard
tomfid
Administrator
Posts: 4000
Joined: Wed May 24, 2006 4:54 am

Re: One template model to apply more

Post by tomfid »

READCIN commands should be sticky, so that the setting applies to subsequent runs. However, issuing another READCIN, or a READRUNCHG or LOADMODEL, will overwrite the READCIN setting.
Post Reply