I have a sys::System, and I’d like to build a sys2 that is like sys, but sys2.some_param’s default is 20. Right now I use
"""
``jldoctest
julia> @named sys = MySystem();
julia> param = sys.some_param;
julia> initial_conditions(assign_parameters(sys, [param=>14]))[vol]
14
``
"""
assign_parameters(sys::System, new_params::AbstractDict) =
MTK.@set sys.initial_conditions = merge(initial_conditions(sys), new_params)
to achieve that, but this is ugly code that uses MTK internals. It also does not work if the Dict contains some_param[2] => new_value; I have to pass some_param => new_array.
I’m aware that “Don’t do this; pass the new parameters as the ps parameter” might be the official answer, but it’s not very satisfying. Given that sys has parameters, it feels natural that we could change them. remake does not seem defined for it.
For context, I want to have sys2 = fit_parameters(sys, my_data). I could of course have it return the new parameters, but I’d prefer to return the new system.