Saving constants to a file

Use this forum to post Vensim related questions.
Post Reply
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

Saving constants to a file

Post by rdudley »

I can use a CIN file to save _changes_ to a model. But sometimes I would like to save all model constants and lookups.

Especially if I'm making a lot of changes to a model, and then would like to re-create an earlier model run as a basis for additional changes.

Is there a way to save all model constants and lookups so that these can be retrieved later?

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

Post by Administrator »

Click on Model->Settings->Info/Pswd then Model->Cin.

That will give you a complete list of default model constants and lookups.

Does that do what you need?

Tony.
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

not sure - will check

Post by rdudley »

Hmm. What does that process save?

Does it save the default constants as written in the model, OR will it save the current constants that are in the currently loaded dataset (including changes made with sliders etc)?

What I would like to do is have a way to automatically save all constants that are currently in use (i.e. if I have moved some sliders temporarily changing constants). All constants that are in the currently loaded dataset.

But I don't _only_ want to save what has been changed, but all constants including changes.

Richard
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

No

Post by rdudley »

No. That process appears to save the model constants as currently written in the model proper.... NOT including any changes made with sliders. Just the "changes made" can be saved with the "changes" menu or buttons.

What I would like to do is save all constants including those that had been changed with sliders. Especially if this could be done by saving them from the currently loaded dataset (e.g. not only when synthesim is active).

I can do this by making a save list for the constants and exporting to excel then to use them again I would have to import again.

I am looking for a way to easily reconstruct earlier model runs for further experimentation and modification.

Richard
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

Post by rdudley »

Ok Here is what I did to save all constants for a model run... for later use.

_____________________________-

Technique for saving all constants of the dataset into a CIN file.

(This allows you to recreate an older model run within Synthesim even if you have subsequently changed constants in your model)
Maybe there is an easier way?

Note: CIN files are not available in Vensim PLE and PLE plus.


Open: model- export- dataset

Then select the dataset you want to export

Enter the name of the "export to" file (like: constants run1)

Select Excel file

Pick the save list (previously created or enter a name and create a new one).
Note this should include all the model constants.

Under "time from" and "time to" enter the beginning time of the model.

Click don't show time.

Click okay


Open the Excel file

Enter a column between the model constant names and the values. Highlight the three columns and format them as text.

In the middle column enter a row of = signs. (Note you will have to use '= in the first cell and then copy into the rest of the column.

Highlight and copy all the cells in the three columns.

Open a text editor and paste the data into it.

Replace tabs with spaces. (I don't think you can do this with Notepad... I used TED Notepad). I guess you can use the Vensim text editor (File - Edit-).

Save the text file with the extension CIN.

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

Post by Administrator »

Once you are running SyntheSim, there is a button "Save constant/lookup setting to file". Does this do what you need?

Also using the "Simulation Control" dialog, there are two buttons under the "Changes" tab to save just changes, or all model constants.

Hopefully one of those methods will do what you need.

Tony.
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

Post by rdudley »

Tony:

1) Using the "save constant / lookup setting" while in sinthesim saves only constants and lookups that have been _changed_ while using sinthesim.

2) The save all model constants is only available when you are not running the model, and thus saves only the constants and look ups as currently written in the model.

3) What I want to do is like number 1 but I want to save not only _changes_ but all model constants.... AND I want to be able to retrieve them from previous runs of the model. That is I want to be able to recall all model constant and lookup settings from a previously created data set (vdf file).

Maybe I need this this is because I don't keep close track of what I have been doing! Some testing via sliders is incorporated into the model then I make a few more runs... change something else etc. Then I go back, looking at earlier runs, and decide that I want to use that earlier run as my basis. Even if there are only 10 constants it would be easier to have them in a file that can be loaded under sinthesim. Especially if I have several basic runs that I need to work on further.

Does that make sense?

Ultimately it would be nice, once the constants are set, to be able to say "OK now write this constants into the model so they become the defaults" :)

Richard
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Hi Richard,

If you first save all model constants, then save the changes you can catenate those into a single .cin file that will work - with later values overriding earlier ones.

Also every vdf does store all of its constants and, in addition to these can be compared with the current model using runs compare.
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

Post by rdudley »

Hmmm. I will have to think about that. I end up fiddling with the model and make some changes within sinthesim and some in the model itself.. Then at some point I want to recreate an earlier run and use that as the basis for further development. IF I have been careful about my progress... no problem... BUT Quite often I need to get the constants out of a particular run to be sure I have what I want.

-- Richard
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

saving constants

Post by LAUJJL »

Hi Richard.

It has taken me some time until I understood how to proceed to save constants and
Lookups from simulation, synthesim runs or optimize runs.

I join a model called constants.example.mdl

The process is the same if you want to save constants and lookups from a simulation,
a synthesim or an optimization.

You must first generate an ordinary run where you have modified the constants with
the sliders or with the modify constants and save it generating a .vdf file.
For the synthesim you must click on the button ‘save this run to ‘ and name a file.

Once you have generated the runs with all the data in it, you must first create a
.cin file that will hold the constants and the lookups that you have modified.

To do that you must click on the button ‘simulation control’ near the set button.
In run name you must write the name of the run and in ‘base on’ you must name the
Vdf file, example ‘first run’ and ‘first run.vdf’.
You must click on ‘changes’ and give a name to your file. For example: ‘first run.cin’
With the extension cin. If you want to save only the parameters or lookups that you have
Changed, or all if you want to change all the parameters and the lookups.

You can then verify with a word processor for instance the edit at the dos prompt
That in your .cin file you have the constants and the lookups that you have wanted
To save.

Now if you want to include in a new run the constants that you have changed, you must
Name a new run, click on the simulation control. The run name will be automatically
Named and you must name the .cin file in the load changes from :
Example ‘first run.cin’
You can even still change the constants or the lookups if you click on the constants or
Lookups near the change button.
Then you click on the simulate, synthesim, sensitivity or optimize button, depending on
The kind of run.
Experiment on the model joined. $
It is not straightforward and needs some experimenting with errors at the beginning.
Regards.
JJ
Attachments
constants_example.mdl
(2.71 KiB) Downloaded 567 times
rdudley
Senior Member
Posts: 71
Joined: Mon Sep 08, 2003 2:16 am

Post by rdudley »

Great! Thanks a lot for pointing that out.

Just to clarify, to save all constants from a previously created run:

open the simulation control, go to the changes tab, enter the name of the desired run in the "run name" box, enter the same name with the vdf extension in the in the "based on" box then click save as cin "all" button. Provide a file name and save.

It works. A lot easier than what I was doing.
Post Reply