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

Binary Variables with Bounds #242

Closed
ccoffrin opened this issue Jun 6, 2019 · 1 comment · Fixed by #261
Closed

Binary Variables with Bounds #242

ccoffrin opened this issue Jun 6, 2019 · 1 comment · Fixed by #261
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API

Comments

@ccoffrin
Copy link

ccoffrin commented Jun 6, 2019

As discussed in this related issue, lanl-ansi/PowerModels.jl#535

A code like the following (untested) appears to result in an error,

using JuMP; using CPLEX
m = Model()
@variable(m, x, binary=true, lower_bound=0, upper_bound=1)
optimize!(m, with_optimizer(CPLEX.Optimizer))
@remi-garcia
Copy link
Contributor

remi-garcia commented Jun 6, 2019

Tested right after a using Pkg; Pkg.update:

julia> using JuMP; using CPLEX

julia> m = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(m, x, binary=true, lower_bound=0, upper_bound=1)
x

julia> optimize!(m, with_optimizer(CPLEX.Optimizer))
ERROR: Cannot set bounds because variable is of type: BINARY.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] add_constraints(::CPLEX.Optimizer, ::Array{MathOptInterface.SingleVariable,1}, ::Array{MathOptInterface.GreaterThan{Float64},1}) at /home/remi/.julia/packages/LinQuadOptInterface/ZMx9f/src/constraints/singlevariable.jl:128
 [3] add_constraints(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::Array{MathOptInterface.SingleVariable,1}, ::Array{MathOptInterface.GreaterThan{Float64},1}) at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:342
 [4] copyconstraints!(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Type{MathOptInterface.SingleVariable}, ::Type{MathOptInterface.GreaterThan{Float64}}) at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:157
 [5] default_copy_to(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool) at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:200
 [6] #automatic_copy_to#61 at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:15 [inlined]
 [7] #automatic_copy_to at ./none:0 [inlined]
 [8] #copy_to#1 at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:91 [inlined]
 [9] (::getfield(MathOptInterface, Symbol("#kw##copy_to")))(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}) at ./none:0
 [10] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}) at /home/remi/.julia/packages/MathOptInterface/C3lip/src/Utilities/cachingoptimizer.jl:130
 [11] attach_optimizer(::Model) at /home/remi/.julia/packages/JuMP/tyMag/src/optimizer_interface.jl:32
 [12] #optimize!#79(::Bool, ::Bool, ::Function, ::Model, ::OptimizerFactory) at /home/remi/.julia/packages/JuMP/tyMag/src/optimizer_interface.jl:119
 [13] optimize!(::Model, ::OptimizerFactory) at /home/remi/.julia/packages/JuMP/tyMag/src/optimizer_interface.jl:105
 [14] top-level scope at none:0```

@odow odow added the Wrapper: MathOptInterface Relates to the MathOptInterface API label Oct 30, 2019
@odow odow mentioned this issue Nov 4, 2019
16 tasks
@odow odow closed this as completed in #261 Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API
Development

Successfully merging a pull request may close this issue.

3 participants