PyPSA / linopy

Linear optimization with N-D labeled arrays in Python
https://linopy.readthedocs.io
MIT License
155 stars 43 forks source link

add MOSEK solver #189

Closed fneum closed 9 months ago

fneum commented 9 months ago

Solve a linear problem using the MOSEK solver.

category: commercial

https://www.mosek.com/

For more information on solver options, see https://docs.mosek.com/latest/pythonapi/parameters.html#doc-all-parameter-list

https://docs.mosek.com/latest/pythonapi/index.html#

Install with pip install mosek

Needs license setup (free academic): https://www.mosek.com/products/academic-licenses/

Tested locally and passed all tests. However, quadratic problems are not supported yet.

MOSEK does not understand "integer" as a label in the LP-file. It understands "general" however, and all other solvers also seem to. Not sure if you want to change the label completely, or have this as function argument.

MOSEK can also compute IIS (for later).

import pypsa

n = pypsa.examples.ac_dc_meshed()
n.optimize(solver_name='highs')
n.buses_t.marginal_price["London"]
n.generators_t.p
n.optimize(solver_name='mosek')
n.generators_t.p
n.buses_t.marginal_price["London"]
codecov[bot] commented 9 months ago

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (ae5d511) 87.62% compared to head (0b53dad) 89.15%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #189 +/- ## ========================================== + Coverage 87.62% 89.15% +1.53% ========================================== Files 14 15 +1 Lines 2989 3291 +302 Branches 669 753 +84 ========================================== + Hits 2619 2934 +315 + Misses 277 248 -29 - Partials 93 109 +16 ``` | [Files](https://app.codecov.io/gh/PyPSA/linopy/pull/189?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA) | Coverage Δ | | |---|---|---| | [linopy/io.py](https://app.codecov.io/gh/PyPSA/linopy/pull/189?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA#diff-bGlub3B5L2lvLnB5) | `87.90% <100.00%> (ø)` | | | [linopy/solvers.py](https://app.codecov.io/gh/PyPSA/linopy/pull/189?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA#diff-bGlub3B5L3NvbHZlcnMucHk=) | `89.23% <88.70%> (+9.66%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/PyPSA/linopy/pull/189/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fneum commented 9 months ago

closes #35

fneum commented 9 months ago

Thankful for an idea how I can stop CI for MOSEK, since license is commercial.

FabianHofmann commented 9 months ago

image

According to the docs, we should be able to set up a license in the GH secrets.