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
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
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