Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for SOC feasibility problem with Gurobi/Julia #617

Open
leonardgoeke opened this issue Mar 7, 2025 · 3 comments
Open

False positive for SOC feasibility problem with Gurobi/Julia #617

leonardgoeke opened this issue Mar 7, 2025 · 3 comments

Comments

@leonardgoeke
Copy link

leonardgoeke commented Mar 7, 2025

I'm solving a feasibility problem with a second-order cone constraint. With JuMP v1.24.0, Gurobi v1.7.0, and Gurobi_jll v12.0.1 (so also Gurobi v12.0.1), Gurobi reports sub-optimal termination for certain solver settings. However, checking the solution, it violates several constraints and bounds. If I solve the same problem directly with Gurobi using the command line, the problem is (presumably correctly) reported as infeasible.

Also, the reporting differs. In Julia, I get this:

Optimize a model with 18205 rows, 13729 columns and 1734972 nonzeros
Model fingerprint: 0x52136f67
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [4e-03, 1e+04]
QMatrix range [4e-01, 4e-01]
QLMatrix range [8e-03, 1e+01]
Objective range [0e+00, 0e+00]
Bounds range [3e+02, 3e+02]
RHS range [1e-02, 1e+02]
QRHS range [2e+03, 2e+03]

Running the same problem from the command line, give me:

Optimize a model with 18205 rows, 13729 columns and 1734972 nonzeros
Model fingerprint: 0x113f16fe
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [4e-03, 1e+04]
QMatrix range [8e-01, 8e-01]
QLMatrix range [8e-03, 1e+01]
Objective range [0e+00, 0e+00]
Bounds range [3e+02, 3e+02]
RHS range [1e-02, 1e+02]
QRHS range [2e+03, 2e+03]

As you can see, the fingerprint and QMatrix range differs between.

I've attached the code and .mps file to reproduce the error. mre.zip

@odow
Copy link
Member

odow commented Mar 7, 2025

I can't reproduce:

julia> using JuMP

julia> using Gurobi

       # read-in model

julia> model = read_from_file("model.mps")
A JuMP Model
├ solver: none
├ objective_sense: MIN_SENSE
│ └ objective_function_type: AffExpr
├ num_variables: 13729
├ num_constraints: 30086
│ ├ AffExpr in MOI.EqualTo{Float64}: 6162
│ ├ AffExpr in MOI.GreaterThan{Float64}: 2954
│ ├ AffExpr in MOI.LessThan{Float64}: 9089
│ ├ QuadExpr in MOI.LessThan{Float64}: 1
│ ├ VariableRef in MOI.GreaterThan{Float64}: 10967
│ └ VariableRef in MOI.LessThan{Float64}: 913
└ Names registered in the model: none

julia> set_optimizer(model, Gurobi.Optimizer)

       # setu options and solve
Set parameter LicenseID to value 890341

julia> set_optimizer_attribute(model, "Method", 2)
Set parameter Method to value 2

julia> set_optimizer_attribute(model, "Crossover", 0)
Set parameter Crossover to value 0

julia> set_optimizer_attribute(model, "Threads", 10)
Set parameter Threads to value 10

julia> set_optimizer_attribute(model, "GURO_PAR_BARDENSETHRESH", 10000)
Set parameter GURO_PAR_BARDENSETHRESH to value 10000

julia> set_optimizer_attribute(model, "NumericFocus", 1)
Set parameter NumericFocus to value 1

julia> set_optimizer_attribute(model, "ResultFile", "model.sol")

julia> optimize!(model)
Set parameter GURO_PAR_BARDENSETHRESH to value 10000
Set parameter Method to value 2
Set parameter NumericFocus to value 1
Set parameter Crossover to value 0
Set parameter Threads to value 10
Gurobi Optimizer version 12.0.1 build v12.0.1rc0 (mac64[x86] - Darwin 24.1.0 24B83)

CPU model: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Thread count: 4 physical cores, 8 logical processors, using up to 10 threads

Warning: Thread count (10) is larger than processor count (8)
         Reduce the value of the Threads parameter to improve performance


