Skip to content

Allow altering a symbolic parameter default value after creation. #2650

@Datseris

Description

@Datseris

As far as I can tell, this isn't possible right now:

@parameters p = 0.5
p.val.metadata[Symbolics.VariableDefaultValue] = 0.6
ERROR: MethodError: no method matching setindex!(::Base.ImmutableDict{DataType, Any}, ::Float64, ::Type{Symbolics.VariableDefaultValue})    

because the metadata are immutable:

julia> p.val.metadata
Base.ImmutableDict{DataType, Any} with 3 entries:
  MTKVariableTypeCtx   => PARAMETER
  VariableSource       => (:parameters, :p)
  VariableDefaultValue => 0.5

Context where this is useful:

I have a parameter at global scope. I have two functions, each representing two different physical processes A, B. They both utilize the same parameter, which itself is also utilized in other unrelated processes C. However, in my A, B the parameter should have a different starting value (while of course in all cases A, B, C the parameter covers the same physical range). I cannot use the same parameter everywhere and have its default value be context-specific. But I would like to!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions