-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Sometimes when you solve a nonlinear problem, the solver might diverge which leaves the solver in a bad state.
Consider the following scenario
solver = NewtonSolver(...)
target_value = 1.0
step = 0.1
while parameter.value < target_value:
parameter.value += step
try:
solver.solve()
except RuntimeError:
# Do smaller step and reset solver
parameter.value -= step
step /= 2.0However, when the solver fails it might be in a bad state which needs to be reset to the last good state. My suggestion would be to allow for resetting the state in a seamless way, e.g
solver = NewtonSolver(...)
target_value = 1.0
step = 0.1
while parameter.value < target_value:
good_state = solver.state
parameter.value += step
try:
solver.solve()
except RuntimeError:
parameter.value -= step
step /= 2.0
solver.reset_state(good_state)or even implement a method called try_to_solve_or_reset (or just make it default to reset the state).
Metadata
Metadata
Assignees
Labels
No labels