Skip to content

Commit c308095

Browse files
committed
squash as well
1 parent 3706870 commit c308095

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rmgpy/molecule/resonance.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,19 @@ def _clar_optimization(mol, recursion_constraints=None, clar_number=-1, save_ord
11011101
if status == 2: # infeasible
11021102
raise RuntimeError("All valid Clar formulae have been enumerated!")
11031103
else:
1104-
raise RuntimeError(f"Clar optimization failed (Exit Code {status}) for an unexpected reason: {result.message}")
1104+
raise RuntimeError(f"Optimization failed (Exit Code {status}) for an unexpected reason '{result.message}'")
11051105

11061106
_clar_number, solution = -result.fun, result.x
11071107

11081108
# optimization may have reached a bad local minimum - this case is rare
11091109
if _clar_number == 0:
11101110
return []
11111111

1112+
# on later runs, non-integer solutions occur - branching might be able to find actual solutions,
1113+
# but we just call it good enough here
1114+
if any([x != 1 and x != 0 for x in solution]):
1115+
raise RuntimeError("Optimization obtained a non-integer solution - no more formulae will be enumerated.")
1116+
11121117
# first solution, so the result should be an upper limit
11131118
if clar_number == -1:
11141119
clar_number = _clar_number

0 commit comments

Comments
 (0)