Skip to content

Commit

Permalink
Merge pull request #91 from chrhansk/hotfix-linear-solver-errors
Browse files Browse the repository at this point in the history
Catch errors produced by singular factors
  • Loading branch information
chrhansk authored May 24, 2024
2 parents 24e65ae + d88ad2b commit 9d77b6c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project = "pygradflow"
copyright = "2023, Christoph Hansknecht"
author = "Christoph Hansknecht"
release = "0.4.21"
release = "0.4.22"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
5 changes: 2 additions & 3 deletions pygradflow/step/extended_step_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ def solve_scaled(self, b0, b1, b2t):
if self._deriv is None:
self._compute_deriv()

if self.solver is None:
self.solver = self.linear_solver(self.deriv)

n = self.n
m = self.m

Expand All @@ -95,6 +92,8 @@ def solve_scaled(self, b0, b1, b2t):
assert rhs.shape == (n + m,)

try:
if self.solver is None:
self.solver = self.linear_solver(self.deriv)
sol = self.solver.solve(rhs)
except LinearSolverError as e:
raise StepSolverError from e
Expand Down
6 changes: 3 additions & 3 deletions pygradflow/step/standard_step_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def solve(self, iterate: Iterate) -> StepResult:
if self.deriv is None:
self._compute_deriv()

if self.solver is None:
self.solver = self.linear_solver(self.deriv)

rhs = self.func.value_at(iterate, self.rho, self.active_set)

try:
if self.solver is None:
self.solver = self.linear_solver(self.deriv)

sol = self.solver.solve(rhs)
except LinearSolverError as e:
raise StepSolverError from e
Expand Down
5 changes: 2 additions & 3 deletions pygradflow/step/symmetric_step_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ def solve_scaled(self, b0, b1, b2t):
def solve_deriv(
self, active_set: np.ndarray, deriv: sp.sparse.spmatrix, rhs: np.ndarray
) -> np.ndarray:
if self.solver is None:
self.solver = self.linear_solver(self.deriv)

try:
if self.solver is None:
self.solver = self.linear_solver(self.deriv)
sol = self.solver.solve(rhs)
except LinearSolverError as e:
raise StepSolverError from e
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pygradflow"
version = "0.4.21"
version = "0.4.22"
description = "PyGradFlow is a simple implementation of the sequential homotopy method to be used to solve general nonlinear programs."
authors = ["Christoph Hansknecht <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 9d77b6c

Please sign in to comment.