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

Trouble fixing variable in linear constraint #2072

Closed
adrien-le-franc opened this issue Sep 30, 2019 · 3 comments
Closed

Trouble fixing variable in linear constraint #2072

adrien-le-franc opened this issue Sep 30, 2019 · 3 comments

Comments

@adrien-le-franc
Copy link

adrien-le-franc commented Sep 30, 2019

Hi,

I need to solve a sequence of LP with a changing constant value in a linear constraint. I picked a solution from the doc at http://www.juliaopt.org/JuMP.jl/v0.20.0/constraints/ but I got an error which I could summarize in this example:

using JuMP
using Clp

m = Model(with_optimizer(Clp.Optimizer, LogLevel=0))
@variable(m, 0 <= x)
@variable(m, xmax)
@constraint(m, x <= xmax)
fix(m[:xmax], 1.)
@objective(m, Min, x)
optimize!(m)

this gives:

ERROR: UndefVarError: getconstant not defined
Stacktrace:
 [1] add_linear_constraints(::Clp.Optimizer, ::Array{MathOptInterface.ScalarAffineFunction{Float64},1}, ::Array{MathOptInterface.LessThan{Float64},1}) at /opt/julia/packages/LinQuadOptInterface/ZMx9f/src/constraints/scalaraffine.jl:79
 [2] add_constraints(::Clp.Optimizer, ::Array{MathOptInterface.ScalarAffineFunction{Float64},1}, ::Array{MathOptInterface.LessThan{Float64},1}) at /opt/julia/packages/LinQuadOptInterface/ZMx9f/src/constraints/scalaraffine.jl:62
 [3] add_constraints(::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::Array{MathOptInterface.ScalarAffineFunction{Float64},1}, ::Array{MathOptInterface.LessThan{Float64},1}) at /opt/julia/packages/MathOptInterface/4hMCx/src/Bridges/bridge_optimizer.jl:1011
 [4] copy_constraints(::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.LessThan{Float64}},1}) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/copy.jl:228
 [5] pass_constraints(::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{DataType,1}, ::Array{Array{T,1} where T,1}, ::Array{DataType,1}, ::Array{Array{T,1} where T,1}, ::typeof(MathOptInterface.Utilities.copy_constraints), ::typeof(MathOptInterface.set)) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/copy.jl:265
 [6] pass_constraints(::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{DataType,1}, ::Array{Array{T,1} where T,1}, ::Array{DataType,1}, ::Array{Array{T,1} where T,1}) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/copy.jl:240
 [7] default_copy_to(::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/copy.jl:340
 [8] #automatic_copy_to#97 at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/copy.jl:15 [inlined]
 [9] #automatic_copy_to at ./none:0 [inlined]
 [10] #copy_to#1 at /opt/julia/packages/MathOptInterface/4hMCx/src/Bridges/bridge_optimizer.jl:228 [inlined]
 [11] (::getfield(MathOptInterface, Symbol("#kw##copy_to")))(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::MathOptInterface.Bridges.LazyBridgeOptimizer{Clp.Optimizer}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}) at ./none:0
 [12] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/cachingoptimizer.jl:149
 [13] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /opt/julia/packages/MathOptInterface/4hMCx/src/Utilities/cachingoptimizer.jl:185
 [14] #optimize!#78(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Model, ::Nothing) at /opt/julia/packages/JuMP/iGamg/src/optimizer_interface.jl:141
 [15] optimize! at /opt/julia/packages/JuMP/iGamg/src/optimizer_interface.jl:111 [inlined] (repeats 2 times)
 [16] top-level scope at none:0

I also get this error with CPLEX so it seems solver independent. I am using JuMP v0.20.0 with Julia 1.1.1

I had a look at https://github.com/JuliaOpt/LinQuadOptInterface.jl/blob/master/src/constraints/scalaraffine.jl where the error comes from, not sure wether if it should be a JuMP or LinQuadOptInterface issue

@adrien-le-franc adrien-le-franc changed the title Hi, Trouble fixing variable in linear constraint Sep 30, 2019
@blegat
Copy link
Member

blegat commented Sep 30, 2019

CPLEX and Clp have not yet been updated to JuMP v0.20/MOI v0.9, see jump-dev/MathOptInterface.jl#736 for an up to date list of solvers that have been ported.

@adrien-le-franc
Copy link
Author

Thanks for your help, I moved back to JuMP v0.19 until the update. Perhaps CPLEX and Clp should be temporally removed from the list of currently supported solver on the v0.20 documentation

@blegat
Copy link
Member

blegat commented Nov 12, 2019

CPLEX and Clp have now been updated thanks to @odow and @mtanneau

@blegat blegat closed this as completed Nov 12, 2019
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

2 participants