-
Notifications
You must be signed in to change notification settings - Fork 53
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 quadratic objective support and 'direct' mode for MOSEK #226
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #226 +/- ##
==========================================
- Coverage 88.29% 85.86% -2.44%
==========================================
Files 15 15
Lines 3470 3572 +102
Branches 803 836 +33
==========================================
+ Hits 3064 3067 +3
- Misses 296 393 +97
- Partials 110 112 +2 ☔ View full report in Codecov by Sentry. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Great @ulfworsoe, thanks for the PR! could you add the implementation to the test routine? Just add a
if "mosek" in available_solvers:
params.append(("mosek", "direct"))
in the beginning of the test_optimization script
linopy/test/test_optimization.py
Line 29 in dd54ec1
linopy/io.py
Outdated
@@ -307,6 +307,80 @@ def to_file(m, fn, integer_label="general"): | |||
return fn | |||
|
|||
|
|||
def to_mosekpy(model, task): |
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.
Would it be possible to optionally set task. With the default None
, a new mosek model would be created which would be returned.
linopy/solvers.py
Outdated
# Gurobi solution format is not supported by MOSEK. | ||
# What is the warmstart file? A Gurobi .sol file? The gurobi | ||
# docs are a bit sparse on the format. Does it include dual | ||
# information? |
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.
This is probably a left-over, can you take that out?
A warmstart file is a simplex basis which can be used by some solvers as a starting point for the optimization. It is stored as a .bas
file. However I am not sure whether xpress
can handle these. Did you try out the original call?
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.
The original call used task.readdata
. I'll check, but I am reasonably sure that it will only read problem files (LP, MPS, etc). MOSEK does have a .bas file but that is an entirely different format.
But I implemented a .sol
reader here so I'll, have to fix that too.
And a hint: if you install pre-commit locally, the pre-commit bot does not interfere with your PR, as all stylistic changes are already applied before committing. |
Ah, that's what was happening. I should probably do that. |
Hey @ulfworsoe, this looks good. I will merge #223 before, and hope this does not lead to merge conflicts. |
@FabianHofmann I can see that the coverage tests fail. My guess is that the tests don't run for MOSEK at all because there is no license file. We have a similar issue in other places (the MOSEK Julia API, for example), and what we do in these cases is to use http://solve.mosek.com/web/ instead of solving locally. This doesn't require a license for small-ish problems. |
@ulfworsoe you let me know as soon as this is ready? Then I can take a final look and merge it. |
@FabianHofmann i think it is ready. The tests actually run and pass now. |
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.
@ulfworsoe thank you for the huge work! looks almost ready, just some minor points. Sorry that this takes so long. But ones it's there it will be quite stable.
@FabianHofmann I have removed the |
@ulfworsoe for some solvers I am keeping a github secret for the CI. Is something similar possible for mosek? |
Yes. Either a secret string that is passed to MOSEK or as a license file placed in |
@ulfworsoe it seems I have mosek license to the github! So if you don't mind I would pull everything into another branch to properly run the CI and then we can merge itl |
Please do. I'm working on a more permanent solution for using licenses in github CI so they won't have to be updated by hand regularly. |
Add quadratic objective support and 'direct' mode for MOSEK (superset of #226)
This PR adds a
to_mosekpy
(similar toto_gurobipy
) for passing a model to MOSEK without files.This should add support for quadratic objective terms.
I have attempted to fix support for reading solution (warmstart) files and disabled reading basis files since these are not directly supported by MOSEK.