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 relaxation kwarg to solve #597

Merged
merged 3 commits into from
Oct 8, 2015
Merged

Add relaxation kwarg to solve #597

merged 3 commits into from
Oct 8, 2015

Conversation

joehuchette
Copy link
Contributor

Ref #587, still open to a bikeshed to the naming convention if @IainNZ wants to chime in.

@defVar(m, -2 <= t <= -1, SemiInt)

@setObjective(m, Min, x + y + z + w + v - t)
solve(m, relaxation=true)
Copy link
Member

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?

Copy link
Contributor Author

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).

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works with me

@mlubin
Copy link
Member

mlubin commented Oct 6, 2015

The name relaxation still doesn't sit well with me. It will definitely send some people to the docs asking "which relaxation?"

@joehuchette
Copy link
Contributor Author

Not sure that's a bad thing, or avoidable, really. I'm warming up to continuous_relaxation, though it doesn't fix the "lookup in the docs" issue.

@IainNZ
Copy link
Collaborator

IainNZ commented Oct 7, 2015

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 relaxation=:Continuous I guess if we want to avoid booleans.

@@ -168,6 +170,8 @@ function solve(m::Model; suppress_warnings=false,
end
end

relaxation && (m.internalModelLoaded = false)
Copy link
Member

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.

@mlubin
Copy link
Member

mlubin commented Oct 8, 2015

Let's just go with relaxation=true for now, can always deprecate later. Needs docs before merging.

joehuchette added a commit that referenced this pull request Oct 8, 2015
Add relaxation kwarg to solve
@joehuchette joehuchette merged commit 6398764 into master Oct 8, 2015
@@ -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)]``.
Copy link
Member

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.

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.

3 participants