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

Typed parameters #199

Open
david-pl opened this issue Mar 20, 2024 · 1 comment
Open

Typed parameters #199

david-pl opened this issue Mar 20, 2024 · 1 comment

Comments

@david-pl
Copy link
Member

The update to MTK v9 #197 required an overload of concrete_symtype to work:

MTK.concrete_symtype(::Symbolics.BasicSymbolic{T}) where T <: CNumber = ComplexF64

That isn't exactly great but should work for most use cases.

However, this now enables us to actually change the implementation of Parameter such that we can represent actual types. The whole parallel implementation for RealParameter could go and we can represent also e.g. 32-bit floats.

We'd just need to add another type parameter, something like

struct Parameter{T<:Number} <: CNumber
...
end

Then, changing the overload to something like

MTK.concrete_symtype(::Symbolics.BasicSymbolic{T}) where {S<:Number, T <: Parameter{S}} = S

could work.

This could be complemented by some syntactic sugar for the @cnumbers macro, basically just stealing the syntax from Symbolics, @cnumbers p::Float32...

@david-pl
Copy link
Member Author

In the latest MTK update, concrete_symtype got removed again. Instead of using that, we could now finally think about getting rid of CNumbers altogether and just using a BasicSymbolic with appropriate symtype and set the parameter metadata.

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

1 participant