Non-default parameters:
Method  2
Crossover  0
NumericFocus  1
Threads  10
GURO_PAR_BARDENSETHRESH  10000

Optimize a model with 18205 rows, 13729 columns and 1734972 nonzeros
Model fingerprint: 0xdd6beab3
Model has 1 quadratic constraint
Coefficient statistics:
  Matrix range     [4e-03, 1e+04]
  QMatrix range    [8e-01, 8e-01]
  QLMatrix range   [8e-03, 1e+01]
  Objective range  [0e+00, 0e+00]
  Bounds range     [3e+02, 3e+02]
  RHS range        [1e-02, 1e+02]
  QRHS range       [2e+03, 2e+03]
Presolve removed 5450 rows and 4316 columns
Presolve time: 0.68s
Presolved: 13508 rows, 9970 columns, 1708390 nonzeros
Presolved model has 1 second-order cone constraint
Ordering time: 0.53s

Barrier statistics:
 Dense cols : 1
 AA' NZ     : 5.725e+06
 Factor NZ  : 1.192e+07 (roughly 100 MB of memory)
 Factor Ops : 1.388e+10 (less than 1 second per iteration)
 Threads    : 10

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   0.00000000e+00 -4.02693281e+01  3.88e+04 1.00e-01  6.69e+00     3s
   1   0.00000000e+00 -4.95609964e+01  2.77e+04 8.52e-02  5.08e+00     3s
   2   0.00000000e+00 -7.64870038e+01  1.86e+04 6.00e-02  3.51e+00     4s
   3   0.00000000e+00 -5.84696977e+01  1.09e+04 3.74e-02  2.09e+00     4s
   4   0.00000000e+00 -7.27786248e+01  7.90e+03 1.91e-02  1.40e+00     5s
   5   0.00000000e+00 -2.47751405e+01  2.54e+03 6.26e-03  4.80e-01     6s
   6   0.00000000e+00  1.73536980e+02  9.49e+02 3.27e-03  1.93e-01     6s
   7   0.00000000e+00  1.24213494e+03  7.91e+02 2.13e-03  1.50e-01     7s
   8   0.00000000e+00  1.29746657e+04  7.67e+02 1.98e-03  1.43e-01     8s
   9   0.00000000e+00  3.42423830e+04  7.65e+02 1.97e-03  1.42e-01     9s
  10   0.00000000e+00  1.51345807e+05  7.63e+02 1.97e-03  1.41e-01    10s
  11   0.00000000e+00  9.33999588e+05  7.63e+02 1.97e-03  1.52e-01    10s
  12   0.00000000e+00  3.21504808e+06  7.63e+02 1.97e-03  1.76e-01    11s
  13   0.00000000e+00  7.17945392e+06  7.63e+02 1.97e-03  2.15e-01    12s
  14   0.00000000e+00  2.76199017e+07  7.63e+02 1.97e-03  3.90e-01    13s
  15   0.00000000e+00  6.57922912e+07  7.63e+02 1.97e-03  6.60e-01    14s
  16   0.00000000e+00 -4.02693281e+01  3.88e+04 1.00e-01  7.45e+00    16s
  17   0.00000000e+00 -1.32900109e+01  6.25e+03 2.94e-02  4.00e-01    17s
  18   0.00000000e+00 -7.96011234e+00  1.65e+03 1.69e-02  7.06e-02    18s
  19   0.00000000e+00 -5.34867486e+00  1.91e+03 1.14e-02  7.25e-02    18s
  20   0.00000000e+00 -1.48031323e+00  1.15e+03 4.43e-03  3.74e-02    19s
  21   0.00000000e+00  9.12129140e-01  1.13e+03 4.57e-03  7.06e-02    20s
  22   0.00000000e+00  5.55314196e+01  1.60e+03 1.20e-02  7.34e-01    21s
  23   0.00000000e+00  1.07579891e+02  9.69e+02 1.06e-02  1.24e+00    22s
  24   0.00000000e+00  3.42610703e+02  1.79e+03 1.22e-02  7.29e+00    23s
  25   0.00000000e+00  1.79618002e+03  2.01e+03 1.47e-02  2.74e+01    23s
  26*  0.00000000e+00  2.11388775e+05  1.04e+01 3.40e-02  1.86e-02    24s
  27*  0.00000000e+00  4.04944120e+04  1.20e+00 3.23e-04  1.04e-03    25s
  28*  0.00000000e+00  6.74833685e+07  1.40e-02 6.21e-06  1.10e-04    26s
  29*  0.00000000e+00  2.59833221e+08  1.85e-05 5.73e-09  5.95e-09    26s

