Skip to content

SCIP errors when setting start values from previous solutions in iterative solves #347

@resmaeilbeigi

Description

@resmaeilbeigi

When solving a model iteratively (only changing the objective function and adding a constraint based on the previous objective value), SCIP sometimes fails when start values are set from the previous solution.

I have observed two distinct errors in this context:

  1. SCIP_INVALIDCALL in SCIPaddSolFree()
    The example below reproduces this issue. It occured after 12 iterations.

  2. SCIPsolve(o) yielded SCIP code SCIP_ERROR
    This happened in another test environment when setting start values before each iteration.
    The error followed a series of SCIP internal errors:

presolved problem has 2360 variables (1355 bin, 0 int, 505 impl, 500 cont) and 2069 constraints
    230 constraints of type <varbound>
     14 constraints of type <knapsack>
   1139 constraints of type <setppc>
    431 constraints of type <linear>
    243 constraints of type <logicor>
     12 constraints of type <bounddisjunction>
Presolving Time: 3.34
transformed 3/4 original solutions to the transformed problem space

[lp.c:11621] ERROR: cannot solve LP when loose variable with infinite best bound is present
[lp.c:12068] ERROR: Error <0> in function call
[lp.c:12257] ERROR: Error <0> in function call
[lp.c:12512] ERROR: Error <0> in function call
[solve.c:1512] ERROR: Error <0> in function call
[solve.c:3096] ERROR: Error <0> in function call
[solve.c:4015] ERROR: Error <0> in function call
[solve.c:4313] ERROR: Error <0> in function call
[solve.c:5106] ERROR: Error <0> in function call
[scip_solve.c:2661] ERROR: Error <0> in function call

Both errors happen due to setting start values as in the example below.
Example that reproduces the first error:

using JuMP, SCIP

function main()
  m, n = 100, 150
  model = Model(SCIP.Optimizer)
  set_silent(model)
  @variable(model, x[1:m, 1:n], Bin)
  @variable(model, y[1:max(m, n)], Bin)
  @constraints(
    model,
    begin
      [i in 1:n], sum(x[:, i]) <= y[i]
      [j in 1:m], sum(mod(i, 2) * x[j, i] for i in 1:n) >= sum(y[1:j])
    end
  )
  for k in 1:min(m, n)
    indices = [(i, j) for i in 1:m for j in 1:n if (i + j) % k == 0]
    @constraint(model, sum(x[i, j] for (i, j) in indices) >= 1)
  end
  varValues = nothing
  for k in 1:20
    @info "k = $k"
    obj = @expression(
      model,
      sum(mod(m + n + k, i) * y[i] for i in 1:max(m, n)) +
      sum(mod(m + n + k, i + j) * x[i, j] for i in 1:m, j in 1:n)
    )
    if varValues !== nothing
      for (varIdx, val) in varValues
        set_start_value(VariableRef(model, varIdx), val)
      end
    end
    @objective(model, Min, obj)
    optimize!(model)
    if primal_status(model) == FEASIBLE_POINT
      varValues = Dict{MOI.VariableIndex, Float64}(
        v.index => value(v) for v in all_variables(model)
      )
      obj_val = objective_value(model)
      @constraint(model, obj <= 1.01 * obj_val)
    end
  end
end

main()

Running this code results in the following:

[ Info: k = 1
[ Info: k = 2
[ Info: k = 3
[ Info: k = 4
[ Info: k = 5
[ Info: k = 6
[ Info: k = 7
[ Info: k = 8
[ Info: k = 9
[ Info: k = 10
[ Info: k = 11
[ Info: k = 12
[primal.c:901] ERROR: Cannot add partial solution to storage: limit reached.
[primal.c:1397] ERROR: Error <-8> in function call
[scip_sol.c:2864] ERROR: Error <-8> in function call
ERROR: LoadError: SCIPaddSolFree(o, sol__, stored_) yielded SCIP code SCIP_INVALIDCALL

Environment:

Julia version: 1.11.7
JuMP version: 1.29.1
SCIP.jl version: 0.12.7
SCIP_PaPILO_jll version: 900.200.200+0
Operating system: Ubuntu 20.04.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions