-
-
Notifications
You must be signed in to change notification settings - Fork 399
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 relaxation kwarg to solve #597
Conversation
@defVar(m, -2 <= t <= -1, SemiInt) | ||
|
||
@setObjective(m, Min, x + y + z + w + v - t) | ||
solve(m, relaxation=true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you call solve()
again with relaxation=false
? Do we clear the relaxation data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work (returns infeasible with CPLEX).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity, what about setting internalModelLoaded=false
after a solve with relaxation=true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works with me
c0ba823
to
285cc24
Compare
The name |
Not sure that's a bad thing, or avoidable, really. I'm warming up to |
I think there is no fixing the "lookup in docs" situation. But, of course, someone would have to look in the docs to find it in the first place. I'd say relaxing integrality is by the most common usage for people who use JuMP, and I don't think it'll be scrutinized heavily. If we get into more general relaxations later, we can cross that bridge then. One option is |
@@ -168,6 +170,8 @@ function solve(m::Model; suppress_warnings=false, | |||
end | |||
end | |||
|
|||
relaxation && (m.internalModelLoaded = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here like: # don't keep relaxed model in memory
? I had trouble reading this line on the first try.
Let's just go with |
Add relaxation kwarg to solve
@@ -43,7 +43,7 @@ Methods | |||
* ``MathProgBase.getsolvetime(m::Model)`` - returns the solve time from the solver if it is implemented. | |||
* ``MathProgBase.getnodecount(m::Model)`` - returns the number of explored branch-and-bound nodes, if it is implemented. | |||
* ``getInternalModel(m::Model)`` - returns the internal low-level ``AbstractMathProgModel`` object which can be used to access any functionality that is not exposed by JuMP. See the MathProgBase `documentation <http://mathprogbasejl.readthedocs.org/en/latest/mathprogbase.html#low-level-interface>`_. | |||
* ``solve(m::Model; suppress_warnings=false)`` - solves the model using the selected solver (or a default for the problem class), and takes two optional arguments that are disabled by default. Setting ``suppress_warnings`` to ``true`` will suppress all JuMP-specific output (e.g. warnings about infeasibility and lack of dual information) but will not suppress solver output (which should be done by passing options to the solver). | |||
* ``solve(m::Model; suppress_warnings=false, relaxation=false)`` - solves the model using the selected solver (or a default for the problem class), and takes two optional arguments that are disabled by default. Setting ``suppress_warnings`` to ``true`` will suppress all JuMP-specific output (e.g. warnings about infeasibility and lack of dual information) but will not suppress solver output (which should be done by passing options to the solver). Setting ``relaxation=true`` solves the standard continuous relaxation for the model: that is, integrality is dropped, SOS constraints are not enforced, and semi-continuous and semi-integer variables with bounds ``[l,u]`` are replaced with bounds ``[min(l,0),max(u,0)]``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should clarify that SOS is special ordered set. Many people will read it as sum of squares.
Ref #587, still open to a bikeshed to the naming convention if @IainNZ wants to chime in.