0

I am trying to use HiGHS solver for PyPSA-Eur. By setting it in config.yaml like:

  solver:
    name: highs
    options: {}

It throws following error:

RuntimeError: Attempting to use an unavailable solver.

The SolverFactory was unable to create the solver "highs" and returned an UnknownSolver object. This error is raised at the point where the UnknownSolver object was used as if it were valid (by calling method "has_capability").

The original solver was created with the following parameters: executable: highs type: highs _args: () options: {}

while creating the environment highspy gets installed properly and no issues there.

While in the pypsa-eur environment if i do python -c "import highspy" it does not throw any error that means highspy is there to be used.

How can we configure pypsa to use HiGHS as a solver?

Dakait
  • 2,531
  • 1
  • 25
  • 43

3 Answers3

2

It should work if you use

  solver:
    name: highs
    options: highs-default

First line defines the solver, second line defines the options to use for the solver.

euronion
  • 1,142
  • 6
  • 14
  • thanks, i tried by specifying `highs-default` instead of `{}` but it throws same error. I think the exception occurs at the step where solver instance is created. `The SolverFactory was unable to create the solver "highs" ` – Dakait Aug 03 '23 at 20:08
1

Should you be on Windows, it might be that you have to install HiGHS binaries manually. Not sure.

https://ergo-code.github.io/HiGHS/stable/installation/

  • I am using Ubuntu. I have tried building highs from source and adding it to the path but it still gives an error. Seems like a bug in pypsa itself and/or the interface they are using to communicate with HiGHS – Dakait Aug 04 '23 at 11:12
1

Had to build HiGHS from https://github.com/ERGO-Code/HiGHS and it worked. Also HiGHS shared lib path has to be included in LD_LIBRARY_PATH so the dynamically linked lib can be found.

After building HiGHS from source the executable can be found in:

/HiGHS/build/bin/

One might need to create a symlink or provide a complete path to the executable.

It seems that HiGHS was not able to handle network clustering in PyPSA-Eur

if not opt.has_capability("quadratic_objective"):
        logger.warning(
            f"The configured solver `{solver_name}` does not support quadratic objectives. Falling back to `ipopt`."
        )
        opt = po.SolverFactory("ipopt")
    
    results = opt.solve(m, tee=True)

When using HiGHS the error was encountered at results = opt.solve(m, tee=True) so as a workaround I used ipopt by default for cluster_network rule (snakemake) and used HiGHS to solve the model.

Dakait
  • 2,531
  • 1
  • 25
  • 43