# Dual ray from LP solved by dual algorithm

**URL:** https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [May 9, 2024, 8:38pm UTC](https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068 "2024-05-09T20:38:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ShGE](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shge/32/207639_2.png) [@ShGE](https://discourse.julialang.org/u/ShGE)
#### Post date: [May 9, 2024, 8:38pm UTC](https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068/1 "2024-05-09T20:38:58Z")

</div>

Hello  
I solve an LP using CPLEX and fix the following parameters:

```
    set_optimizer_attribute(sub, "CPX_PARAM_REDUCE", 0)
    set_optimizer_attribute(sub, "CPX_PARAM_NUMERICALEMPHASIS", 1) # Emphasize numerical precision
    set_optimizer_attribute(sub, "CPX_PARAM_LPMETHOD", 2)

```

if I have a LP which is infeasible, I need to get the dual ray.  
I check  
if MOI.get(sub, MOI.DualStatus()) == MOI.INFEASIBILITY\_CERTIFICATE  
and try :  
dual\_ray\_balance1 = MOI.get(sub, MOI.ConstraintDual(), balance1)  
and I get the following.  
All constructive comments are highly appreciated.

Error accessing dual ray: MethodError(MathOptInterface.get, (A JuMP Model  
Minimization problem with:  
Variables: 67  
Objective function type: VariableRef  
`VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 67 constraints  
`AffExpr`-in-`MathOptInterface.LessThan{Float64}`: 54 constraints  
`AffExpr`-in-`MathOptInterface.GreaterThan{Float64}`: 21 constraints  
`AffExpr`-in-`MathOptInterface.EqualTo{Float64}`: 36 constraints  
Model mode: DIRECT  
Solver name: CPLEX  
Names registered in the model: Cmax, E1, E2, F1, F2, balance1, balance2, cmax, ftime, loading\_sequence, loading\_time, operation\_completion, transfer\_limit, unloading\_sequence, unloading\_time, x, MathOptInterface.ConstraintDual(1), 2-dimensional DenseAxisArray{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape},2,…} with index sets:  
Dimension 1, 1:3  
Dimension 2, 1:6  
And data, a 3×6 Matrix{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:  
balance1[1,1] : 34 x[1,1,1] + 34 x[1,1,2] + 34 x[1,1,3] == 19 balance1[1,2] : 19 x[2,1,1] + 19 x[2,1,2] + 19 x[2,1,3] == 3 balance1[1,3] : 21 x[3,1,1] + 21 x[3,1,2] + 21 x[3,1,3] == 2 balance1[1,4] : 41 x[4,1,1] + 41 x[4,1,2] + 41 x[4,1,3] == 7 balance1[1,5] : 33 x[5,1,1] + 33 x[5,1,2] + 33 x[5,1,3] == 12 balance1[1,6] : 21 x[6,1,1] + 21 x[6,1,2] + 21 x[6,1,3] == 3  
balance1[2,1] : 34 x[1,2,1] + 34 x[1,2,2] + 34 x[1,2,3] == 13 balance1[2,2] : 19 x[2,2,1] + 19 x[2,2,2] + 19 x[2,2,3] == 9 balance1[2,3] : 21 x[3,2,1] + 21 x[3,2,2] + 21 x[3,2,3] == 6 balance1[2,4] : 41 x[4,2,1] + 41 x[4,2,2] + 41 x[4,2,3] == 19 balance1[2,5] : 33 x[5,2,1] + 33 x[5,2,2] + 33 x[5,2,3] == 18 balance1[2,6] : 21 x[6,2,1] + 21 x[6,2,2] + 21 x[6,2,3] == 5  
balance1[3,1] : 34 x[1,3,1] + 34 x[1,3,2] + 34 x[1,3,3] == 2 balance1[3,2] : 19 x[2,3,1] + 19 x[2,3,2] + 19 x[2,3,3] == 7 balance1[3,3] : 21 x[3,3,1] + 21 x[3,3,2] + 21 x[3,3,3] == 13 balance1[3,4] : 41 x[4,3,1] + 41 x[4,3,2] + 41 x[4,3,3] == 15 balance1[3,5] : 33 x[5,3,1] + 33 x[5,3,2] + 33 x[5,3,3] == 3 balance1[3,6] : 21 x[6,3,1] + 21 x[6,3,2] + 21 x[6,3,3] == 13), 0x0000000000007b8c)

---

<div class="post-metadata">

### Author: ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)
#### Post date: [May 9, 2024, 9:11pm UTC](https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068/2 "2024-05-09T21:11:49Z")

</div>

Edit the the category to `Optimization (Mathematical)` and with tags `JuMP,` `Optimization,` etc. Folks there will have answers to your questions.

---

<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: [May 9, 2024, 9:19pm UTC](https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068/3 "2024-05-09T21:19:36Z")

</div>

Hi @ShGE,

You can query the dual of a constraint in JuMP with `JuMP.dual(balance1)`.

You should rarely, if ever, need to use the `MOI.` functions. These are for a few specialized advanced use-cases.

---

<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: [May 9, 2024, 9:22pm UTC](https://discourse.julialang.org/t/dual-ray-from-lp-solved-by-dual-algorithm/114068/4 "2024-05-09T21:22:07Z")

</div>

I assume you’re doing some sort of Benders decomposition. We should add feasibility cuts to the tutorial: [Benders decomposition · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/benders_decomposition/)
