# Xpress with bilinear models (the model is MIQCP)

**URL:** https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680
**Category:** Optimization (Mathematical)
**Created:** [November 24, 2023, 3:26pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680 "2023-11-24T15:26:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![martina.gherardi](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@martina.gherardi](https://discourse.julialang.org/u/martina.gherardi)
#### Post date: [November 24, 2023, 3:26pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/1 "2023-11-24T15:26:47Z")

</div>

Hi,

I am trying to use **Xpress** on a model with **bilinear** terms.  
With linear models it works while with my bilinear model I obtain:

```julia
?900 Warning: The quadratic part of row 'R21577' defines a nonconvex region.
Please check your model or use nlpoptimize.

```

How to use nlpoptimize?

I tried using  
`MyBMod = BilevelModel(Xpress.nlpOptimizer, mode=...)`  
or declaring it as an option  
`set_optimizer(MyBMod, "nlpoptimize",1)`  
but without success.

Thank you in advance

---

<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: [November 24, 2023, 9:36pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/2 "2023-11-24T21:36:12Z")

</div>

cc @joaquimg is our Xpress and BilevelJuMP expert.

You could try using Gurobi instead, but the non-convex part combined with BilevelJuMP is a bit concerning. Is the bilinearity in the upper or lower level?

---

<div class="post-metadata">

### Author: ![martina.gherardi](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@martina.gherardi](https://discourse.julialang.org/u/martina.gherardi)
#### Post date: [November 24, 2023, 9:43pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/3 "2023-11-24T21:43:53Z")

</div>

The bilinearity is in the upper level.  
I already used gurobi but I would like to compare it with Xpress

---

<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: [November 24, 2023, 9:59pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/4 "2023-11-24T21:59:30Z")

</div>

I dont think Xpress.jl supports that yet then. We have a plan to fix things early next year.

---

<div class="post-metadata">

### Author: ![martina.gherardi](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@martina.gherardi](https://discourse.julialang.org/u/martina.gherardi)
#### Post date: [November 24, 2023, 10:07pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/5 "2023-11-24T22:07:41Z")

</div>

Okay thanks.  
Do you know how to declare the non linearity with xpress on single-level models?  
( MyMod = model…)

---

<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: [November 24, 2023, 10:30pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/6 "2023-11-24T22:30:07Z")

</div>

Not to my knowledge but Joaquim might. Its what we would fix next year

---

<div class="post-metadata">

### Author: ![martina.gherardi](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@martina.gherardi](https://discourse.julialang.org/u/martina.gherardi)
#### Post date: [November 25, 2023, 11:42am UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/7 "2023-11-25T11:42:06Z")

</div>

Ok I will wait for the answer of @joaquimg to see if it is possible (and how) to use xpress.jl to solve a single-level model with bilinear terms.

I am searching for the equivalent in xpress of the option (nonconvex=2) of gurobi

Thank you

---

<div class="post-metadata">

### Author: ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)
#### Post date: [November 29, 2023, 5:37pm UTC](https://discourse.julialang.org/t/xpress-with-bilinear-models-the-model-is-miqcp/106680/8 "2023-11-29T17:37:01Z")

</div>

Sorry for the delay.  
Xpress NL requires some updates to the API that are not ready yet.  
Since the problem is a QCQP, it might only require a simple update in `optimize!` and a recent version of express.  
I can give it a try and check.

You can use QuadraticToBinary.jl to get rid of bilinear terms. There is a tutorial for this: [Using QuadraticToBinary · BilevelJuMP.jl](https://joaquimg.github.io/BilevelJuMP.jl/stable/tutorials/quad_to_bin/)  
However, this might not be considered a fair benchmark between Xpress and Gurobi.
