# Problem with Mosek and JuMP after Update

**URL:** https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [October 11, 2022, 7:12pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594 "2022-10-11T19:12:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)
#### Post date: [October 11, 2022, 7:12pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/1 "2022-10-11T19:12:18Z")

</div>

Hi, I just installed Julia v1.8.2 and Mosek 10.0.25 and suddenly a code for an optimization function that I’ve always used stopped working.

I provide a MWE

```julia
using JuMP, Ipopt, LinearAlgebra, Random, Distributions, BenchmarkTools, Mosek, MosekTools, NLopt, Plots, FLoops

Threads.nthreads()

const Ι = 2
const J = 1

#Create vectors

Random.seed!(123)

β = 1. *ones(J)

τ = [1.05 1.05]

z = rand(Ι)

function func1(C,β,τ,z)
    (J,Ι) = size(τ)
    model = JuMP.Model(optimizer_with_attributes(Mosek.Optimizer, "QUIET" => false, "INTPNT_CO_TOL_DFEAS" => 1e-7))
    set_silent(model)
    ms = β
    @variable(model, ν[1:Ι] >= 0)
    @variable(model, μ[1:J]>= 0)
    @variable(model, t[1:J]>= 0)
    @objective(model, Min, ν'*C .+ ms'*t)

    @constraint(
        model,
        c[i = i=1:Ι, j=1:J],
        τ[j,i]*z[i] + τ[j,i]*ν[i] - μ[j] >= 0,
    )

    @inbounds for j = 1 : J
        @constraint(model, [t[j],μ[j],1] in MOI.PowerCone(1/2))
    end    

    JuMP.optimize!(model)

    return objective_value(model), value.(ν)[1:Ι], value.(μ)[1:J], dual.(c)

end 

func1([10,10],β,τ,z)

```

with error message

```julia
MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}: Adding `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.PowerCone{Float64}` constraints cannot be performed. 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.
Stacktrace:
  [1] correct_throw_add_constraint_error_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64}; error_if_supported::MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}})
    @ MathOptInterface C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\constraints.jl:209
  [2] correct_throw_add_constraint_error_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
    @ MathOptInterface C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\constraints.jl:202
  [3] throw_add_constraint_error_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MathOptInterface C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\constraints.jl:173
  [4] throw_add_constraint_error_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
    @ MathOptInterface C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\constraints.jl:167
  [5] add_constraint(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
    @ MathOptInterface C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\constraints.jl:148
  [6] _copy_constraints(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index_map::MathOptInterface.Utilities.IndexMap, index_map_FS::MathOptInterface.Utilities.DoubleDicts.IndexDoubleDictInner{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}, cis_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:252
  [7] _copy_constraints(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index_map::MathOptInterface.Utilities.IndexMap, cis_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:264
  [8] pass_nonvariable_constraints_fallback(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index_map::MathOptInterface.Utilities.IndexMap, constraint_types::Vector{Any})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:275
  [9] pass_nonvariable_constraints
    @ C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:301 [inlined]
 [10] pass_nonvariable_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, idxmap::MathOptInterface.Utilities.IndexMap, constraint_types::Vector{Any})
    @ MathOptInterface.Bridges C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Bridges\bridge_optimizer.jl:435
 [11] _pass_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index_map::MathOptInterface.Utilities.IndexMap, variable_constraints_not_added::Vector{Any})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:323
 [12] default_copy_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\copy.jl:498
 [13] copy_to
    @ C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Bridges\bridge_optimizer.jl:451 [inlined]
 [14] optimize!
    @ C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\MathOptInterface.jl:86 [inlined]
 [15] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities C:\Users\juan\.julia\packages\MathOptInterface\Ohzb2\src\Utilities\cachingoptimizer.jl:316
 [16] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP C:\Users\juan\.julia\packages\JuMP\gVq7V\src\optimizer_interface.jl:185
 [17] optimize!
    @ C:\Users\juan\.julia\packages\JuMP\gVq7V\src\optimizer_interface.jl:155 [inlined]
 [18] func1(C::Vector{Int64}, β::Vector{Float64}, τ::Matrix{Float64}, z::Vector{Float64})
    @ Main c:\Users\juan\Dropbox\Projects\JMP\code_0122\mwe_crash.jl:39
 [19] top-level scope
    @ c:\Users\juan\Dropbox\Projects\JMP\code_0122\mwe_crash.jl:45

```

---

<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: [October 11, 2022, 8:35pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/2 "2022-10-11T20:35:58Z")

</div>

MOSEK v10 changed quite a few things, so this might be a bug.

Does it still have the problem with:

```julia
using JuMP, MosekTools
model = Model(Mosek.Optimizer)
@variable(model, x[1:2])
@constraint(model, [x[1], x[2], 1] in MOI.PowerCone(0.5))
optimize!(model)

```

If so, can you please open an issue at [Issues · jump-dev/MosekTools.jl · GitHub](https://github.com/jump-dev/MosekTools.jl/issues) and include the full text of the error message.

---

<div class="post-metadata">

### Author: ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)
#### Post date: [October 11, 2022, 10:47pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/3 "2022-10-11T22:47:39Z")

</div>

Thanks. It still has a problem.

I’ve just opened the issue

> <https://github.com/jump-dev/MosekTools.jl/issues/109>
>
> Hi,
> 
> Using the following MWE
> 
> \`\`\`Julia
> using JuMP, MosekTools
> model = Mode…l(Mosek.Optimizer)
> @variable(model, x\[1:2\])
> @constraint(model, \[x\[1\], x\[2\], 1\] in MOI.PowerCone(0.5))
> optimize!(model)
> \`\`\`
> 
> I get the following error message,
> 
> \`\`\`Julia
> ERROR: MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}: Adding \`MathOptInterface.VectorAffineFunction{Float64}\`-in-\`MathOptInterface.PowerCone{Float64}\` constraints cannot be performed. 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.
> Stacktrace:
> \[1\] correct\_throw\_add\_constraint\_error\_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64}; error\_if\_supported::MathOptInterface.AddConstraintNotAllowed{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}})
> @ MathOptInterface C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\constraints.jl:209
> \[2\] correct\_throw\_add\_constraint\_error\_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
> @ MathOptInterface C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\constraints.jl:202
> \[3\] throw\_add\_constraint\_error\_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
> @ MathOptInterface C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\constraints.jl:173
> \[4\] throw\_add\_constraint\_error\_fallback(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
> @ MathOptInterface C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\constraints.jl:167
> \[5\] add\_constraint(model::MosekTools.Optimizer, func::MathOptInterface.VectorAffineFunction{Float64}, set::MathOptInterface.PowerCone{Float64})
> @ MathOptInterface C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\constraints.jl:148
> \[6\] \_copy\_constraints(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, index\_map\_FS::MathOptInterface.Utilities.DoubleDicts.IndexDoubleDictInner{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}, cis\_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:252
> \[7\] \_copy\_constraints(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, cis\_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.PowerCone{Float64}}})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:264
> \[8\] pass\_nonvariable\_constraints\_fallback(dest::MosekTools.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, constraint\_types::Vector{Any})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:275
> \[9\] pass\_nonvariable\_constraints
> @ C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:301 \[inlined\]
> \[10\] pass\_nonvariable\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, idxmap::MathOptInterface.Utilities.IndexMap, constraint\_types::Vector{Any})
> @ MathOptInterface.Bridges C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Bridges\\bridge\_optimizer.jl:435
> \[11\] \_pass\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, index\_map::MathOptInterface.Utilities.IndexMap, variable\_constraints\_not\_added::Vector{Any})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:323
> \[12\] default\_copy\_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\copy.jl:498
> \[13\] copy\_to
> @ C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Bridges\\bridge\_optimizer.jl:451 \[inlined\]
> \[14\] optimize!
> @ C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\MathOptInterface.jl:86 \[inlined\]
> \[15\] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{MosekTools.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
> @ MathOptInterface.Utilities C:\\Users\\juan\\.julia\\packages\\MathOptInterface\\Ohzb2\\src\\Utilities\\cachingoptimizer.jl:316
> \[16\] optimize!(model::Model; ignore\_optimize\_hook::Bool, \_differentiation\_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
> @ JuMP C:\\Users\\juan\\.julia\\packages\\JuMP\\gVq7V\\src\\optimizer\_interface.jl:185
> \[17\] optimize!(model::Model)
> @ JuMP C:\\Users\\juan\\.julia\\packages\\JuMP\\gVq7V\\src\\optimizer\_interface.jl:155
> \[18\] top-level scope
> @ c:\\Users\\juan\\Dropbox\\Projects\\JMP\\code\_0122\\mwe\_crash.jl:5
> \`\`\`

---

<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: [October 11, 2022, 11:00pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/4 "2022-10-11T23:00:46Z")

</div>

Thanks. I don’t have an immediate work-around, so I suggest you go back to using Mosek 9 in the mean time.

---

<div class="post-metadata">

### Author: ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)
#### Post date: [October 11, 2022, 11:08pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/5 "2022-10-11T23:08:16Z")

</div>

Thanks so much. My only concern is that `Mosek.jl` was asking me for Mosek 10.

---

<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: [October 11, 2022, 11:10pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/6 "2022-10-11T23:10:44Z")

</div>

Use `] add MosekTools@0.12`.

(The latest release of MosekTools.jl, `v0.13`, supports only Mosek 10. The previous release, v0.12, supports Mosek 9.)

---

<div class="post-metadata">

### Author: ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)
#### Post date: [October 11, 2022, 11:13pm UTC](https://discourse.julialang.org/t/problem-with-mosek-and-jump-after-update/88594/7 "2022-10-11T23:13:38Z")

</div>

> [@odow](#):
>
> `] add MosekTools@0.12`.

thanks!
