Skip to content

Error returning solution of a problem with DualExponentialCone using JuMP #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
guilhermebodin opened this issue Sep 10, 2019 · 2 comments

Comments

@guilhermebodin
Copy link

Hello I am trying to run this problem using the JuMP interface

using MathOptInterface, JuMP, COSMO
model = Model(with_optimizer(COSMO.Optimizer))
@variable(model, u)
@variable(model, v)
@variable(model, w)
@constraint(model, [u; v; w] in MathOptInterface.DualExponentialCone())
@constraint(model, u == 1)
@constraint(model, v == 2)
@objective(model, Max, u + v + w)
optimize!(model)

apparently it solves but breaks writing the answer somewhere

julia> optimize!(model)
------------------------------------------------------------------
          COSMO v0.5.0 - A Quadratic Objective Conic Solver
                         Michael Garstka
                University of Oxford, 2017 - 2019
------------------------------------------------------------------

Problem:  x  R^{3},
          constraints: A  R^{5x3} (5 nnz),
          matrix size to factor: 8x8 (18 nnz)
Sets:     DualExponentialCone of dim: 3
          ZeroSet of dim: 2
Settings: ϵ_abs = 1.0e-04, ϵ_rel = 1.0e-04,
          ϵ_prim_inf = 1.0e-06, ϵ_dual_inf = 1.0e-04,
          ρ = 0.1, σ = 1.0e-6, α = 1.6,
          max_iter = 2500,
          scaling iter = 10 (on),
          check termination every 40 iter,
          check infeasibility every 40 iter,
          KKT system solver: QDLDL
Setup Time: 2156.02ms

Iter:   Objective:      Primal Res:     Dual Res:       Rho:
40      -6.4299e+02     9.9900e-01      1.0000e+00      1.0000e-01
ERROR: MethodError: no method matching in_cone(::Array{Float64,1}, ::Type{COSMO.ExponentialCone{Float64}}, ::Float64)
Closest candidates are:
  in_cone(::AbstractArray{T,1}, ::COSMO.ExponentialCone{T}, ::T) where T at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:507
  in_cone(::AbstractArray{T,1}, ::COSMO.PowerCone{T}, ::T) where T at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:624
  in_cone(::AbstractArray{T<:Real,1}, ::Union{DualExponentialCone, DualPowerCone}, ::Real) where T<:Real at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:678
Stacktrace:
 [1] in_dual(::Array{Float64,1}, ::COSMO.DualExponentialCone{Float64}, ::Float64) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:679
 [2] support_function(::SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true}, ::COSMO.DualExponentialCone{Float64}, ::Float64) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:809
 [3] (::getfield(COSMO, Symbol("##21#22")){Float64})(::Tuple{SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},COSMO.DualExponentialCone{Float64}}) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:775
 [4] mapfoldl_impl(::getfield(COSMO, Symbol("##21#22")){Float64}, ::typeof(Base.add_sum), ::NamedTuple{(:init,),Tuple{Float64}}, ::Base.Iterators.Zip2{Array{SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},1},Array{COSMO.AbstractConvexSet,1}}, ::Tuple{Int64,Int64}) at ./reduce.jl:43
 [5] mapfoldl_impl(::Function, ::Function, ::NamedTuple{(),Tuple{}}, ::Base.Iterators.Zip2{Array{SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},1},Array{COSMO.AbstractConvexSet,1}}) at ./reduce.jl:59
 [6] #mapfoldl#170 at ./reduce.jl:70 [inlined]
 [7] mapfoldl at ./reduce.jl:70 [inlined]
 [8] #mapreduce#174 at ./reduce.jl:203 [inlined]
 [9] mapreduce at ./reduce.jl:203 [inlined]
 [10] sum at ./reduce.jl:397 [inlined]
 [11] support_function at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/convexset.jl:775 [inlined]
 [12] is_primal_infeasible(::Array{Float64,1}, ::COSMO.Workspace{Float64}) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/infeasibility.jl:14
 [13] optimize!(::COSMO.Workspace{Float64}) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/solver.jl:135
 [14] optimize!(::Optimizer) at /home/guilhermebodin/.julia/packages/COSMO/Paq9I/src/MOIWrapper.jl:152
 [15] optimize!(::MathOptInterface.Utilities.CachingOptimizer{Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /home/guilhermebodin/.julia/packages/MathOptInterface/WXD0G/src/Utilities/cachingoptimizer.jl:189
 [16] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}) at /home/guilhermebodin/.julia/packages/MathOptInterface/WXD0G/src/Bridges/bridge_optimizer.jl:184
 [17] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /home/guilhermebodin/.julia/packages/MathOptInterface/WXD0G/src/Utilities/cachingoptimizer.jl:189
 [18] #optimize!#78(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Model, ::Nothing) at /home/guilhermebodin/.julia/packages/JuMP/iGamg/src/optimizer_interface.jl:141
 [19] optimize! at /home/guilhermebodin/.julia/packages/JuMP/iGamg/src/optimizer_interface.jl:111 [inlined] (repeats 2 times)
 [20] top-level scope at none:0

I am running with this Project.toml

(Teste) pkg> st
    Status `~/Documents/Github/Teste/Project.toml`
  [1e616198] COSMO v0.5.0
  [4076af6c] JuMP v0.20.0
  [b8f27783] MathOptInterface v0.9.2
  [c946c3f1] SCS v0.6.1
@migarstka
Copy link
Member

migarstka commented Sep 10, 2019

Thanks @guilhermebodin .
I fixed the bug in ed25b4b. If you want to try it, you can checkout master.

With this fix, I get:

------------------------------------------------------------------
          COSMO v0.5.0 - A Quadratic Objective Conic Solver
                         Michael Garstka
                University of Oxford, 2017 - 2019
------------------------------------------------------------------

Problem:  x  R^{3},
          constraints: A  R^{5x3} (5 nnz),
          matrix size to factor: 8x8 (18 nnz)
Sets:     DualExponentialCone of dim: 3
          ZeroSet of dim: 2
Settings: ϵ_abs = 1.0e-04, ϵ_rel = 1.0e-04,
          ϵ_prim_inf = 1.0e-06, ϵ_dual_inf = 1.0e-04,
          ρ = 0.1, σ = 1.0e-6, α = 1.6,
          max_iter = 2500,
          scaling iter = 10 (on),
          check termination every 40 iter,
          check infeasibility every 40 iter,
          KKT system solver: QDLDL
Setup Time: 0.27ms

Iter:	Objective:	Primal Res:	Dual Res:	Rho:
40	-6.4299e+02	9.9900e-01	1.0000e+00	1.0000e-01

------------------------------------------------------------------
>>> Results
Status: Primal_infeasible
Iterations: 40
Optimal objective: -642.9926
Runtime: 0.027s (27.28ms)

which is correct as you constrain u > 0 and the dual exponential cone is:

K_Dexp = { (u, v, w) : -u exp( v / u ) <= - exp(1) w, u < 0 }

@guilhermebodin
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants