Weird error with input variables not altering the simulation #440
-
|
Hello I am building a proof of concept to check how well SDEverywhere plays with the model we have, and I am stuck with an issue. Let's see if I can explain it: We have a world model where we can control policies and visualize indicators in different regions. To "enable" a region to be controlled we have a Vensim variable called:
If we set it to 2 for US, it means that the policy variables we change for US will affect the simulation. The problem is that when the simulation runs in SDEveryhwere, the policies for the regions that depend on enabling the "Switch for policies 1 is automatic 2 is userset[us]" are not affecting the simulation. Test scenario A):
Result:
Test scenario B):We export a new model in Vensim. The same as the scenario A) However in this case Switch for policies 1 is automatic 2 is userset[us] is configured to be "2" by default, in Vensim. In this case, I remove the "Switch for policies 1 is automatic 2 is userset[us]" slider With this change, now ISPV slider user[us] slider has an impact on the simulation. So there might be a problem setting up the "SWTICH ... []"variable = 2. But I am sure that the variable value is 2 because it is also represented in the charts. It is a strange behavior, that I don't know how to solve. I was wondering if you might have any clue about this error. @chrispcampbell Note. There is no error in the terminal console. I have attached the charts.csv and inputs.csv |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
Hi @serman, thanks for providing lots of good details about this problem. The issue as I see it (after inspecting the mdl that you guys sent offline) is that Currently it's only possible to configure an input variable if the underlying model variable is a constant (when the right hand side of the equation is a simple number or a constant list). It's not possible to configure an input that overrides a non-constant equation. Unfortunately the compiler doesn't currently produce an error message if you try to configure a non-constant; if we had had that, it would've helped catch this problem earlier. I filed an issue (#441) so that we can improve the compiler to report an error message in this case. Let me know if the above makes sense. I'm not sure I understand yet the goal with the way If you set it up this way (and have a slider or switch defined in |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
To avoid confusion, let's keep the discussion here. I'll ask Ulrich in case I don't understand something about the model or vensim. "SWITCH for policies 1 is automatic 2 is userset[region]" is a constant here but the problem is the same I described: Variables that depend on this switch being ===2 don't affect the simulation. Sorry for the misunderstanding with the "debug version" of the model that we shared with you. That one was only in use to help us to identify the error. Rgds |
Beta Was this translation helpful? Give feedback.




Hi @serman, my apologies, when I tried the example yesterday (after converting it back to use a constant), I didn't notice that the issue you described is still present. I am able to reproduce the problem with the latest files linked above.
The issue turns out to be a bug in some older code that does constant analysis in conditional statements (
IF THEN ELSE) to eliminate unused code branches. That code did not correctly handle the case where an input variable uses subscripts, and that bug caused someIF THEN ELSEstatements to be eliminated incorrectly, which meant that theSwitch for policiesvalue had no effect at runtime.The code in question is scheduled to be removed in the near futu…