Skip to content

Dingo always selects HiGHS as first choice of optimizer #134

@quothbonney

Description

@quothbonney

I have Gurobi installed and licensed. I the solver to "gurobi" on the model. Gurobi even prints its license banner so it's clearly loaded and working. But dingo still crashes trying to load HiGHS.

From my understanding, pyoptinterface_based_impl.py hardcodes default_solver = "highs" and the set_solver() on MetabolicNetwork doesn't actually propagate everywhere. So internally it still tries highs.Model() first, that fails because HiGHS isn't installed, and then the error handling itself crashes because the except clauses try to catch enum values (poi.TerminationStatusCode.NUMERICAL_ERROR) instead of actual exceptions. So you get a confusing TypeError about BaseException instead of anything useful.

I ended up having to do a workaround modifying the code myself In pyoptinterface_based_impl.py. I changed default_solver = "highs" to default_solver = "gurobi", and replace the three broken except poi.TerminationStatusCode.* blocks with plain except Exception.

Here is what the error looks like from my perspective

[2026-02-24 20:34:56] sampling 50000 steady states (thinning=100, burn_in=5000)...
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value <REDACTED>
Academic license <REDACTED> - for non-commercial use only - registered to jd___@mit.edu
Traceback (most recent call last):
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/dingo/pyoptinterface_based_impl.py", line 55, in fba
    model = SOLVER.Model()
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/pyoptinterface/_src/highs.py", line 296, in __init__
    super().__init__()
RuntimeError: HiGHS library is not loaded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/<REDACTED>/users/jdcarson/hop/benchmarking/chrr_sampling/volesti_cdhr.py", line 198, in <module>
    main()
  File "/data/<REDACTED>/users/jdcarson/hop/benchmarking/chrr_sampling/volesti_cdhr.py", line 174, in main
    timings = run_model(name, fname)
  File "/data/<REDACTED>/users/jdcarson/hop/benchmarking/chrr_sampling/volesti_cdhr.py", line 104, in run_model
    steady_states = sampler.generate_steady_states_no_multiphase(
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/dingo/PolytopeSampler.py", line 178, in generate_steady_states_no_multiphase
    self.get_polytope()
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/dingo/PolytopeSampler.py", line 73, in get_polytope
    A, b, Aeq, beq = remove_redundant_facets(
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/dingo/pyoptinterface_based_impl.py", line 329, in remove_redundant_facets
    max_biomass_flux_vector, max_biomass_objective = fba(lb, ub, S, c, solver_name)
  File "/data/<REDACTED>/users/jdcarson/envs/hop/lib/python3.10/site-packages/dingo/pyoptinterface_based_impl.py", line 82, in fba
    except poi.TerminationStatusCode.NUMERICAL_ERROR as e:
TypeError: catching classes that do not inherit from BaseException is not allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions