Skip to content

Conversation

migarstka
Copy link
Contributor

I realised that currently there aren't any unit tests available for power cone problems. I added one feasible power cone problem to the contconic test problem set and tested with both COSMO and SCS#master.

I used the following test script:

using MathOptInterface, COSMO, SCS, Test, LinearAlgebra
const MOI = MathOptInterface
const MOIT = MOI.Test
const MOIB = MOI.Bridges

const MOIU = MOI.Utilities
MOIU.@model(COSMOModelData,
        (),
        (MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval),
        (MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives, MOI.SecondOrderCone,
         MOI.PositiveSemidefiniteConeSquare, MOI.PositiveSemidefiniteConeTriangle, MOI.ExponentialCone, MOI.DualExponentialCone),
        (MOI.PowerCone, MOI.DualPowerCone),
        (MOI.SingleVariable,),
        (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction),
        (MOI.VectorOfVariables,),
        (MOI.VectorAffineFunction,),);



# optimizer = MOIU.CachingOptimizer(MOIU.UniversalFallback(COSMOModelData{Float64}()),
#                                  COSMO.Optimizer());

optimizer = MOIU.CachingOptimizer(MOIU.UniversalFallback(COSMOModelData{Float64}()),
                                  SCS.Optimizer());

#MOI.set(optimizer, MOI.Silent(), true)
bridged = MOIB.full_bridge_optimizer(optimizer, Float64);

config = MOIT.TestConfig(atol=1e-3, rtol=1e-3)

exclude_conic_test_sets = ["lin", "soc", "rsoc", "geomean", "exp", "sdp", "rootdet", "logdet"]
@testset "Continuous conic problems" begin
    MOIT.contconictest(bridged, config, exclude_conic_test_sets)
end

The tests pass for COSMO but with SCS I get the following error:

pow1v: Error During Test at /Users/Micha/.julia/dev/MathOptInterface/src/Test/contconic.jl:1118
  Test threw exception
  Expression: MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.PowerCone)
  MethodError: Cannot `convert` an object of type Type{MathOptInterface.PowerCone} to an object of type DataType
  Closest candidates are:
    convert(::Type{T}, !Matched::T) where T at essentials.jl:154
  Stacktrace:
   [1] convert(::Type{Tuple{DataType}}, ::Tuple{UnionAll}) at ./essentials.jl:275 (repeats 2 times)
   [2] setindex!(::Dict{Tuple{DataType,DataType},Nothing}, ::Nothing, ::Tuple{DataType,UnionAll}) at ./dict.jl:373
   [3] push!(::Set{Tuple{DataType,DataType}}, ::Tuple{DataType,UnionAll}) at ./set.jl:48
   [4] fill_required_constraints!(::Set{Tuple{DataType,DataType}}, ::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{COSMOModelData{Float64}}},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::Type{MathOptInterface.VectorOfVariables}, ::Type{MathOptInterface.PowerCone}) at /Users/Micha/.julia/dev/MathOptInterface/src/Bridges/lazybridgeoptimizer.jl:71
   [5] update_constraint! at /Users/Micha/.julia/dev/MathOptInterface/src/Bridges/lazybridgeoptimizer.jl:84 [inlined]
   [6] supports_bridging_constraint(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{COSMOModelData{Float64}}},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::Type{MathOptInterface.VectorOfVariables}, ::Type{MathOptInterface.PowerCone}) at /Users/Micha/.julia/dev/MathOptInterface/src/Bridges/lazybridgeoptimizer.jl:110
   [7] supports_constraint at /Users/Micha/.julia/dev/MathOptInterface/src/Bridges/bridgeoptimizer.jl:303 [inlined]
   [8] _pow1test(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{COSMOModelData{Float64}}},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Test.TestConfig, ::Bool) at /Users/Micha/.julia/dev/MathOptInterface/src/Test/contconic.jl:1118
   [9] pow1vtest(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{COSMOModelData{Float64}}},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Test.TestConfig) at /Users/Micha/.julia/dev/MathOptInterface/src/Test/contconic.jl:1177
   [10] macro expansion at /Users/Micha/.julia/dev/MathOptInterface/src/Test/config.jl:53 [inlined]
   [11] macro expansion at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.1/Test/src/Test.jl:1083 [inlined]
   [12] powtest(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{COSMOModelData{Float64}}},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Test.TestConfig, ::Array{String,1}) at /Users/Micha/.julia/dev/MathOptInterface/src/Test/contconic.jl:1190

I am not sure whether that error is due to a mistake in

  • the test problem
  • the test script
  • or the SCS.jl wrapper

@odow
Copy link
Member

odow commented Jun 15, 2019

It's fixed on latest master:

25a9a25

@mlubin mlubin requested a review from chriscoey June 18, 2019 00:58
@mlubin mlubin added this to the v0.9 milestone Jun 18, 2019
@blegat
Copy link
Member

blegat commented Jun 23, 2019

A rebase should fix the CI failures

rtol = config.rtol
# Problem POW1
# max z
# st x^0.9 * y^(0.1) >= z (i.e (x, y, z) are in the 3d power cone with a=0.9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be clearer to have absolute value |z| on the RHS

@migarstka migarstka force-pushed the mg/pow_tests branch 2 times, most recently from da6868f to 754f85b Compare June 24, 2019 10:13
@test MOI.supports(model, MOI.ObjectiveSense())

if vecofvars
@test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.PowerCone{Float64})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this line? Should it be MOI.PowerCone or MOI.PowerCone{Float64}? Either way it seems to produce different errors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be PowerCone{typeof(a)} so PowerCone{Float64}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to solve it. There are some errors in the Bridges unit tests related to the fact that PowerCone is typed. I am not really sure, what's going on there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you post the errors or push the suggested fix so that I see the errors on Travis ?

@migarstka migarstka force-pushed the mg/pow_tests branch 2 times, most recently from 6bce5ae to e363958 Compare July 9, 2019 08:31
(MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives, MOI.SecondOrderCone,
MOI.ExponentialCone, MOI.PositiveSemidefiniteConeTriangle),
(),
(MOI.PowerCone),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possibly the source of the error because (MOI.PowerCone) isn't a tuple. Try (MOI.PowerCone,) instead.

@codecov-io
Copy link

Codecov Report

Merging #768 into master will decrease coverage by 0.22%.
The diff coverage is 59.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #768      +/-   ##
==========================================
- Coverage   94.26%   94.03%   -0.23%     
==========================================
  Files          59       59              
  Lines        6481     6523      +42     
==========================================
+ Hits         6109     6134      +25     
- Misses        372      389      +17
Impacted Files Coverage Δ
src/Test/contconic.jl 98.06% <59.52%> (-1.94%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd88e5d...bb51f8d. Read the comment docs.

@mlubin mlubin merged commit 303c070 into jump-dev:master Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants