PyPSA / linopy

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

add COPT solver #190

Closed fneum closed 9 months ago

fneum commented 9 months ago

closes #186

https://shanshu.ai/copt

Documentation: https://guide.coap.online/copt/en-doc/index.html

Install with pip install coptpy

Commercial, free academic license.

Tested locally and passed all tests. However, quadratic problems are not supported yet (LP file format issues?).

Small problem instances do not require a license. Hence, this solver can be tested in CI.

COPT could also calculate 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='copt', solver_options=dict(LpMethod=2))
n.generators_t.p
n.buses_t.marginal_price["London"]
codecov[bot] commented 9 months ago

Codecov Report

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

Comparison is base (c1186a3) 89.22% compared to head (0557525) 89.25%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #190 +/- ## ========================================== + Coverage 89.22% 89.25% +0.03% ========================================== Files 15 15 Lines 3136 3182 +46 Branches 723 731 +8 ========================================== + Hits 2798 2840 +42 - Misses 234 237 +3 - Partials 104 105 +1 ``` | [Files](https://app.codecov.io/gh/PyPSA/linopy/pull/190?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA) | Coverage Δ | | |---|---|---| | [linopy/solvers.py](https://app.codecov.io/gh/PyPSA/linopy/pull/190?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PyPSA#diff-bGlub3B5L3NvbHZlcnMucHk=) | `90.10% <91.30%> (+0.16%)` | :arrow_up: |

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

FabianHofmann commented 9 months ago

Wow, super nice! I hope I can review soon, but it looks very good on the first glimpse (same for #189, #188 )

loongmxbt commented 8 months ago

Hi, copt also support quadratic problem, hope to add to quadratic solvers option.

ValueError: Solver copt does not support quadratic problems