Disassociate parameter or variable from a model in JuMP

Take a read of the first post in Please read: make it easier to help you. It has some advice on how to write a good post on construct a minimal working example.

There is nothing equivalent for NLparameter right?

No. Certain base functions on JuMP constraints not implemented for NLconstraints. · Issue #2355 · jump-dev/JuMP.jl · GitHub

because these variables appear in equations such as the objective

You can delete variables that appear in objectives and constraints.

I am still confused as the number of variables is decreasing, but the Names registered in the model is not.

Looks like you found a bug :smile:. I don’t know how we missed this one for so long… I’ll open an issue.

julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(model, x)
x

julia> model
A JuMP Model
Feasibility problem with:
Variable: 1
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
Names registered in the model: x

julia> delete(model, x)

julia> model[:x]
noname

julia> model
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
Names registered in the model: x
1 Like