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

Add fix_discrete_variables for computing the dual of a MIP #3208

Merged
merged 8 commits into from
Feb 3, 2023

Conversation

odow
Copy link
Member

@odow odow commented Feb 1, 2023

This comes up quite often on discourse etc, and @jd-lara has written custom code to do this in PowerSimulations etc.

x-ref: #2348 (comment)

Open to bike-shed. I considered making this a separate relax_integrality_and_fix function instead of the keyword argument, but the overlap between the two methods is quite large, so it seemed to make more sense as an option.

Docs: https://jump.dev/JuMP.jl/previews/PR3208/tutorials/linear/mip_duality/

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 98.07% // Head: 98.07% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (0009f9e) compared to base (57785ae).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3208   +/-   ##
=======================================
  Coverage   98.07%   98.07%           
=======================================
  Files          34       34           
  Lines        4621     4631   +10     
=======================================
+ Hits         4532     4542   +10     
  Misses         89       89           
Impacted Files Coverage Δ
src/variables.jl 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mlubin
Copy link
Member

mlubin commented Feb 2, 2023

The functionality makes sense but the naming is too confusing. Mathematically there's no relaxation (i.e., enlarging the feasible region) happening when you do this. You're actually restricting the feasible region by fixing variables. I don't have a great suggestion off the top of my head.

@odow
Copy link
Member Author

odow commented Feb 2, 2023

What about a new function like fix_discrete_variables?

Gurobi calls this fixmodel: https://www.gurobi.com/documentation/9.5/refman/c_fixmodel.html

@mlubin
Copy link
Member

mlubin commented Feb 2, 2023

fix_discrete_variables sgtm

src/variables.jl Outdated Show resolved Hide resolved
@odow odow changed the title Add fix kwarg to relax_integrality for fixing the discrete values of a MIP Add fix_discrete_variables for computing the dual of a MIP Feb 2, 2023
@odow
Copy link
Member Author

odow commented Feb 2, 2023

I've left the implementation as a single (now private) function, with two public functions as the API.

I can duplicate the code if people would prefer.

src/variables.jl Outdated Show resolved Hide resolved
Co-authored-by: Miles Lubin <[email protected]>
@odow odow merged commit 18f48b5 into master Feb 3, 2023
@odow odow deleted the od/relax-and-fix branch February 3, 2023 03:26
x binary
```
"""
function fix_discrete_variables(var_value::Function, model::Model)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont know if the ::Function was on purpose, but it will force nonspecialize: https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing
maybe:

function fix_discrete_variables(var_value::F, model::Model) where {F<:Function}

fix_discrete_variables(model::Model) = fix_discrete_variables(value, model)

function _relax_or_fix_integrality(
var_value::Union{Nothing,Function},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to specialize here at least since the function is called a lot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen this be a performance issue on large models?

@odow
Copy link
Member Author

odow commented Feb 17, 2023

This comes up quite often on discourse etc

Speak of the devil: https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants