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

Handle evaluation errors in PyNumero #2899

Closed
Robbybp opened this issue Jul 5, 2023 · 1 comment · Fixed by #2901 or #2994
Closed

Handle evaluation errors in PyNumero #2899

Robbybp opened this issue Jul 5, 2023 · 1 comment · Fixed by #2901 or #2994

Comments

@Robbybp
Copy link
Contributor

Robbybp commented Jul 5, 2023

Summary

Currently, PyNumero's ASL interface handles evaluation errors by asserting the return value of the interface's eval_g function here. To handle this error, e.g. in a solver interface, one would have to catch the error, something like:

try:
    nlp.evaluate_constraints()
except AssertionError:
    # Follow whatever convention the solver uses for eval errors
    return False

This is dangerous as it catches any assertion error (e.g. the check for consistent dimensions). I propose we have something like a PyNumeroEvaluationError that we raise in this case that can safely be caught and handled by solver interfaces.

Presumably, we could also provide some information about which constraint caused the evaluation error, which would be useful for debugging. Ipopt's AMPL interface does this, although from a quick glance at the ASL evaluation functions it was not obvious to me how this is done.

Rationale

This is one step towards a CyIpopt interface that handles function evaluation errors in the same way that Ipopt (AMPL interface) does. The other steps are to handle evaluation errors in CyIpopt and to integrate both of these in our CyIpopt interface.

@Robbybp
Copy link
Contributor Author

Robbybp commented Jul 7, 2023

Presumably, we could also provide some information about which constraint caused the evaluation error, which would be useful for debugging. Ipopt's AMPL interface does this, although from a quick glance at the ASL evaluation functions it was not obvious to me how this is done.

It looks like the additional information that Ipopt displays with halt_on_ampl_error yes comes from ASL, and I can't figure out exactly where it comes from. At the high-level ASL interface, we have the following options:

  1. Ignore an evaluation error but set the error flag (this is what we currently use in PyNumero)
  2. Halt on error and print a message. I don't think this is useful for us. We want the program to keep executing.

One option to provide useful information on errors in Jacobian/constraint evaluation would be to call conival and jacival for each constraint and make a note of which set the error flag. This information could then be passed up to Python where we can print useful debugging information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants