Skip to content
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

Debug info for unsupported constraints #2203

Merged

Conversation

yashvardhan747
Copy link
Contributor

@yashvardhan747 yashvardhan747 commented Mar 13, 2020

Closes #2143

@yashvardhan747
Copy link
Contributor Author

Right now it just prints out all the information of Unsupported constraints (NOT giving any error). I cant really figure put how can we put all this information in Error.

@yashvardhan747
Copy link
Contributor Author

yashvardhan747 commented Mar 24, 2020

This is supposed to work but I dont know why the julia session quit whenever I try to access function debug_string
It can also be seen by running tests.
Any help please!!

src/constraints.jl Outdated Show resolved Hide resolved
@yashvardhan747 yashvardhan747 force-pushed the Debug_info_for_unsupported_constraints branch from f8a061d to f405c13 Compare March 25, 2020 03:15
@yashvardhan747
Copy link
Contributor Author

yashvardhan747 commented Mar 25, 2020

@odow As you suggested I tried using sprint but after that I got StackOverflowError: by infinite recursive calling of function add_unsupported when the test runs

@odow
Copy link
Member

odow commented Mar 30, 2020

I'm not sure where the stack overflow comes. Perhaps you could try isolating the issue. Can you reproduce it outside this PR just by calling MOI.Bridges.debug with some arguments?

@yashvardhan747
Copy link
Contributor Author

yashvardhan747 commented Mar 31, 2020

I tried calling sprint(io -> MOI.Bridges.debug(bridged, F, S; io = io)) with same arguments with which it was called inside moi_add_constraint.
Its really weird, Julia session ends unexpectedly.

julia> using JuMP
[ Info: Precompiling JuMP [4076af6c-e467-56ae-b986-b466b2749572]

julia> function mock_factory()
                       mock = MOIU.MockOptimizer(MOIU.Model{Float64}(),
                                                 eval_variable_constraint_dual=false)
                       optimize!(mock) = MOIU.mock_optimize!(mock, [1.0],
                               (MOI.SingleVariable, MOI.GreaterThan{Float64}) => [2.0])
                       MOIU.set_mock_optimize!(mock, optimize!)
                       return mock
                   end
mock_factory (generic function with 1 method)

julia> model = Model(mock_factory)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Mock

julia> @variable(model, x)
x

julia> F = MOI.SingleVariable
MathOptInterface.SingleVariable

julia> include("/Users/yash/.julia/dev/JuMP/test/nonnegative_bridge.jl")

julia> S = Nonnegative
Nonnegative

julia> sprint(io -> MOI.Bridges.debug(backend(model).optimizer, F, S; io = io))

Julia has exited. Press Enter to start a new session.

but in place of using sprint if we use this, StackoverFlow happens.

julia>  io = IOBuffer()
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> MOIB.debug(backend(model).optimizer, F, S; io = io)
ERROR: StackOverflowError:
Stacktrace:
 [1] ht_keyindex2!(::Dict{MathOptInterface.Bridges.ConstraintNode,Nothing}, ::MathOptInterface.Bridges.ConstraintNode) at ./dict.jl:304

And when I am using functiondebug_string to call MOIB.debug, infite recursive calling to function add_unsupported causing StackoverFlow error

julia> function debug_string(b::MOIB.LazyBridgeOptimizer, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})
           io = IOBuffer()
           MOIB.debug(b, F, S; io = io)
           return String(resize!(io.data, io.size))
       end
debug_string (generic function with 1 method)

julia> debug_string(backend(model).optimizer, F, S)
ERROR: StackOverflowError:
Stacktrace:
 [1] objectid at ./reflection.jl:312 [inlined]
 [2] hash at ./hashing.jl:23 [inlined]
 [3] hash at ./hashing.jl:18 [inlined]
 [4] hashindex at ./dict.jl:168 [inlined]
 [5] ht_keyindex2!(::Dict{MathOptInterface.Bridges.ConstraintNode,Nothing}, ::MathOptInterface.Bridges.ConstraintNode) at ./dict.jl:308
 [6] setindex!(::Dict{MathOptInterface.Bridges.ConstraintNode,Nothing}, ::Nothing, ::MathOptInterface.Bridges.ConstraintNode) at ./dict.jl:381
 [7] push! at ./set.jl:48 [inlined]
 [8] add_unsupported(::MathOptInterface.Bridges.Graph, ::MathOptInterface.Bridges.ConstraintNode, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:162
 [9] add_unsupported(::MathOptInterface.Bridges.Graph, ::Array{MathOptInterface.Bridges.Edge,1}, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:129
 [10] add_unsupported at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:163 [inlined]
 [11] add_unsupported(::MathOptInterface.Bridges.Graph, ::MathOptInterface.Bridges.VariableNode, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:154
 [12] add_unsupported(::MathOptInterface.Bridges.Graph, ::Array{MathOptInterface.Bridges.Edge,1}, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:126
 [13] add_unsupported(::MathOptInterface.Bridges.Graph, ::MathOptInterface.Bridges.ConstraintNode, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:163
 ... (the last 5 lines are repeated 7018 more times)
 [35104] add_unsupported(::MathOptInterface.Bridges.Graph, ::Array{MathOptInterface.Bridges.Edge,1}, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:129
 [35105] add_unsupported at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:163 [inlined]
 [35106] add_unsupported(::MathOptInterface.Bridges.Graph, ::MathOptInterface.Bridges.VariableNode, ::Set{MathOptInterface.Bridges.VariableNode}, ::Set{MathOptInterface.Bridges.ConstraintNode}, ::Set{MathOptInterface.Bridges.ObjectiveNode}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:154
 [35107] debug_unsupported(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.MockOptimizer{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.Bridges.VariableNode) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:182
 [35108] #debug#106(::Base.GenericIOBuffer{Array{UInt8,1}}, ::typeof(MathOptInterface.Bridges.debug), ::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.MockOptimizer{MathOptInterface.Utilities.Model{Float64}}}, ::Type{MathOptInterface.SingleVariable}, ::Type{Nonnegative}) at /Users/yash/.julia/dev/MathOptInterface/src/Bridges/debug.jl:202
 [35109] #debug at ./none:0 [inlined]
 [35110] debug_string(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.MockOptimizer{MathOptInterface.Utilities.Model{Float64}}}, ::Type{MathOptInterface.SingleVariable}, ::Type{Nonnegative}) at ./none:3

@yashvardhan747
Copy link
Contributor Author

Tests are failing because its using outdated version of MathOptInterface, Tests will run successfully once the new version is released.

@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #2203 into master will increase coverage by 0.23%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2203      +/-   ##
==========================================
+ Coverage   91.15%   91.38%   +0.23%     
==========================================
  Files          42       42              
  Lines        4113     4189      +76     
==========================================
+ Hits         3749     3828      +79     
+ Misses        364      361       -3     
Impacted Files Coverage Δ
src/JuMP.jl 75.00% <ø> (+1.38%) ⬆️
src/constraints.jl 91.85% <ø> (ø)
src/Containers/nested_iterator.jl 84.61% <0.00%> (-3.39%) ⬇️
src/Containers/vectorized_product_iterator.jl 42.85% <0.00%> (-3.30%) ⬇️
src/Containers/SparseAxisArray.jl 79.16% <0.00%> (-1.36%) ⬇️
src/operators.jl 88.35% <0.00%> (-0.61%) ⬇️
src/callbacks.jl 100.00% <0.00%> (ø)
src/macros.jl 92.79% <0.00%> (+0.17%) ⬆️
src/variables.jl 96.13% <0.00%> (+0.25%) ⬆️
... and 8 more

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 0ba22ad...afcd15f. Read the comment docs.

@odow odow requested a review from blegat July 1, 2020 13:29
@blegat blegat merged commit 70fe5a1 into jump-dev:master Jul 1, 2020
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.

Debug info for unsupported constraints
3 participants