PyPSA / PyPSA/pypsa-usa

Using Highs in cluster network optimizaion

Open
#421 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
148
Forks
55
Avg merge
2d 11h
Merged PRs (30d)
18

Description

Checklist
  • I am using the current master branch
  • I am running on an up-to-date pypsa-usa environment. Update via conda env update -f envs/environment.yaml
The Issue

When using highs in the cluster/simplify network scripts, an error is thrown by pyomo. If only highs is passed to the SolverFactory, the following error is thrown:

opt = po.SolverFactory("highs")
opt.solve(m)
Solver (asl) did not exit normally
  File "/home/trevor/master/pypsa-usa/workflow/scripts/cluster_network.py", line 247, in distribute_clusters
    results = opt.solve(m)
              ^^^^^^^^^^^^
  File "/home/trevor/master/pypsa-usa/workflow/scripts/cluster_network.py", line 317, in busmap_for_n_clusters
    n_clusters = distribute_clusters(
                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/trevor/master/pypsa-usa/workflow/scripts/cluster_network.py", line 379, in clustering_for_n_clusters
    busmap = busmap_for_n_clusters(
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevor/master/pypsa-usa/workflow/scripts/simplify_network.py", line 278, in <module>
    clustering = clustering_for_n_clusters(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
pyomo.common.errors.ApplicationError: Solver (asl) did not exit normally

If you pass the solver appsi_highs, as described by pyomo with the command pyomo help --solvers, the following error is raised:

opt = po.SolverFactory("appsi_highs")
if not opt.has_capability("quadratic_objective"):
...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'LegacySolver' object has no attribute 'has_capability'
Steps To Reproduce
  1. Change solver configuration to the following:
  solver:
    name: highs
    options: highs-default
  1. Run the workflow
Expected Behavior

The clustering optimization should run via ipopt if highs is selected for the quadratic optimization

https://github.com/PyPSA/pypsa-usa/blob/a05664935c3d0828b9dae46d64fcd4fca137d177/workflow/scripts/cluster_network.py#L186-L252

Error Message

No response

Anything else?

The pypsa-eur team updated their clustering to use linopy; would be nice to follow their implementation and allow us to drop the pyomo dependency

https://github.com/PyPSA/pypsa-eur/blob/51f8c2935ae3f80b15ad0ab71708ad006ad49da9/scripts/cluster_network.py#L172-L230

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the solver configuration in workflow/scripts/cluster_network.py and the workflow entry point in workflow/scripts/simplify_network.py. Read the clustering code around the reported lines and compare the linked pypsa-eur implementation. Done means clustering runs with highs selected for quadratic optimization, using ipopt as expected, or the proposed linopy migration is clearly scoped.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.