jump-dev / Xpress.jl

A Julia interface to the FICO Xpress Optimization suite
https://www.fico.com/en/products/fico-xpress-optimization
65 stars 30 forks source link

prob not defined in utils.jl when creating empty model #125

Closed NLaws closed 3 years ago

NLaws commented 3 years ago

I'm not sure if this exception is hiding something else going on, but there is a variable undefined in https://github.com/jump-dev/Xpress.jl/blob/e325c688e32ebe819cb4cb4db358635e0144f90a/src/utils.jl#L99

 exception =
UndefVarError: prob not defined
Stacktrace:
 [1] macro expansion at /root/.julia/packages/Xpress/ab5Cg/src/utils.jl:99 [inlined]
 [2] createprob(::Base.RefValue{Ptr{Nothing}}) at /root/.julia/packages/Xpress/ab5Cg/src/api.jl:56
 [3] Xpress.XpressProblem(; logfile::String) at /root/.julia/packages/Xpress/ab5Cg/src/helper.jl:67
 [4] XpressProblem at /root/.julia/packages/Xpress/ab5Cg/src/helper.jl:66 [inlined]
 [5] empty!(::Xpress.Optimizer) at /root/.julia/packages/Xpress/ab5Cg/src/MOI/MOI_wrapper.jl:281
 [6] Xpress.Optimizer(; kwargs::Base.Iterators.Pairs{Symbol,Real,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:MAXTIME, :MIPRELSTOP, :OUTPUTLOG),Tuple{Int64,Float64,Int64}}}) at /root/.julia/packages/Xpress/ab5Cg/src/MOI/MOI_wrapper.jl:271
 [7] xpress_model(::Int64, ::Float64) at /opt/julia_src/xpress_model.jl:31

Item [7] is here, which is:

m = direct_model(Xpress.Optimizer(MAXTIME=-MAXTIME, MIPRELSTOP=MIPRELSTOP, OUTPUTLOG = 0))

This is happening in the REopt Lite API, which uses Xpress.jl to solve 100's to 10,000's of problems per day. It does not happen consistently and so is difficult to recreate. We are running multiple Julia pods managed by Kubernetes, so I'm also suspect of some threading issues, though the pods should be isolated from each other. Any insights that the Xpress.jl developers might have would be very welcome!

kdheepak commented 3 years ago

It looks like when createprob is called, Xpress is not returning 0, meaning something has gone wrong (possibly related to threading issues as you mentioned).

When a non-zero is returned, the macro in Xpress.jl (which I originally wrote) tries to get the error message from Xpress. And this macro assumes that the prob exists in the scope where @checked is expanded and hence is not doing the right thing inside the body of the createprob(_probholder) function.

This is why you get prob not defined. I've made a PR to fix that. When that PR is merged you should be able run it again and it should display an error message from Xpress. Maybe that'll help shine some light on what is going on.

NLaws commented 3 years ago

Thank you @kdheepak !

kdheepak commented 3 years ago

@NLaws the PR has been merged. You can now use the default master branch and it should work. Let us know if you run into any other issues.