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

Fix bug in relax_integrality #2666

Merged
merged 2 commits into from
Aug 20, 2021
Merged

Fix bug in relax_integrality #2666

merged 2 commits into from
Aug 20, 2021

Conversation

odow
Copy link
Member

@odow odow commented Aug 15, 2021

relax_integrality doesn't work for solvers in direct mode not supporting VariablePrimalStart:

julia> model = direct_model(GLPK.Optimizer())
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: DIRECT
Solver name: GLPK

julia> @variable(model, x, Int)
x

julia> optimize!(model)

julia> undo = JuMP.relax_integrality(model)
ERROR: ArgumentError: ModelLike of type GLPK.Optimizer does not support accessing the attribute MathOptInterface.VariablePrimalStart()
Stacktrace:
  [1] get_fallback(model::GLPK.Optimizer, attr::MathOptInterface.VariablePrimalStart, args::MathOptInterface.VariableIndex)
    @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/attributes.jl:296
  [2] get(model::GLPK.Optimizer, attr::MathOptInterface.VariablePrimalStart, args::MathOptInterface.VariableIndex)
    @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/attributes.jl:293
  [3] get(model::Model, attr::MathOptInterface.VariablePrimalStart, v::VariableRef)
    @ JuMP ~/.julia/packages/JuMP/b3hGi/src/JuMP.jl:1234
  [4] start_value(v::VariableRef)
    @ JuMP ~/.julia/packages/JuMP/b3hGi/src/variables.jl:911
  [5] _info_from_variable(v::VariableRef)
    @ JuMP ~/.julia/packages/JuMP/b3hGi/src/variables.jl:1247
  [6] #34
    @ ~/.julia/packages/JuMP/b3hGi/src/variables.jl:1334 [inlined]
  [7] iterate
    @ ./generator.jl:47 [inlined]
  [8] _collect(c::Vector{VariableRef}, itr::Base.Generator{Vector{VariableRef}, JuMP.var"#34#35"}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:691
  [9] collect_similar
    @ ./array.jl:606 [inlined]
 [10] map
    @ ./abstractarray.jl:2294 [inlined]
 [11] relax_integrality(model::Model)
    @ JuMP ~/.julia/packages/JuMP/b3hGi/src/variables.jl:1333
 [12] top-level scope
    @ REPL[13]:1

If solvers don't support querying start values, relax_integrality
will error. In practice, the start value isn't used.
@odow odow added the Type: Bug label Aug 15, 2021
@codecov
Copy link

codecov bot commented Aug 15, 2021

Codecov Report

Merging #2666 (4d30472) into master (fe1f0d1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2666   +/-   ##
=======================================
  Coverage   93.51%   93.51%           
=======================================
  Files          44       44           
  Lines        5549     5551    +2     
=======================================
+ Hits         5189     5191    +2     
  Misses        360      360           
Impacted Files Coverage Δ
src/variables.jl 98.78% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe1f0d1...4d30472. Read the comment docs.

@odow odow merged commit 0975852 into master Aug 20, 2021
@odow odow deleted the od/relax_integrality branch August 20, 2021 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant