Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solvers tolerant to infinite values #56

Closed
philippkraft opened this issue Jan 18, 2019 · 1 comment
Closed

Add solvers tolerant to infinite values #56

philippkraft opened this issue Jan 18, 2019 · 1 comment
Assignees
Labels
enhancement python Need to change Python file (.py)
Milestone

Comments

@philippkraft
Copy link
Owner

The nice error reporting for not finite results in connections can render recoverable errors to be unrecoverable. By allowing some retries in a solver, calculations can become more robust

Proposed solution

Change cmf.integrator.call(...) to the following:

    def __init__(self, project, err_tol=1e-9, max_errors=10):
        super().__init__(project, err_tol)
        self.errors = []
        self.max_errors = max_errors

    def __call__(self, t, reset=False):
        import sys
        until = self.t + t if t < self.t else t
        while self.t < until:
            try:
                self.integrate_until(until, reset=reset)
            except RuntimeError as e:
                if len(self.errors) < self.max_errors:
                    self.errors.append((self.t, e))
                    self.reset()
                    sys.stderr.write(str(e) + '\n')
                else:
                    raise

        return self.t
@philippkraft philippkraft added this to the v1.5 milestone Mar 12, 2019
@philippkraft philippkraft added python Need to change Python file (.py) enhancement labels Mar 12, 2019
@philippkraft philippkraft self-assigned this Mar 12, 2019
@philippkraft
Copy link
Owner Author

Availale via solver.run(..., max_errors=10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement python Need to change Python file (.py)
Projects
None yet
Development

No branches or pull requests

1 participant