-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Control parameter accessors need to generate code #301
Comments
@ToddFincannonEI: Well, that's interesting, but I'm glad that EPS helped us to get a counterexample so soon :)
I started down that road when I first added the accessors, but decided against it because it would mean running some portion of the model init and running the model for one time step to properly initialize Looking at it again, maybe that approach wouldn't be so awful, and it would allow us to get rid of the special code gen and instead define the accessors in |
@ToddFincannonEI: I took a crack at it, preliminary changes are on a branch: The downside is that it doesn't handle the case where one or more control params are overridden by The other approach I considered is changing the way the
That might work, but I'll need to look at some of the call sites and in En-ROADS to see if it can pan out. |
This fix works for EPS. It would be fine with me to use this and await an actual need for control params set in inputs. |
@ToddFincannonEI: Thanks for confirming that it works for EPS. I agree we can go with this simple solution for now. I'll submit a PR shortly. I also opened up a new issue #302 to have a place to link possible improvements to this interface to other API improvements I'd like to make before 1.0 (so we'll do the quick thing now, and can consider how to make it better later). |
I was wrong when I said that the new control parameter accessor values would always be constants, like they are in most models. EPS is highly data-driven to adapt to different model regions. The initial and final times are read from CSV files. Simply copying the formula text doesn't work. We need to generate code for the RHS after all.
The attached zip file illustrates the problem with a model adapted from EPS. Here's how the initial and final times are specified.
control.zip
This results in the following invalid C code for the new control parameter accessors.
Is it possible to define the accessors like this? Or are they not initialized yet when the runtime needs them?
The text was updated successfully, but these errors were encountered: