# CPLEX.jl Quadratic Expression symmetric matrix bug?

**URL:** <https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315>\
**Category:** Optimization (Mathematical)\
**Created:** [October 30, 2020, 4:45pm UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315 "2020-10-30T16:45:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 30, 2020, 4:45pm UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/1 "2020-10-30T16:45:49Z")

</div>

I have a optimization procedure that used to work but now I’m getting an error. Is it related to the new CPLEX.jl package? A simple working example that produces the error is:

```julia
m = Model(CPLEX.Optimizer)
@variable m x[1:10]
@variable m y

tmp = @expression m (y + x[1] + x[2] + x[3] + x[4] + x[5] - x[6] - x[7] - x[8] - x[9] - x[10] - .5)^2

@objective m Min tmp

optimize!(m)

```

This produces the error

```julia
ERROR: Matrix Q must be either symmetric or triangular
Stacktrace:
 [1] add_qpterms!(::CPLEX.Model, ::Array{Int32,1}, ::Array{Int32,1}, ::Array{Float64,1}) at /home/paul/.julia/packages/CPLEX/DgohF/src/cpx_quad.jl:17

```

Like I said, I used to have an optimization procedure essentially like this that worked well with JuMP and CPLEX. I’m unsure if this is a bug and if I should post it somewhere?

---

<div class="post-metadata">

**Author:** ![metab0t](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/metab0t/32/15551_2.png) [@metab0t](https://discourse.julialang.org/u/metab0t)\
**Post date:** [October 30, 2020, 5:41pm UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/2 "2020-10-30T17:41:18Z")

</div>

I test this code on my computer with newest CPLEX@0.7.2 and it works fine.  
It seems that you are using an older version of CPLEX.

---

<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 30, 2020, 6:54pm UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/3 "2020-10-30T18:54:00Z")

</div>

Yeah, the provided stack trace is from an older version.

---

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 31, 2020, 2:12am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/4 "2020-10-31T02:12:32Z")

</div>

Ok, this is a silly question. But updating `CPLEX` keeps the version at v0.6.6. I even updated julia to make sure its version `1.5.2` but it still won’t update. I thought the new version was tagged?

---

<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 31, 2020, 2:35am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/5 "2020-10-31T02:35:04Z")

</div>

You most likely have another package that is preventing Pkg from using the latest CPLEX release.  
You can force Pkg to use the latest CPLEX with

```julia
] add CPLEX#master

```

(the `#` is not a comment, it means "use the `master` branch from CPLEX.jl), and see what `Pkg`’s conflict tool says.

---

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 31, 2020, 3:28am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/6 "2020-10-31T03:28:06Z")

</div>

Awesome - it was `CUDA` and `CuArrays`

---

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 31, 2020, 3:56am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/7 "2020-10-31T03:56:42Z")

</div>

Ok, I’m really sorry for these questions. But now I can’t install `CPLEX` again. I re-downloaded the binaries to make sure it was greater than version 12.10, I set the `ENV["CPLEX_STUDIO_BINARIES"]` variables correctly and whenever I tried to build it it says `no cplex in` and then lists the folders in my `PATH` variable? Did it package get changed to look for the binaries in the `PATH` and not `CPLEX_STUDIO_BINARIES` folders?

---

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 31, 2020, 4:15am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/8 "2020-10-31T04:15:32Z")

</div>

Ok, so it looks like the version I just downloaded is 12.80. Is the only version supported by `CPLEX` 12.10? I don’t even know how I would get that version

---

<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 31, 2020, 6:03am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/9 "2020-10-31T06:03:57Z")

</div>

12.80 is a misnomer. It’s really 12.8.

12.10 is the latest version. You can download it from IBM. They have an academic program: [CPLEX Optimization Studio is free for students and academics!](https://community.ibm.com/community/user/datascience/blogs/xavier-nodet1/2020/07/09/cplex-free-for-students?CommunityKey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=)

---

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [October 31, 2020, 6:17am UTC](https://discourse.julialang.org/t/cplex-jl-quadratic-expression-symmetric-matrix-bug/49315/10 "2020-10-31T06:17:01Z")

</div>

That is strange. I had literally just done that. But I did it again and this time it was 12.10. I guess I made a mistake. Thanks for the help. Everything from my original question works now
