# Linprog and Clp under JuMP or MathOptInterface - Why is it so hard?

**URL:** <https://discourse.julialang.org/t/linprog-and-clp-under-jump-or-mathoptinterface-why-is-it-so-hard/39323>\
**Category:** Optimization (Mathematical)\
**Created:** [May 12, 2020, 3:39am UTC](https://discourse.julialang.org/t/linprog-and-clp-under-jump-or-mathoptinterface-why-is-it-so-hard/39323 "2020-05-12T03:39:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scotts](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@scotts](https://discourse.julialang.org/u/scotts)\
**Post date:** [May 12, 2020, 3:39am UTC](https://discourse.julialang.org/t/linprog-and-clp-under-jump-or-mathoptinterface-why-is-it-so-hard/39323/1 "2020-05-12T03:39:59Z")

</div>

Julia is working beautifully on an LP problem on my mac.

My optimisation problem is structured with inequality constraints and the sense vector:

sol = linprog(-f,A,sense,b,lb,ub,ClpSolver())

For some reason running the same code on Windows 10, I get an error:

`ClpSolver` is no longer supported. If you are using JuMP, upgrade to the latest version and use `Clp.Optimizer` instead. If you are using MathProgBase (e.g., via `lingprog`), you will need to upgrade to MathOptInterface ([GitHub - jump-dev/MathOptInterface.jl: An abstraction layer for mathematical optimization solvers.](https://github.com/JuliaOpt/MathOptInterface.jl)).

Is there a simple way to take these matrices and get them to work under either of the options referred to in the error, using the matrices and vectors I have already created. I have spent the entire morning reading docs for this and am just confused. Some don’t use the sense vector, others I just don’t understand.

There must be a simple way to “upgrade” this previously working code, keeping it simple?

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [May 12, 2020, 7:28am UTC](https://discourse.julialang.org/t/linprog-and-clp-under-jump-or-mathoptinterface-why-is-it-so-hard/39323/2 "2020-05-12T07:28:51Z")

</div>

The support for MathProgBase was just dropped in v0.8 that was released 16 hours ago. I guess you were using Clp.jl v0.7.2 on your mac.  
The recommendation is to use JuMP now instead of `linprog`. From the input of `linprog`, you can do

```julia
using JuMP, Clp
model = Model(Clp.Optimizer)
@variable(model, lb[i] <= x[i=1:length(lb)] <= ub[i])
@objective(model, Max, f'x)
# Depending on the `sense` vector, you may need to split it into `<=` and `>=` constraints too
@constraint(model, A * x .== b)
optimize!(model)

```

---

<div class="post-metadata">

**Author:** ![scotts](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@scotts](https://discourse.julialang.org/u/scotts)\
**Post date:** [May 12, 2020, 8:33am UTC](https://discourse.julialang.org/t/linprog-and-clp-under-jump-or-mathoptinterface-why-is-it-so-hard/39323/3 "2020-05-12T08:33:19Z")

</div>

That’s great, thank you. Looks like my timing was perfect for learning LP in Julia.

I assume by “splitting” you mean I need two lines:

```julia
@constraint(model, A * x .<= b) #inequality constraints
@constraint(model, Aeq * x .== beq) #equality constraints

```

Where beq is just a vector of zeros, right?

The first line seems to process fine, but when Julia gets to the second one I get the following error…

julia\> @constraint(model, Aeq \* x .== beq)  
ERROR: MethodError: no method matching zero(::Type{Any})

EDIT: Ahhh. Nevermind, my Aeq was Array{Any,2}.

Fixed with Float64.(Aeq)

Thanks again, much appreciated!
