Skip to content

runs without a solution are not catched when using glpk  #560

@phil-fzj

Description

@phil-fzj

Purpose of the improvement

When glpk fails to find a solution, the code just continues and only fails later with very cryptic error messages

TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

See this example:

Warning: basis matrix is ill-conditioned (cond = 1.14e+14)
Error: basis matrix is singular to working precision (cond = 4.54e+15)
glp_simplex: unable to recover undefined or non-optimal solution
If you need actual output for non-optimal solution, use --nopresol
Time used:   141.6 secs
Memory used: 73.7 Mb (77238063 bytes)
Writing basic solution to '/tmp/tmpuy8qxdh4.glpk.raw'...
92882 lines were written

Status: ok
Termination condition: other
Statistics: 
  Branch and bound: 
    Number of bounded subproblems: 0
    Number of created subproblems: 0
Error rc: 0
Time: 142.14720749855042


Name: unknown
Lower bound: -.inf
Upper bound: .inf
Number of objectives: 1
Number of constraints: 62110
Number of variables: 30763
Number of nonzeros: 182899
Sense: minimize

Solve time: 143.76304483413696 sec.
/fast/home/p-dunkel/testing/fine_gh/fine/energySystemModel.py:2162: UserWarning: Output is generated for a non-optimal solution.
  warnings.warn("Output is generated for a non-optimal solution.")

Processing optimization output...
Traceback (most recent call last):
  File "/fast/home/p-dunkel/testing/fine_gh/aaa.py", line 482, in <module>
    esM.optimize(timeSeriesAggregation=True, solver="glpk")
  File "/fast/home/p-dunkel/testing/fine_gh/fine/energySystemModel.py", line 2175, in optimize
    mdl.setOptimalValues(self, self.pyM)
  File "/fast/home/p-dunkel/testing/fine_gh/fine/sourceSink.py", line 965, in setOptimalValues
    optSummaryBasic = super().setOptimalValues(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fast/home/p-dunkel/testing/fine_gh/fine/component.py", line 3860, in setOptimalValues
    resultsNPV_cx = self.getEconomicsDesign(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fast/home/p-dunkel/testing/fine_gh/fine/component.py", line 3196, in getEconomicsDesign
    annuity = self.getLocEconomicsDesign(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fast/home/p-dunkel/testing/fine_gh/fine/component.py", line 3425, in getLocEconomicsDesign
    return factor * _var.value
           ~~~~~~~^~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Proposal

Raise an error if no solution is available.
The user warning

UserWarning: Output is generated for a non-optimal solution.

is not sufficient, if there is no solution available at all!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions