Error with SCIP when reoptimize after adding a constraint

Hi,
I don’t understand why SCIP throws an error when I reoptimize a model after adding a constraint.
Error:

"""
using JuMP; using SCIP;
model = Model(SCIP.Optimizer);
@variable(model, x);@variable(model, y);@variable(model, z);
@NLconstraint(model, x*y*z <= 5);
@objective(model, Max, 0);
optimize!(model)
@NLconstraint(model, x*y*z >= 3);
optimize!(model)
"""
julia> using JuMP; using SCIP;

julia> model = Model(SCIP.Optimizer);

julia> @variable(model, x);@variable(model, y);@variable(model, z);

julia> @NLconstraint(model, x*y*z <= 5);

julia> @objective(model, Max, 0);

julia> println(model)
Max 0
Subject to
 x * y * z - 5.0 ≤ 0


julia> optimize!(model)
feasible solution found by trivial heuristic after 0.0 seconds, objective value 0.000000e+00
presolving:
presolving (1 rounds: 1 fast, 0 medium, 0 exhaustive):
 0 deleted vars, 0 deleted constraints, 0 added constraints, 0 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
 0 implications, 0 cliques
transformed 2/2 original solutions to the transformed problem space
Presolving Time: 0.00

SCIP Status        : problem is solved [optimal solution found]
Solving Time (sec) : 0.00
Solving Nodes      : 0
Primal Bound       : +0.00000000000000e+00 (2 solutions)
Dual Bound         : +0.00000000000000e+00
Gap                : 0.00 %

julia> @NLconstraint(model, x*y*z >= 3)
x * y * z - 3.0 ≥ 0

julia> println(model)
Max 0
Subject to
 x * y * z - 5.0 ≤ 0
 x * y * z - 3.0 ≥ 0

julia> optimize!(model)
[/nfs/OPTI/jenkins/workspace/SCIPOptSuite_linux_release/scipoptsuite-6.0.2/scip/src/scip/scip_cons.c:991] ERROR: invalid SCIP stage <10>
[/nfs/OPTI/jenkins/workspace/SCIPOptSuite_linux_release/scipoptsuite-6.0.2/scip/src/scip/cons_nonlinear.c:9424] ERROR: Error <-8> in function call
[/nfs/OPTI/jenkins/workspace/SCIPOptSuite_linux_release/scipoptsuite-6.0.2/scip/src/scip/cons_nonlinear.c:9473] ERROR: Error <-8> in function call
ERROR: AssertionError: $(Expr(:escape, :(SCIPcreateConsBasicNonlinear(mscip, cons__, "", 0, C_NULL, C_NULL, 1, tree__, C_NULL, lhs, rhs)))) == SCIP_OKAY
Stacktrace:
 [1] add_nonlinear_constraint(::SCIP.ManagedSCIP, ::Expr, ::Float64, ::Float64) at /home/remi/.julia/packages/SCIP/lx725/src/nonlinear.jl:190
 [2] set(::SCIP.Optimizer, ::MathOptInterface.NLPBlock, ::MathOptInterface.NLPBlockData) at /home/remi/.julia/packages/SCIP/lx725/src/MOI_wrapper/nonlinear_constraints.jl:17
 [3] set(::MathOptInterface.Bridges.LazyBridgeOptimizer{SCIP.Optimizer}, ::MathOptInterface.NLPBlock, ::MathOptInterface.NLPBlockData) at /home/remi/.julia/packages/MathOptInterface/bygN7/src/Bridges/bridge_optimizer.jl:593
 [4] set(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.NLPBlock, ::MathOptInterface.NLPBlockData) at /home/remi/.julia/packages/MathOptInterface/bygN7/src/Utilities/cachingoptimizer.jl:485
 [5] set(::Model, ::MathOptInterface.NLPBlock, ::MathOptInterface.NLPBlockData) at /home/remi/.julia/packages/JuMP/YXK4e/src/JuMP.jl:893
 [6] #optimize!#97(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Model, ::Nothing) at /home/remi/.julia/packages/JuMP/YXK4e/src/optimizer_interface.jl:108
 [7] optimize! at /home/remi/.julia/packages/JuMP/YXK4e/src/optimizer_interface.jl:107 [inlined] (repeats 2 times)
 [8] top-level scope at none:0

Same model but no error:

"""
using JuMP; using SCIP;
model = Model(SCIP.Optimizer);
@variable(model, x);@variable(model, y);@variable(model, z);
@NLconstraint(model, x*y*z <= 5);
@NLconstraint(model, x*y*z >= 3);
@objective(model, Max, 0);
optimize!(model)
"""
julia> using JuMP; using SCIP;

julia> model = Model(SCIP.Optimizer);

julia> @variable(model, x);@variable(model, y);@variable(model, z);

julia> @NLconstraint(model, x*y*z <= 5);

julia> @NLconstraint(model, x*y*z >= 3);

julia> @objective(model, Max, 0);

julia> println(model)
Max 0
Subject to
 x * y * z - 5.0 ≤ 0
 x * y * z - 3.0 ≥ 0


julia> optimize!(model)
presolving:
(round 1, fast)       0 del vars, 0 del conss, 2 add conss, 0 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 2, fast)       0 del vars, 0 del conss, 2 add conss, 0 chg bounds, 0 chg sides, 0 chg coeffs, 4 upgd conss, 0 impls, 0 clqs
presolving (3 rounds: 3 fast, 1 medium, 1 exhaustive):
 0 deleted vars, 0 deleted constraints, 2 added constraints, 0 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
 0 implications, 0 cliques
presolved problem has 5 variables (0 bin, 0 int, 0 impl, 5 cont) and 4 constraints
      4 constraints of type <quadratic>
transformed objective value is always integral (scale: 1)
Presolving Time: 0.00

 time | node  | left  |LP iter|LP it/n| mem |mdpt |frac |vars |cons |cols |rows |cuts |confs|strbr|  dualbound   | primalbound  |  gap   
  0.0s|     1 |     0 |     0 |     - | 574k|   0 |   0 |   5 |   4 |   5 |   0 |   0 |   0 |   0 | 0.000000e+00 |      --      |    Inf 

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

m 0.1s|     1 |     0 |     0 |     - | 623k|   0 |   - |   5 |   4 |   5 |   0 |   0 |   0 |   0 | 0.000000e+00 | 0.000000e+00 |   0.00%
  0.1s|     1 |     0 |     0 |     - | 623k|   0 |   - |   5 |   4 |   5 |   0 |   0 |   0 |   0 | 0.000000e+00 | 0.000000e+00 |   0.00%

SCIP Status        : problem is solved [optimal solution found]
Solving Time (sec) : 0.09
Solving Nodes      : 1
Primal Bound       : +0.00000000000000e+00 (1 solutions)
Dual Bound         : +0.00000000000000e+00
Gap                : 0.00 %

Thank you,
Rémi

You should probably open an issue in SCIP.jl for this.

1 Like

Ok, I though that I was doing something wrong.