Hello, I want to extend Symbolics.jl Variables to encode bounds and default value of parameters in the “variable”; Currently something like this:
using Symbolics: _parse_vars, Num, @variables
import SciMLBase: issymbollike
import Base: +, -, *, /
struct Parameter
var::Num
lower::Real
upper::Real
default::Real
end
# Extended Functions:
Base.:+(p::Parameter, x::Any) = Base.:+(p.var, x)
Base.:-(p::Parameter, x::Any) = Base.:-(p.var, x)
Base.:/(p::Parameter, x::Any) = Base.:/(p.var, x)
Base.:*(p::Parameter, x::Any) = Base.:*(p.var, x)
issymbollike(::Parameter) = true
macro parameter(x, lower, upper, default)
var = (@variables $x)[1]
esc(Parameter(var, lower, upper, default))
end
function bounds(p::Parameter)
return (p.lower, p.upper)
end
I want all functions (except a few pre-determined ones like bounds
) to act directly on p.var
without having to extend everything by hand like the Base.:
block.