Is there a way to get the variable refs of the whole container?
julia> @variable(model, u[1:2])
2-element Vector{VariableRef}:
u[1]
u[2]
julia> variable_by_name(model, "u[2]")
u[2]
How do I get all u as Vector{VariableRef}?
Is there a way to get the variable refs of the whole container?
julia> @variable(model, u[1:2])
2-element Vector{VariableRef}:
u[1]
u[2]
julia> variable_by_name(model, "u[2]")
u[2]
How do I get all u as Vector{VariableRef}?
If you mean a method by a string, I assume that doesn’t exist. Just use u?
Why do you want this?
No just "u" does not work, it tried that first.
I didn’t mean "u", I meant u the reference.
And actually you can call u out directly via model[:u] or model[Symbol("u")].
Dropping this link to the documentation for posterity:
JuMP uses a single flat namespace for string names. In general, if you want to be able to access a structured view of your model components, you should maintain a data structure yourself. The model[:key] approach is a helpful utility, but it doesn’t work for every case (for example, anonymous variables and constraints).