NaN and inf behaviour

25 views
Skip to first unread message

TD

unread,
Jun 29, 2023, 5:54:29 PM6/29/23
to Artelys Knitro forum
Hello there!

What is the current behaviour of Knitro (as of 13.2) when the function, Jacobian, or Hessian encounters an inf or NaN? I saw in an old post, from 2015, that the solver will take a shorter step until a feasible answer is obtained. However, I see that the following return code is possible:

KN_RC_EVAL_ER:  This termination value indicates that an evaluation error occurred (e.g., divide by 0, taking the square root of a negative number), preventing the optimization from continuing.

Kind regards
TD

Richard Waltz

unread,
Jun 29, 2023, 6:03:40 PM6/29/23
to kni...@googlegroups.com
Hi,

When the function evaluation produces inf or NaN, Knitro will take shorter steps until a solution estimate can be found where the functions are well-defined.  When the gradient/Jacobian/Hessian evaluation produces inf or NaN, Knitro terminates with an evaluation error message.  The distinction is that the function evaluation occurs for a "trial" solution estimate "x", and so it is easier to recover from since the function value at the current "x" should be well-defined.  On the other hand, a gradient/Jacobian/Hessian evaluation would occur at the current "x" and is more problematic (since Knitro uses derivative information to generate new solution estimates).

One way to try to avoid issues with evaluation errors is, if possible, to define finite lower and upper bounds on the variables in such a way that the functions, gradients, etc. are always well-defined inside these bounds, and then to set the option "honorbnds=1" in Knitro to ensure that all iterates generated during the solution process are within the defined variable bounds. See:


The "bar_feasible" option may also be helpful here:


Regards,
-Richard Waltz

From: kni...@googlegroups.com <kni...@googlegroups.com> on behalf of TD <tinusd...@gmail.com>
Sent: Thursday, June 29, 2023 2:47 PM
To: Artelys Knitro forum <kni...@googlegroups.com>
Subject: [Knitro] NaN and inf behaviour
 
--
You received this message because you are subscribed to the Artelys "Knitro Nonlinear Optimization Solver" google group.
To post to this group, send email to kni...@googlegroups.com
To unsubscribe from this group, send email to knitro-un...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/knitro?hl=en
Thank You,
Artelys
http://www.artelys.com/en/optimization-tools/knitro
---
You received this message because you are subscribed to the Google Groups "Artelys Knitro forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knitro+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knitro/70875c50-3fe3-48fb-a8e0-506aa9eef92fn%40googlegroups.com.

TD

unread,
Jun 29, 2023, 6:49:01 PM6/29/23
to Artelys Knitro forum
Thanks a lot for your quick and clear reply, Richard! Got it.

Kind regards
TD
Reply all
Reply to author
Forward
0 new messages