I’m doing sort of implementation of a column generation model and after finding a new pattern I want to add a new variable from a existing set of existing variables. Example:
This is my main problem
main = Model(Gurobi.Optimizer) @variable(main, 0 <= x[i in 1:length(I)] <= 1) @variable(main, 0 <= y[i in 1:length(J)] <= 1) @variable(main, 0 <= z[Edges] <= 1)
…
Found a new pattern and I want to add the number of variables so
And I want to be refereced as a new “x” variable, not “_”. Additionally, I want to add the variable x[121], not with indices 286. I think this happens because I have y variables.
How can I create this type of variable to add in my set of existing variables named x?
julia> using JuMP
julia> model = Model();
julia> @variable(model, x[1:2])
2-element Vector{VariableRef}:
x[1]
x[2]
julia> for i in (length(x)+1):4
push!(x, @variable(model, base_name = "x[$i]"))
end
julia> x
4-element Vector{VariableRef}:
x[1]
x[2]
x[3]
x[4]