Skip to content
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

Proposal for @constants #1802

Closed
lamorton opened this issue Sep 2, 2022 · 6 comments
Closed

Proposal for @constants #1802

lamorton opened this issue Sep 2, 2022 · 6 comments

Comments

@lamorton
Copy link
Contributor

lamorton commented Sep 2, 2022

What if we introduced a new category of @constants, alongside @parameters? My use case is including physical constants or unit conversion factors. These don't belong in parameter vectors, especially not the anonymous conversion factors generated by the unit conversion pass.

Basically, we'd add a new metadata tag MTKConstantCtx, analogous to MTKParameterCtx. The @constants macro would require a default value. build_function would just use the default value.

This method is less flexible than something like a tag on the parameter vector (b/c it requires rebuilding the system to change a parameter to a constant). However, I want these constants to not appear in the parameter vector at all. So we'd have two different ways to make some thing constant. I'm wondering if that's too confusing.

@YingboMa
Copy link
Member

YingboMa commented Sep 2, 2022

That's a good idea.

@crlaugh
Copy link

crlaugh commented Sep 2, 2022

Agreed. The same idea also exists in Modelica.

@lamorton
Copy link
Contributor Author

lamorton commented Sep 4, 2022

Working on a prototype.

@lamorton
Copy link
Contributor Author

lamorton commented Sep 6, 2022

I'm stuck on how to treat these during flattening/renamespacing. @YingboMa Do we want to assume these are global or should we allow to have different values for different subsystems? I'm leaning toward the former - if it's not global, it's not a real constant, it's just a fixed parameter.

@lamorton
Copy link
Contributor Author

Prototype is here. Still needs more work before it's ready for a PR, but I'd like feedback on my strategy first.

@lamorton
Copy link
Contributor Author

lamorton commented Nov 4, 2022

Done!

@lamorton lamorton closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants