# Using Juniper with Convex.jl

**URL:** https://discourse.julialang.org/t/using-juniper-with-convex-jl/119974
**Category:** Optimization (Mathematical)
**Created:** [September 27, 2024, 7:43pm UTC](https://discourse.julialang.org/t/using-juniper-with-convex-jl/119974 "2024-09-27T19:43:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [September 27, 2024, 7:43pm UTC](https://discourse.julialang.org/t/using-juniper-with-convex-jl/119974/1 "2024-09-27T19:43:54Z")

</div>

I am trying to solve a MISOCP, modeled using Convex.jl, and I thought that trying to solve it with Juniper would be great since it is one of the non-commercial solvers that can handle this problem. However, when I call `solve!` I got this error

```julia
ERROR: LoadError: MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Nonnegatives}: Adding `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.Nonnegatives` constraints cannot be performed: MatrixOfConstraints does not allow modifications to be made to the model once
`MOI.Utilities.final_touch` has been called. This is called at the end of
`MOI.copy_to` and in `MOI.Utilities.attach_optimizer` (which is called by
`MOI.optimize!` in a `MOI.Utilities.CachingOptimizer`). In order to be able to
apply modifications to this model, you should add a layer
`MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), model)`
where `model` is the current model. This will automatically empty `model` when
modifications are done after `MOI.Utilities.final_touch` is called and copy the
model again in `MOI.Utilities.attach_optimizer`.
 You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.

```

This is a MWE to reproduce the error (example taken from the Convex.jl docs):

```julia
using Convex, Juniper, ECOS
const MOI = Convex.MOI

w = [23; 31; 29; 44; 53; 38; 63; 85; 89; 82]
C = 165
p = [92; 57; 49; 68; 60; 43; 67; 84; 87; 72];
n = length(w)
x = Variable(n, BinVar)
problem = maximize(dot(p, x), dot(w, x) <= C)
opt = MOI.OptimizerWithAttributes(Juniper.Optimizer,
    "nl_solver" => MOI.OptimizerWithAttributes(ECOS.Optimizer, MOI.Silent() => true))
solve!(problem, opt)

```

Is this something expected (e.g., Convex.jl does not support Juniper) or am I missing something?

---

<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: [September 27, 2024, 8:49pm UTC](https://discourse.julialang.org/t/using-juniper-with-convex-jl/119974/2 "2024-09-27T20:49:33Z")

</div>

I don’t know if I have tested Juniper with Convex.

Do you want to open an issue? [Issues · jump-dev/Convex.jl · GitHub](https://github.com/jump-dev/Convex.jl/issues)

---

<div class="post-metadata">

### Author: ![CaG21](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@CaG21](https://discourse.julialang.org/u/CaG21)
#### Post date: [September 27, 2024, 9:45pm UTC](https://discourse.julialang.org/t/using-juniper-with-convex-jl/119974/3 "2024-09-27T21:45:23Z")

</div>

Yes, sure. I’ll do it now
