Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Use this forum to post Vensim related questions.
Post Reply
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Hello Ventana Systems folks,

I've been able to track down a bug that has been troubling us for some time and isolate a procedure that reproduces the bug reliably. The bug is specific to Vensim Model Reader and doesn't affect Vensim DSS.

When saving a .cin file (changes only), Model Reader (including the latest version, 7.3.5) will write the values for many input data variables into the .cin file, not just the values that were changed. This creates a bloated .cin file, and it means that when that .cin file is loaded, any changes to the underlying input data files won't be reflected because they'll be over-written with the copies that were (earlier) saved into the .cin file.

Following the exact same procedure in Vensim DSS creates a normal .cin file that only includes the changed variables, not data from bunches of other input variables that did not change.

This does not happen in all Vensim models. It happens in our India Energy Policy Simulator and some others.

Procedure to reproduce this bug:

1. Download the India Energy Policy Simulator from https://us.energypolicy.solutions/eps-a ... -india.zip

2. Unzip the folder

3. Open the EPS.vpm file in Vensim Model Reader (to see the bug) or in Vensim DSS (to see the intended, non-buggy behavior).

4. Navigate to the "Policy Control Center" sheet.

5. Enter SyntheSim mode.

6. Change one policy setting. It doesn't matter which one. For example, slide the "Carbon Tax" slider to a non-zero value.

7. Click the "Save Changes" button and save your scenario as a .cin file.

When you follow this procedure in Model Reader, you get a .cin file that contains 1502 lines, including data from numerous input variables.

When you follow this procedure in Vensim DSS, you get a .cin file that contains 1 line, including just the policy setting for the Carbon Tax.

I've attached to this forum post .cin files for the exact same policy setting from this model, one saved from DSS and one saved from Model Reader. This way, you can examine the output I'm getting.

We ask many people we work with to download and use Model Reader, and this bug causes all their .cin files to be filled with junk data, which prevents them from finding their policy settings inside the .cin file, and prevents them from picking up on input data updates when they use .cin files they created with prior versions of the input dataset. It's a pretty vexing bug, and we'd be so appreciative if Ventana Systems could fix this issue in Model Reader, so it behaves like Vensim DSS and doesn't save a bunch of unchanged variables into the .cin files it creates.

Jeff
Attachments
Scenario_SavedFromModelReader.cin
.cin file created by Model Reader
(102.16 KiB) Downloaded 215 times
Scenario_SavedFromDSS.cin
.cin file created by DSS
(41 Bytes) Downloaded 206 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by tomfid »

Strange. We'll check it out. Thanks for the thorough report!
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

I'm getting the exact same behaviour in both DSS and the model reader (using the VPM rather than MDL in DSS and VPM in Reader).

I think this is a case of misunderstanding how CIN files work. When you start the model, constants are read in using lots of calls to GET DIRECT CONSTANTS. When the Save button is pressed, Vensim saves the values of these to the CIN file (as they are different from the default values).

I'll see if there is something I can do to ignore anything read in from Excel.
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
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by tomfid »

When you write a cin file from synthesim, you get everything as well. Maybe we need a new "update" concept for .cin files, that overwrites an existing template (existing cin or maybe lst) with new values only for the variables found.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

I'm working on it.
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
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by tomfid »

I recall discussing this with Bob ages ago. It may be that there are already two modes (write everything, write only interactive changes) but the trigger for the latter is somehow getting missed in some cases.
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Writing all of the values that were read using "GET DIRECT X" calls into .cin files is definitely not how Vensim historically has handled the writing of .cin files, in any version of Vensim, at least back to when I started using Vensim in 2013. It's also not how the current versions of Vensim work when running most models. Since I started using Vensim, the only values written into .cin files have been those that were changed by the user, most typically, when moving sliders in SyntheSim mode. This is a genuine bug, not normal behavior.

This bug is particular to some Energy Policy Simulator models, such as the India EPS model (whose download link was provided above). It appears that something about this model causes Vensim to incorrectly flag many variables as having been changed by the user, when they were not changed.

One clue that may help you trace the source of the bug is that the buggy behavior started after I added a feature that allows for the selection of different policy implementation schedules. Take a look at the following four variables in the model, which might be linked to the bug:

FoPITY Fraction of Policy Implemented This Year
Selected Policy Implementation Schedule
Policy Implementation Schedule Selector
Policy Schedule Sequence Numbers

