# Using complements in JuMP

**URL:** https://discourse.julialang.org/t/using-complements-in-jump/42486
**Category:** Optimization (Mathematical)
**Created:** [July 3, 2020, 6:06pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486 "2020-07-03T18:06:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jovansam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jovansam/32/15023_2.png) [@jovansam](https://discourse.julialang.org/u/jovansam)
#### Post date: [July 3, 2020, 6:06pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/1 "2020-07-03T18:06:33Z")

</div>

I am trying to use complements in Julia-JuMP. I appreciate the work put into this wonderful package, the manual is not detailed enough unfortunately.

A working example that uses this feature in an optimization problem would be great.

Otherwise I would appreciate some help completing the following which the [JuMP manual here](https://jump.dev/JuMP.jl/v0.21.1/constraints/#Complementarity-constraints-1) says has a solution of 0.5.

```julia
using JuMP
function cake_eating()
    model = Model()
    @variable(model, x >= 0)
    @constraint(model, 2x - 1 ⟂ x)
    print(model)
    value(x)
end
cake_eating()

```

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 3, 2020, 6:09pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/2 "2020-07-03T18:09:57Z")

</div>

The only thing I see missing is actually calling the solver to solve the model. Did you not get an exception for calling `value` in an unsolved model?

---

<div class="post-metadata">

### Author: ![jovansam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jovansam/32/15023_2.png) [@jovansam](https://discourse.julialang.org/u/jovansam)
#### Post date: [July 3, 2020, 6:17pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/3 "2020-07-03T18:17:53Z")

</div>

@Henrique_Becker. How to call the solver in this case is exactly where my question is.

I have tried the following but it does not get me anywhere.

```julia
using Ipopt, JuMP
function cake_eating()
    model = Model(Ipopt.Optimizer)
    @variable(model, x >= 0)
    @constraint(model, 2x - 1 ⟂ x)
    print(model)
    optimize!(model)
    value(q)
end
cake_eating()

```

This returns:

```
Constraints of type MathOptInterface.VectorAffineFunction{Float64}-in-MathOptInterface.Complements are not supported by the solver and there are no bridges that can reformulate it into supported constraints.

```

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 3, 2020, 6:21pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/4 "2020-07-03T18:21:33Z")

</div>

The error message is completely self-explanatory. The solver you are using do not support such constraints and JuMP is missing any code that could work-around this lack of support by the solver. The documentation of the solver you are using says it supports this kind of constraints?

---

<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: [July 3, 2020, 6:29pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/5 "2020-07-03T18:29:45Z")

</div>

Solvers currently supporting Complements are: [PATH](https://github.com/odow/PATH.jl) and [KNITRO](https://github.com/jump-dev/KNITRO.jl).

---

<div class="post-metadata">

### Author: ![jovansam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jovansam/32/15023_2.png) [@jovansam](https://discourse.julialang.org/u/jovansam)
#### Post date: [July 3, 2020, 6:47pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486/6 "2020-07-03T18:47:03Z")

</div>

@Henrique_Becker, @joaquimg. Thanks for the heads up. No access to KNITRO. But will install PATH and see what I get. Will report back.

UPDATE: I have now tried both solvers (PATH and KNITRO) and they returned the correct solution. Thanks for the assistance.
