# Problem with CPLEX variable types using JuMP

**URL:** <https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [October 15, 2020, 8:30am UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415 "2020-10-15T08:30:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arkanver](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@arkanver](https://discourse.julialang.org/u/arkanver)\
**Post date:** [October 15, 2020, 8:30am UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/1 "2020-10-15T08:30:38Z")

</div>

Hello all,

I am trying to solve a quadratic optimization problem using CPLEX through JuMP. It is a continuous relaxation, hence **all of my variables are continuous** (with box constraints).  
After dealing with convexity issues, I get the following error :

```julia
ERROR: CPLEX.CplexError(1017, "CPLEX Error 1017: Not available for mixed-integer problems.\n")

```

Since the error is thrown by CPLEX, I went through documentation and forums on the CPLEX side of things, until I found the following note (in the documentation for the Python API, granted).

_Note : If types is specified, the problem type will be a MIP, even if all variables are specified to be continuous._ ([IBM Documentation](https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/refpythoncplex/html/cplex._internal._subinterfaces.VariablesInterface-class.html#add))

Since the python user and I got the same error, this might be the same problem for both of us. How do I remedy this situation in JuMP ? I need the problem to be seen as a continuous optimization problem.

Thank you for reading.

---

<div class="post-metadata">

**Author:** ![MarcMush](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcmush/32/18006_2.png) [@MarcMush](https://discourse.julialang.org/u/MarcMush)\
**Post date:** [October 15, 2020, 3:16pm UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/2 "2020-10-15T15:16:57Z")

</div>

Can you please post a minimal code example to replicate the error ?

---

<div class="post-metadata">

**Author:** ![arkanver](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@arkanver](https://discourse.julialang.org/u/arkanver)\
**Post date:** [October 15, 2020, 4:00pm UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/3 "2020-10-15T16:00:33Z")

</div>

```julia
using JuMP
using CPLEX
mp = Model(CPLEX.Optimizer)
@variable(mp, 0 <= x[1:3] <= 1)
@objective(mp, Min, x[1]^2 + x[2]^2 + x[3]^2 -3*x[1]*x[2] -4*x[1]*x[3] -5*x[2]*x[3])
set_optimizer_attribute(mp, "CPXPARAM_OptimalityTarget",3) #To search global opt
#Despite non convexity
optimize!(mp)

```

This should yield the error, despite all variables being continuous.

---

<div class="post-metadata">

**Author:** ![mtanneau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtanneau/32/17787_2.png) [@mtanneau](https://discourse.julialang.org/u/mtanneau)\
**Post date:** [October 15, 2020, 5:13pm UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/4 "2020-10-15T17:13:28Z")

</div>

~~I can’t reproduce the error locally. Are you using the latest versions of JuMP & CPLEX?~~

[EDIT]: this is obtained with the master branch of CPLEX.jl

```julia
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_OptimalityTarget 3
Warning: global optimality target changes problem type to MIQP.
Found incumbent of value 0.000000 after 0.01 sec. (0.00 ticks)
Found incumbent of value -9.000000 after 0.01 sec. (0.00 ticks)
Tried aggregator 2 times.
MIQP Presolve added 0 rows and 3 columns.
Aggregator did 1 substitutions.
Reduced MIQP has 2 rows, 6 columns, and 7 nonzeros.
Reduced MIQP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators.
Reduced MIQP objective Q matrix has 3 nonzeros.
Presolve time = 0.01 sec. (0.01 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.01 sec. (0.03 ticks) 
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap

      0 0 -12.5250 0 -12.5250 14
* 0+ 0 -9.0000 -12.5250 39.17%
      0 2 -12.5250 0 -9.0000 -12.5250 14 39.17%
Elapsed time = 0.05 sec. (0.17 ticks, tree = 0.02 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.05 sec. (0.16 ticks)
Parallel b&c, 8 threads:
Real time = 0.01 sec. (0.04 ticks)
Sync time (average) = 0.00 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 0.05 sec. (0.20 ticks)

```

With the latest tagged release, I obtain the same error, which is triggered when the MOI wrapper tries to query dual information from the problem.

I suggest you swtich to CPLEX#master for now. A new version should be tagged soon.

---

<div class="post-metadata">

**Author:** ![arkanver](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@arkanver](https://discourse.julialang.org/u/arkanver)\
**Post date:** [October 15, 2020, 5:20pm UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/5 "2020-10-15T17:20:56Z")

</div>

Thank you very much ! Seems I have a habit of stumbling on issues that have been solved in the master branch. I should think about it next time something like that happens.

---

<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:** [October 15, 2020, 9:02pm UTC](https://discourse.julialang.org/t/problem-with-cplex-variable-types-using-jump/48415/6 "2020-10-15T21:02:30Z")

</div>

Make sure you read the following before using `CPLEX#master`. It also explains when a new version will be tagged:

> [@\[ANN\] Upcoming breaking changes to CPLEX.jl and Gurobi.jl](https://discourse.julialang.org/t/ann-upcoming-breaking-changes-to-cplex-jl-and-gurobi-jl/47814):
>
> Update: 20 October 2020: New versions of CPLEX.jl and Gurobi.jl are tagged. tl;dr: CPLEX.jl and Gurobi.jl will have major breaking changes in the next latest release. If you just use CPLEX.Optimizer() or Gurobi.Optimizer() with JuMP, nothing changes. If you use any lower-level functionality in CPLEX.jl or Gurobi.jl (e.g., solver-dependent callbacks, or functions from the C API), your code will break. Furthermore, all support for MathProgBase has been removed. You can try out the changes by addi…

The underlying issue for this is complicated. I wasn’t aware `CPXPARAM_OptimalityTarget` changes the problem type, so I should add some better tests.

Edit: added a test so this doesn’t break in future: [Add test for CPXPARAM\_OptimalityTarget by odow · Pull Request #332 · jump-dev/CPLEX.jl · GitHub](https://github.com/jump-dev/CPLEX.jl/pull/332)
