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

MOI looking for MIP in LP problem #1554

Closed
jd-lara opened this issue Oct 17, 2018 · 8 comments
Closed

MOI looking for MIP in LP problem #1554

jd-lara opened this issue Oct 17, 2018 · 8 comments

Comments

@jd-lara
Copy link
Contributor

jd-lara commented Oct 17, 2018

I am trying to solve an LP problem with several linear solvers, GLPK and Clp and I am getting this error as if the solver was trying to find Integer Variables. However, if I use Ipopt then the model runs which indicate is not a model specification problem. I have checked that all my variables have a start value consistently also.

MethodError: no method matching add_mip_starts!(::Clp.Optimizer, ::Array{Int64,1}, ::Array{Float64,1})

Stacktrace:
 [1] set(::Clp.Optimizer, ::MathOptInterface.VariablePrimalStart, ::Array{MathOptInterface.VariableIndex,1}, ::Array{Float64,1}) at /Users/jdlara/.julia/packages/LinQuadOptInterface/RY8jg/src/variables.jl:189
 [2] _pass_attributes(::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractVariableAttribute,1}, ::Tuple{DataType}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::typeof(MathOptInterface.set)) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/copy.jl:59
 [3] pass_attributes at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/copy.jl:46 [inlined]
 [4] pass_attributes at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/copy.jl:44 [inlined]
 [5] default_copy_to(::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/copy.jl:101
 [6] #copy_to#71 at /Users/jdlara/.julia/packages/LinQuadOptInterface/RY8jg/src/copy.jl:6 [inlined]
 [7] (::getfield(MathOptInterface, Symbol("#kw##copy_to")))(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}) at ./none:0
 [8] attachoptimizer!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/cachingoptimizer.jl:125
 [9] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/cachingoptimizer.jl:158
 [10] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}},MathOptInterface.Bridges.AllBridgedConstraints{Float64}}) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Bridges/bridgeoptimizer.jl:73
 [11] #optimize!#94(::Bool, ::Function, ::Model, ::Nothing) at /Users/jdlara/.julia/packages/JuMP/LjMor/src/optimizer_interface.jl:65
 [12] optimize! at /Users/jdlara/.julia/packages/JuMP/LjMor/src/optimizer_interface.jl:42 [inlined] (repeats 2 times)
 [13] top-level scope at In[16]:1

Trying with ECOS gives a different error

MethodError: no method matching allocate(::ECOS.Optimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex, ::Float64)
Closest candidates are:
  allocate(!Matched::MathOptInterface.Utilities.AbstractModel, ::Any...) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/model.jl:339
  allocate(!Matched::MathOptInterface.Utilities.MockOptimizer, ::Union{AbstractConstraintAttribute, AbstractModelAttribute, AbstractOptimizerAttribute, AbstractVariableAttribute}, ::Union{VariableIndex, ConstraintIndex}, ::Any) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/mockoptimizer.jl:286
  allocate(::MathOptInterface.ModelLike, ::Union{AbstractConstraintAttribute, AbstractVariableAttribute}, !Matched::Array{T,1} where T, !Matched::Array{T,1} where T) at /Users/jdlara/.julia/packages/MathOptInterface/62rhX/src/Utilities/copy.jl:156
  ...
@blegat
Copy link
Member

blegat commented Oct 18, 2018

Starting values are not implemented for ECOS yet, the error message says that if you use MOI master :)

cc @IssamT for Clp

@jd-lara
Copy link
Contributor Author

jd-lara commented Oct 18, 2018

@blegat thanks, I am using the tagged version of JuMP. Something happened that all the LP solvers (that support start values) broke.

@IssamT
Copy link
Contributor

IssamT commented Oct 18, 2018

@jd-lara, could you please send a MWE reproducing this error?

@IssamT
Copy link
Contributor

IssamT commented Oct 18, 2018

Oh, I just noticed that you are using MOI. Clp and GLPK implement the LQOI interface and apparently they haven't implemented add_mip_starts! yet.

ECOS gives a different error because it doesn't use LQOI for implementing MOI.

@IssamT
Copy link
Contributor

IssamT commented Oct 24, 2018

While trying to reproduce this error, I had a different error because I didn't set the start of all variables.

ERROR: LoadError: KeyError: key MathOptInterface.VariableIndex(1) not found
Stacktrace:
 [1] copy(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(MathOptInterface.get),Tuple{Base.RefValue{MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}},Base.RefValue{MathOptInterface.VariablePrimalStart},Array{MathOptInterface.VariableIndex,1}}}) at ./dict.jl:478
 [2] materialize at ./broadcast.jl:724 [inlined]
 [3] get(::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::MathOptInterface.VariablePrimalStart, ::Array{MathOptInterface.VariableIndex,1}) at /Users/itahiri/.julia/dev/MathOptInterface/src/attributes.jl:195
 [4] _pass_attributes(::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractVariableAttribute,1}, ::Tuple{DataType}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::typeof(MathOptInterface.set)) at /Users/itahiri/.julia/dev/MathOptInterface/src/Utilities/copy.jl:62
 [5] pass_attributes(::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.VariableIndex,1}, ::Function) at /Users/itahiri/.julia/dev/MathOptInterface/src/Utilities/copy.jl:49
 [6] pass_attributes at /Users/itahiri/.julia/dev/MathOptInterface/src/Utilities/copy.jl:44 [inlined]
 [7] default_copy_to(::Clp.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool) at /Users/itahiri/.julia/dev/MathOptInterface/src/Utilities/copy.jl:104
 [8] #copy_to#71 at /Users/itahiri/.julia/dev/LinQuadOptInterface/src/copy.jl:7 [inlined]

The following example raises that error:

using JuMP
using Clp

m = Model(with_optimizer(Clp.Optimizer))

@variable(m, 0 <= x <= 1)
@variable(m, 0 <= y <= 1)
@variable(m, 0 <= z <= 1, start=1.0)
@constraint(m, x + y + z >= 1)
@objective(m, Min, 2x + y + z)

JuMP.optimize!(m)

The error I was getting is due to the fact MOI's default_copy assumes that if a variables has an attribute then this attribute should be defined for all the variables. Isn't this a strong assumption?

When defining the start value of all variables, then I get the same error in the issue and it should be fixed with this PR jump-dev/Clp.jl#44

@blegat
Copy link
Member

blegat commented Oct 24, 2018

The error I was getting is due to the fact MOI's default_copy assumes that if a variables has an attribute then this attribute should be defined for all the variables. Isn't this a strong assumption?

See #1460

@odow
Copy link
Member

odow commented Nov 10, 2018

Is this now a duplicate of #1460?

@blegat
Copy link
Member

blegat commented Nov 10, 2018

I have opened issues to corresponding repo:
jump-dev/ECOS.jl#79
jump-dev/Clp.jl#44
jump-dev/GLPK.jl#82
JuliaOpt/LinQuadOptInterface.jl#70

We can close this.

@blegat blegat closed this as completed Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants