I am unable to delete the constraints which is created and stored in a dictionary using the JuMP.@constraint macro.

the constraints are added in the form

for i in array

d[i] = JuMP.@constraint(model, variable[i] == constant)

end

when i delete them using

for i in array

delete(model, d[i])

end

it doesnt seem to work. any Idea where i am going wrong or what can be done to fix it?

So from what i gather there is no way to delete itâ€¦ only modification is the option?

Or do i have to reformulate the whole problem each time before I solve it? I have an equality constraint on some variables which i want to remove , add a few different constraints and re run the optimization

Ah, I mis-read your question. This should work:

```
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> array = [1, 2, 3]
3-element Array{Int64,1}:
1
2
3
julia> constant = 1
1
julia> @variable(model, x[array])
1-dimensional DenseAxisArray{VariableRef,1,...} with index sets:
Dimension 1, [1, 2, 3]
And data, a 3-element Array{VariableRef,1}:
x[1]
x[2]
x[3]
julia> d = Dict()
Dict{Any,Any} with 0 entries
julia> for i in array
d[i] = @constraint(model, x[i] == constant)
end
julia> println(model)
Feasibility
Subject to
x[1] = 1.0
x[2] = 1.0
x[3] = 1.0
julia> for i in array
delete(model, d[i])
end
julia> println(model)
Feasibility
Subject to
```

Thats usefulâ€¦Can you solve the given model-

julia> println(model)

Feasibility

Subject to

x[1] = 1.0

x[2] = 1.0

x[3] = 1.0

write its solution and then delete the constraints? I for some reason am still unable to do so

Also i was using JuMP.@constraint is it different than using @constraint?

Please show a minimal version of the code you are trying to run the demonstrates the error.

The first post of PSA: make it easier to help you has some good tips to read first.

Ok.iwas actually thinking perhaps I should use a call back routineâ€¦ given I an solving the problem then using the solution to add delete constraints and solving again iterativelyâ€¦ will post code shortly