Barrier performed 29 iterations in 26.38 seconds (19.75 work units)
Infeasible model


User-callback calls 3341, time in user-callback 0.02 sec

Warning: unable to write requested result file 'model.sol'


shell> gurobi_cl Crossover=0 GURO_PAR_BARDENSETHRESH=10000 Method=2 NumericFocus=1 Threads=10 logfile=gurobi_cl.log ResultFile=gurobi_cl.sol model.mps
Set parameter LicenseID to value 890341
Set parameter Method to value 2
Set parameter Crossover to value 0
Set parameter LogFile to value "gurobi_cl.log"
Set parameter NumericFocus to value 1
Set parameter Threads to value 10
Set parameter GURO_PAR_BARDENSETHRESH to value 10000
Using license file /Users/oscar/gurobi.lic

Gurobi Optimizer version 11.0.1 build v11.0.1rc0 (mac64[x86] - Darwin 24.1.0 24B83)
Copyright (c) 2024, Gurobi Optimization, LLC

Read MPS format model from file model.mps
Reading time = 0.49 seconds
: 18205 rows, 13729 columns, 1734972 nonzeros

CPU model: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Thread count: 4 physical cores, 8 logical processors, using up to 10 threads

Warning: Thread count (10) is larger than processor count (8)
         Reduce the value of the Threads parameter to improve performance


Optimize a model with 18205 rows, 13729 columns and 1734972 nonzeros
Model fingerprint: 0x113f16fe
Model has 1 quadratic constraint
Coefficient statistics:
  Matrix range     [4e-03, 1e+04]
  QMatrix range    [8e-01, 8e-01]
  QLMatrix range   [8e-03, 1e+01]
  Objective range  [0e+00, 0e+00]
  Bounds range     [3e+02, 3e+02]
  RHS range        [1e-02, 1e+02]
  QRHS range       [2e+03, 2e+03]
Presolve removed 4000 rows and 2866 columns
Presolve time: 0.86s
Presolved: 17768 rows, 10865 columns, 1716572 nonzeros
Presolved model has 1 second-order cone constraint
Ordering time: 0.59s