All of these appear on the sheet named "Policy Implementation Schedule" in the upper left corner. These variables are an implementation of a method to allow the user to select from one of nine input data files for a single variable while running the model. All of the nine schedule files are read into the model (in the variable starting with "FoPITY..."), but eight of the schedules are multiplied by zero, and the user-selected schedule is multiplied by 1 (in the variable "Selected Policy Implementation Schedule"). Then the schedules are summed together, resulting in values equal to the user-selected schedule. This technique works around Vensim's inability to switch which input data file is being read into the model dynamically based on a slider setting. It's actually a rather straightforward technique and I'm surprised it may be giving Vensim trouble, but it is possible (not certain) that the bug is triggered by something being done here.

Vensim structure for policy schedule selection
Vensim structure for policy schedule selection
PolicyScheduleSelectionStructure.PNG (10.62 KiB) Viewed 7832 times

Note that the bug does not happen when all of the nine policy schedules are the same. It only happens when at least one of the nine schedules differs from the other eight schedules. This, I think, is why the bug happens in the India Energy Policy Simulator but not in the U.S. Energy Policy Simulator.
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Important:

Also, I can confirm Tony's finding that the bug affects Vensim DSS when opening the VPM file, but not the MDL file. So it doesn't seem to be a problem with Model Reader specifically, but rather, a problem affecting compiled (.vpm) versions of the model, but not affecting uncompiled (.mdl) versions.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

It has been there for a long time, but only appears in published models.

We've got a fix and are testing at the moment.
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
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Awesome! I am really happy you managed to track it down and are already testing a fix!
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

I've uploaded a new installer for the Vensim model reader which has this fix. Let us know of any issues.
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
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Hi folks,

The Model Reader 7.3.6 update improves the problem but does not fix it completely. Data read in from "GET DIRECT CONSTANTS" no longer appears in the .cin file, which is good. However, variables that are read into the model using "GET DIRECT LOOKUPS" are still included in the .cin package when they should not be (only when running the VPM version, not the MDL version, of the model).

I've attached versions of the .cin file for the exact same policy setting, saved from three different versions of Vensim, to show the differences:
  • The .mdl file (run in Vensim DSS) results in a file with 1 line. This is the correct output.
  • The .vpm file (run in Reader 7.3.5) results in a file with 1502 lines, including input variables from GET DIRECT CONSTANTS and GET DIRECT LOOKUPS.
  • The .vpm file (run in Reader 7.3.6) results in a file with 722 lines, including input variables from GET DIRECT LOOKUPS.
Is it possible that in 7.3.6 you made a fix affecting GET DIRECT CONSTANTS and need to make the same fix for GET DIRECT LOOKUPS?

Jeff
Attachments
Reader-7.3.6-VPM-TestScenario.cin
(32.54 KiB) Downloaded 199 times
Reader-7.3.5-VPM-TestScenario.cin
(102.17 KiB) Downloaded 202 times
DSS-7.2-MDL-TestScenario.cin
(43 Bytes) Downloaded 203 times
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

It's been a little while, so I thought I would just check in and see if there has been any luck fixing the last part of this bug. We're so close to having this long-standing bug solved, at which point the .vpm files will behave like the .mdl files! I tried to be thorough in providing test results, along with a model and procedure that reliably reproduces the bug, but if there is anything else I can do to help you test or locate the remaining issue (which apparently pertains to variables populated by GET DIRECT LOOKUPS), please let me know! If Vensim can correctly flag changes in these variables (or the lack thereof) when it runs a .mdl file, there has got to be a way to make it behave the same way when running the exact same model from a .vpm file.

Thank you so much for looking into it, and for letting me know if there is anything else I can provide to help!
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

I've got a fix but it's more involved for lookups so just needs a little more testing.
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
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

Fantastic- that's great to hear!
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by Administrator »

I've uploaded a fix for the lookup tables as well, let me know of any issues ASAP.
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
jrissman
Senior Member
Posts: 95
Joined: Wed Oct 16, 2013 6:04 pm
Vensim version: DSS

Re: Bug Report: Model Reader (but not DSS) Writes Junk into .cin Files

Post by jrissman »

I just downloaded a fresh copy of Model Reader (still numbered 7.3.6) and tested it today. It looks like it's working perfectly, and the behavior saving .cin files from the .vpm executable now matches the behavior when saving .cin files from the .mdl executable. I tested saving a simple package, and no longer is any unchanged data read in by GET DIRECT CONSTANTS or GET DIRECT LOOKUPS included in the .cin file. I also tested the saving of a complicated policy package containing many policies, and it correctly flagged and saved all of the changes. As far as I can tell, it's working great and is ready to go! Thank you so much for this fix- it was causing a lot of trouble for our partners (who rely on Model Reader when using the Energy Policy Simulator), and it is just great that this is resolved.
Post Reply