# Problem with CPLEX lazy callback and JuMP

**URL:** <https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090>\
**Category:** Optimization (Mathematical)\
**Created:** [September 22, 2020, 6:59pm UTC](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090 "2020-09-22T18:59:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dragond4](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dragond4/32/18123_2.png) [@dragond4](https://discourse.julialang.org/u/dragond4)\
**Post date:** [September 22, 2020, 6:59pm UTC](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090/1 "2020-09-22T18:59:15Z")

</div>

Hi!

When trying to use lazy callbacks in JuMP I get the following error if CPLEX is used as solver:

> ERROR: LoadError: TypeError: in typeassert, expected Tuple{CPLEX.Model,Function}, got a value of type Tuple{UInt64,Int64}

from function _callback\_wrapper(::Ptr{Nothing}, ::Int32, ::Ptr{Nothing})_ at  
at _.julia\packages\CPLEX\DgohF\src\cpx\_generic\_callbacks.jl:15_

The MWE is simply the callback example found in the [Julia manual](https://jump.dev/JuMP.jl/stable/callbacks/):

```julia
model = Model(GLPK.Optimizer)
@variable(model, x <= 10, Int)
@objective(model, Max, x)
function my_callback_function(cb_data)
    x_val = callback_value(cb_data, x)
    if x_val > 2 + 1e-6
        con = @build_constraint(x <= 2)
        MOI.submit(model, MOI.LazyConstraint(cb_data), con)
    end
end
MOI.set(model, MOI.LazyConstraintCallback(), my_callback_function)

```

The same error is obtained with both CPLEX 12.10 and CPLEX 12.8 on a machine running Windows 8.1. The error disappears when using GLPK as a solver.  
I am using Julia 1.5.0.  
Any idea of how to solve this problem?  
Thanks,  
Michele

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 22, 2020, 8:51pm UTC](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090/2 "2020-09-22T20:51:13Z")

</div>

This is a known error: [https://github.com/jump-dev/CPLEX.jl/issues/312](https://github.com/jump-dev/CPLEX.jl/issues/312)

Until it gets fixed, use an older version of Julia (like 1.0 or 1.3).

---

<div class="post-metadata">

**Author:** ![dragond4](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dragond4/32/18123_2.png) [@dragond4](https://discourse.julialang.org/u/dragond4)\
**Post date:** [September 22, 2020, 8:59pm UTC](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090/3 "2020-09-22T20:59:21Z")

</div>

Hi odow,  
thank you very much for your answer!  
Sorry for opening this topic then: in fact I searched a lot before writing, but without finding your link.  
Best regards,  
Michele