Barrier statistics:
 Dense cols : 1
 AA' NZ     : 5.286e+06
 Factor NZ  : 1.312e+07 (roughly 120 MB of memory)
 Factor Ops : 1.362e+10 (less than 1 second per iteration)
 Threads    : 10

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   0.00000000e+00 -3.05246631e+01  6.91e+04 1.00e-01  6.34e+00     3s
   1   0.00000000e+00 -4.40018611e+01  3.60e+04 8.25e-02  3.89e+00     4s
   2   0.00000000e+00 -6.34264634e+01  2.26e+04 5.29e-02  2.49e+00     4s
   3   0.00000000e+00 -3.56617184e+01  1.28e+04 3.42e-02  1.52e+00     5s
   4   0.00000000e+00 -4.35834134e+01  4.36e+03 1.14e-02  5.44e-01     6s
   5   0.00000000e+00 -5.86031553e+00  1.64e+03 3.77e-03  2.06e-01     7s
   6   0.00000000e+00  1.59735850e+02  8.44e+02 1.69e-03  1.03e-01     8s
   7   0.00000000e+00  1.17345876e+03  7.40e+02 1.10e-03  8.32e-02     9s
   8   0.00000000e+00  5.97861131e+03  7.27e+02 1.02e-03  8.14e-02    10s
   9   0.00000000e+00  2.17806077e+04  7.24e+02 1.01e-03  7.93e-02    11s
  10   0.00000000e+00  8.64249166e+04  7.23e+02 1.01e-03  7.86e-02    12s
  11   0.00000000e+00  3.81861383e+05  7.23e+02 1.01e-03  8.52e-02    13s
  12   0.00000000e+00  2.91345841e+06  7.23e+02 1.01e-03  1.42e-01    14s
  13   0.00000000e+00  7.88461362e+06  7.23e+02 1.01e-03  2.18e-01    15s
  14   0.00000000e+00  1.53684599e+07  7.22e+02 1.01e-03  3.13e-01    16s
  15   0.00000000e+00  3.67620540e+07  7.22e+02 1.01e-03  5.96e-01    17s
  16   0.00000000e+00  7.83477262e+07  7.22e+02 1.01e-03  1.09e+00    18s
  17   0.00000000e+00 -3.05246631e+01  1.71e+04 1.00e-01  1.57e+00    20s
  18   0.00000000e+00 -2.90990301e+00  2.51e+03 2.43e-02  7.74e-02    20s
  19   0.00000000e+00 -1.22819794e+00  1.24e+03 8.81e-03  2.98e-02    21s
  20   0.00000000e+00  2.63611669e+00  2.03e+03 6.56e-03  1.31e-01    22s
  21   0.00000000e+00  2.47766896e+01  1.72e+03 6.11e-03  2.66e-01    23s
  22   0.00000000e+00  4.97765140e+01  1.57e+03 5.97e-03  5.35e-01    24s
  23   0.00000000e+00  1.35680878e+02  1.90e+03 5.76e-03  1.67e+00    26s
  24   0.00000000e+00  5.55612602e+02  2.62e+03 6.61e-03  7.85e+00    27s
  25   0.00000000e+00  3.58414305e+04  4.70e+03 4.15e-02  6.30e+02    29s
  26*  0.00000000e+00  2.10064225e+04  7.65e-01 1.98e-05  4.42e-05    30s
  27*  0.00000000e+00  4.84622949e+07  1.60e-03 7.16e-10  1.55e-07    32s
  28*  0.00000000e+00  4.34617895e+08  2.29e-06 4.14e-11  4.79e-12    34s

Barrier performed 28 iterations in 33.93 seconds (20.12 work units)
Infeasible model


Unable to retrieve attribute 'X'
julia> v = MOI.get(Gurobi.Optimizer(), MOI.SolverVersion())
Set parameter LicenseID to value 890341
"12.0.1"

(tmp) pkg> st
Status `/private/tmp/Project.toml`
  [2e9cd046] Gurobi v1.7.0
  [4076af6c] JuMP v1.24.0

@odow
Copy link
Member

odow commented Mar 7, 2025

The fingerprints are different but that's probably due to a difference in row order with how we read in the MPS file and how Gurobi reads in the MPS file.

@torressa
Copy link
Collaborator

torressa commented Mar 7, 2025

I also cannot reproduce this on Windows (the users OS):

julia> include("code.jl")
Gurobi version: 12.0.1
Set parameter Method to value 2
Set parameter Crossover to value 0
Set parameter Threads to value 10
Set parameter GURO_PAR_BARDENSETHRESH to value 10000
Set parameter NumericFocus to value 1
Set parameter GURO_PAR_BARDENSETHRESH to value 10000
Set parameter Method to value 2
Set parameter NumericFocus to value 1
Set parameter Crossover to value 0
Set parameter Threads to value 10
Gurobi Optimizer version 12.0.1 build v12.0.1rc0 (win64 - Windows 11.0 (22000.2))

CPU model: AMD EPYC 7402P 24-Core Processor, instruction set [SSE2|AVX|AVX2]
Thread count: 4 physical cores, 4 logical processors, using up to 10 threads

Warning: Thread count (10) is larger than processor count (4)
         Reduce the value of the Threads parameter to improve performance


Non-default parameters:
Method  2
Crossover  0
NumericFocus  1
Threads  10
GURO_PAR_BARDENSETHRESH  10000

Optimize a model with 18205 rows, 13729 columns and 1734972 nonzeros
Model fingerprint: 0xdd6beab3
Model has 1 quadratic constraint
Coefficient statistics:
  Matrix range     [4e-03, 1e+04]
  QMatrix range    [8e-01, 8e-01]
  QLMatrix range   [8e-03, 1e+01]
  Objective range  [0e+00, 0e+00]
  Bounds range     [3e+02, 3e+02]
  RHS range        [1e-02, 1e+02]
  QRHS range       [2e+03, 2e+03]
