jump-dev / CPLEX.jl

A Julia interface to the CPLEX solver
https://www.ibm.com/products/ilog-cplex-optimization-studio
MIT License
134 stars 63 forks source link

Example on annotation is failing v22.1.0.0 #408

Closed davide-f closed 2 years ago

davide-f commented 2 years ago

I'm using CPLEX@0.9.3 and JuMP@1.1.1 using the latest ILOG CPLEX binaries Version identifier: 22.1.0.0 on windows 11, but the example on the use of annotations, either the partial and full implementation, is failing on my windows 11.

The following error is returned: CPLEX Error 2002: Invalid Benders decomposition.

odow commented 2 years ago

You'd have to dig into the C API to check if anything changed. I haven't used the CPLEX Benders API so not sure what the problem is.

cc @kaarthiksundar added the example in https://github.com/jump-dev/CPLEX.jl/pull/394

davide-f commented 2 years ago

For me this task is too large to handle, as it would involve deep checking on the documentation and I don't have the time to do that. I may go for the strategy 3 and bypass the annotations, though I would loose performances.

I believe suggestions by @kaarthiksundar may be welcome as theoretically that PR was quite recent and at the same time as the v22.1 release.

@kaarthiksundar what version of CPLEX did you use?

davide-f commented 2 years ago

I've just tested with CPLEX ILOG v12.10 and the same problem occurs

odow commented 2 years ago

I cannot reproduce on macOS, so perhaps this is a Windows thing. In which case, that's even harder to debug.

julia> illustrate_full_annotation()
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_Benders_Strategy                        1
Found incumbent of value 4.000000 after 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 4 columns, and 8 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 4 columns, and 8 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)

        Nodes                                         Cuts/
   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

      0     0        0.0000              4.0000    Benders: 1        0  100.00%
      0     0        3.9565              4.0000    Benders: 1        1    1.09%
Tried aggregator 1 time.
Reduced MIP has 2 rows, 3 columns, and 6 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Probing time = 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 3 columns, and 6 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Probing time = 0.00 sec. (0.00 ticks)
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 8 threads.
Root relaxation solution time = 0.00 sec. (0.00 ticks)
*     0+    0                            4.0000        3.9565             1.09%
      0     0        3.9756     2        4.0000        3.9756        4    0.61%
      0     0        cutoff              4.0000                      5    0.00%
Elapsed time = 0.00 sec. (0.04 ticks, tree = 0.01 MB, solutions = 0)

Benders cuts applied:  2

Root node processing (before b&c):
  Real time             =    0.00 sec. (0.04 ticks)
Parallel b&c, 8 threads:
  Real time             =    0.00 sec. (0.00 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                          ------------
Total (root+branch&cut) =    0.00 sec. (0.04 ticks)
x: [0.0, 1.0], y: [0.0, 0.0]

julia> illustrate_partial_annotation()
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_Benders_Strategy                        2
Found incumbent of value 4.000000 after 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 4 columns, and 8 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 4 columns, and 8 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)

        Nodes                                         Cuts/
   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

      0     0        0.0000              4.0000    Benders: 1        0  100.00%
      0     0        3.9565              4.0000    Benders: 1        1    1.09%
Tried aggregator 1 time.
Reduced MIP has 2 rows, 3 columns, and 6 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Probing time = 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
Reduced MIP has 2 rows, 3 columns, and 6 nonzeros.
Reduced MIP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (0.00 ticks)
Probing time = 0.00 sec. (0.00 ticks)
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 8 threads.
Root relaxation solution time = 0.00 sec. (0.00 ticks)
*     0+    0                            4.0000        3.9565             1.09%
      0     0        3.9756     2        4.0000        3.9756        4    0.61%
      0     0        cutoff              4.0000                      5    0.00%
Elapsed time = 0.00 sec. (0.04 ticks, tree = 0.01 MB, solutions = 0)

Benders cuts applied:  2

Root node processing (before b&c):
  Real time             =    0.00 sec. (0.04 ticks)
Parallel b&c, 8 threads:
  Real time             =    0.00 sec. (0.00 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                          ------------
Total (root+branch&cut) =    0.00 sec. (0.04 ticks)
x: [0.0, 1.0], y: [0.0, 0.0]
odow commented 2 years ago

Can you try replacing

indices, annotations = Cint[], Clong[]

with

indices, annotations = CPLEX.CPXINT[], CPLEX.CPXLONG[]
davide-f commented 2 years ago

Oh yes! @odow you are right! that fixed this issue!