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

conflict with "ScikitLearn" package #64

Closed
brad-sturt opened this issue Jun 1, 2016 · 16 comments
Closed

conflict with "ScikitLearn" package #64

brad-sturt opened this issue Jun 1, 2016 · 16 comments

Comments

@brad-sturt
Copy link

There seems to be conflict between master branch of JuMPeR and ScikitLearn. When adding

using ScikitLearn

to an example (such as inventory or portfolio examples), I get the following error during the solve(model):

ERROR: LoadError: JuMPeR.BasicUncertaintySet has not implemented setup_set!
 in error at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
 in _solve_robust at /Users/brad-sturt/.julia/v0.4/JuMPeR/src/solve.jl:65
 in solve at /Users/brad-sturt/.julia/v0.4/JuMP/src/solvers.jl:114
 in include at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
 in include_from_node1 at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
 in process_options at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
 in _start at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
while loading /Users/brad-sturt/Code/Experiments/Jumper/inventory.jl, in expression starting on line 68

The examples work correctly when using ScikitLearn is removed. My package versions:

  • ScikitLearnBase: 0.0.5
  • ScikitLearn: 0.0.4
  • JuMPeR: 0.3.1+ (master)
  • JuMP: 0.13.1

Is this a known bug / is there a workaround? Sorry in advance if I am missing an obvious solution. Thanks alot!

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

I wonder if ScikitLearn defines something called Model...

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

Although it is getting through solve(::Model) so maybe not that.

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

If you are at a REPL with using JuMP, JuMPeR, ScikitLearn, and do methods JuMPeR.setup_set!, what do you see?

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

JuMPeR hardly exports anything so I'm not sure the root of this really...

@brad-sturt
Copy link
Author

In the REPL, I ran the following sequences of commands:

using JuMP, JuMPeR
model = RobustModel()
@variable(model,x)
@objective(model,Min,x)
@constraint(model, x>= 0)
@uncertain(model,u >= 0)
@constraint(model, x == u)
solve(model) # Solves correctly

Then, I tried again with ScikitLearn

using JuMP, JuMPeR, Scikitlearn
model = RobustModel()
@variable(model,x)
@objective(model,Min,x)
@constraint(model, x>= 0)
solve(model)  
# :Optimal

@uncertain(model,u >= 0)
@constraint(model, x == u)
solve(model) 
# ERROR: JuMPeR.BasicUncertaintySet has not implemented setup_set!
 in error at /Applications/Julia-0.4.3.app/Contents/Resources/julia/lib/julia/sys.dylib
 in _solve_robust at /Users/brad-sturt/.julia/v0.4/JuMPeR/src/solve.jl:65
 in solve at /Users/brad-sturt/.julia/v0.4/JuMP/src/solvers.jl:114

In both cases, JuMPeR.setup_set is a defined method, but JuMPeR.setup_set! is undefined.

@brad-sturt
Copy link
Author

(sorry, in the previous post, it should be ScikitLearn, not Scikitlearn)

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

error("$(typeof(us)) has not implemented setup_set!")

is the cause of setup_set! appearing - its just an incorrect error message.

So I guess what I meant before was methods(setup_set)

@brad-sturt
Copy link
Author

Sorry! Here are the methods.

julia> methods(JuMPeR.setup_set)
# 3 methods for generic function "setup_set":
setup_set(us::JuMPeR.BasicUncertaintySet, rm::JuMP.Model, idxs::Array{Int64,1}, scens_requested::Bool, other_prefs::Dict{Symbol,Any}) at /Users/brad-sturt/.julia/v0.4/JuMPeR/src/uncsets_basic.jl:82
setup_set(us::JuMPeR.BudgetUncertaintySet, rm::JuMP.Model, idxs::Array{Int64,1}, scens_requested::Bool, other_prefs::Dict{Symbol,Any}) at /Users/brad-sturt/.julia/v0.4/JuMPeR/src/uncsets_budget.jl:58
setup_set(us::JuMPeR.AbstractUncertaintySet, rm::JuMP.Model, idxs::Array{Int64,1}, scens_requested::Bool, other_prefs) at /Users/brad-sturt/.julia/v0.4/JuMPeR/src/uncsets.jl:33

@IainNZ
Copy link
Owner

IainNZ commented Jun 1, 2016

OK, good. So its falling through to the abstract error case, but the only reason it should do that is if other_prefs made it - I just noticed that the abstract one doesn't have that restriction.
The thing I don't get is,

  • That dictionary is defined here:
    prefs = Dict{Symbol,Any}([name => value for (name,value) in kwargs])
  • Why ScikitLearn being loaded would affect that

@brad-sturt
Copy link
Author

Interestingly, I found that the first file works correctly, whereas the second file crashes.

File1.jl

using JuMP, JuMPeR

model = RobustModel()
@variable(model, x)
@uncertain(model, u)
@constraint(model, u >= 0)
@constraint(model, u <= 1)
@constraint(model, x >= u)
@objective(model, Min, x)
@show solve(model)

using ScikitLearn

model = RobustModel()
@variable(model, x)
@uncertain(model, u)
@constraint(model, u >= 0)
@constraint(model, u <= 1)
@constraint(model, x >= u)
@objective(model, Min, x)
@show solve(model)

File2.jl

using JuMP, JuMPeR
using ScikitLearn

model = RobustModel()
@variable(model, x)
@uncertain(model, u)
@constraint(model, u >= 0)
@constraint(model, u <= 1)
@constraint(model, x >= u)
@objective(model, Min, x)
@show solve(model)

@brad-sturt
Copy link
Author

The following also works:

using JuMP, JuMPeR

model = RobustModel()
solve(model)

using ScikitLearn

model = RobustModel()
@variable(model, x)
@uncertain(model, u)
@constraint(model, u >= 0)
@constraint(model, u <= 1)
@constraint(model, x >= u)
@objective(model, Min, x)
@show solve(model)

It appears that is we run a solve() prior to loading ScikitLearn, the problem goes away.

@IainNZ
Copy link
Owner

IainNZ commented Jun 3, 2016

Can you try Julia 0.4.5?

@brad-sturt
Copy link
Author

Same problem

@brad-sturt
Copy link
Author

The workaround a couple posts above works for now. I'll keep looking through the code to see if I can figure out the problem.

@yeesian
Copy link
Collaborator

yeesian commented Oct 13, 2016

I can't reproduce this in #69. Is it still an issue?

@yeesian
Copy link
Collaborator

yeesian commented Oct 14, 2016

Closing stale issues. Re-open if it's still a problem.

@yeesian yeesian closed this as completed Oct 14, 2016
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

3 participants