Presolve removed 5450 rows and 4316 columns
Presolve time: 1.02s
Presolved: 13508 rows, 9970 columns, 1708390 nonzeros
Presolved model has 1 second-order cone constraint
Ordering time: 0.70s

Barrier statistics:
 Dense cols : 1
 AA' NZ     : 5.725e+06
 Factor NZ  : 1.192e+07 (roughly 100 MB of memory)
 Factor Ops : 1.388e+10 (less than 1 second per iteration)
 Threads    : 10

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   0.00000000e+00 -4.02693281e+01  3.88e+04 1.00e-01  6.69e+00     4s
   1   0.00000000e+00 -4.97920941e+01  2.82e+04 8.56e-02  5.15e+00     4s
   2   0.00000000e+00 -7.79359792e+01  2.03e+04 5.97e-02  3.70e+00     5s
   3   0.00000000e+00 -5.63001751e+01  1.18e+04 3.85e-02  2.25e+00     6s
   4   0.00000000e+00 -7.50067786e+01  4.88e+03 2.06e-02  1.03e+00     6s
   5   0.00000000e+00 -4.48504945e+00  1.72e+03 6.84e-03  3.56e-01     7s
   6   0.00000000e+00  1.27978814e+03  1.00e+03 3.51e-03  2.07e-01     8s
   7   0.00000000e+00  1.00736854e+04  9.08e+02 3.06e-03  1.87e-01     8s
   8   0.00000000e+00  3.98375829e+04  8.97e+02 2.97e-03  1.86e-01     9s
   9   0.00000000e+00  2.11825843e+05  8.94e+02 2.96e-03  1.81e-01    10s
  10   0.00000000e+00  1.56201414e+06  8.94e+02 2.96e-03  2.07e-01    11s
  11   0.00000000e+00  7.26678968e+06  8.94e+02 2.95e-03  2.94e-01    11s
  12   0.00000000e+00  1.66131016e+07  8.94e+02 2.95e-03  3.99e-01    12s
  13   0.00000000e+00  2.54717163e+07  8.94e+02 2.95e-03  4.88e-01    13s
  14   0.00000000e+00  7.69189039e+07  8.94e+02 2.95e-03  1.04e+00    14s
  15   0.00000000e+00 -4.02693281e+01  3.88e+04 1.00e-01  7.58e+00    16s
  16   0.00000000e+00 -1.30800600e+01  3.34e+03 2.92e-02  2.22e-01    16s
  17   0.00000000e+00 -8.48249818e+00  1.09e+03 1.63e-02  5.48e-02    17s
  18   0.00000000e+00 -2.33548524e+00  6.17e+02 4.00e-03  1.82e-02    18s
  19   0.00000000e+00  7.68469576e+00  6.07e+02 4.16e-03  4.51e-02    18s
  20   0.00000000e+00  4.91864674e+01  6.87e+02 4.83e-03  1.90e-01    19s
  21   0.00000000e+00  2.00074614e+02  6.42e+02 5.23e-03  5.69e-01    20s
  22   0.00000000e+00  3.71064031e+02  8.82e+02 5.41e-03  1.72e+00    20s
  23   0.00000000e+00  2.33172549e+03  1.45e+03 5.58e-03  8.68e+00    21s
  24*  0.00000000e+00  1.41390375e+05  1.20e+01 1.30e-02  9.29e-03    22s
  25*  0.00000000e+00  3.22710453e+06  1.70e+00 1.84e-03  1.33e-03    22s
  26*  0.00000000e+00  9.11702116e+06  1.21e-01 6.29e-08  9.51e-05    23s
  27*  0.00000000e+00  8.52019017e+09  1.35e-04 9.68e-08  1.14e-07    24s

Barrier performed 27 iterations in 23.55 seconds (16.81 work units)
Infeasible model


User-callback calls 431, time in user-callback 0.00 sec

Warning: unable to write requested result file 'model.sol'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants