Set type of finite differences for variables separately

Skip to first unread message

Lisa Neu

Dec 16, 2020, 11:26:53 AM12/16/20
to Artelys Knitro forum
Hi all,

do you know if there is a way to set the type of finite differences (forward vs. central) for each variable separately without implementing your own gradients?
I have some variables where I would rather like to have central differences, whereas for others, forward differences would perform better.

I am happy about your input!
Thanks in advance

Richard Waltz

Dec 16, 2020, 3:06:18 PM12/16/20
Hi Lisa,

Unfortunately, this functionality is not currently available in Knitro.  I agree it could be useful and we will consider adding it in a future release.

There are 2 related functionalities that may or may not be useful to you. 

1) There is an API function in Knitro to set a custom finite-difference steplength for each variable:

2) The callable library API in Knitro allows computing/approximating gradients for different groups of constraints in different ways.  For example you could use forward differences for some group of constraints and central differences for another group of constraints, by creating separate callback structures for these 2 groups.  In the Knitro distribution, the "C" example


shows how to use exact gradients for some constraints and forward finite-differencing for others.  Something similar could be done to compute some constraints with forward differencing and others with central differencing.

Best regards,

Richard WALTZ
Senior Scientist
Artelys USA

From: [] on behalf of Lisa Neu []
Sent: Wednesday, December 16, 2020 2:18 AM
To: Artelys Knitro forum
Subject: [Knitro] Set type of finite differences for variables separately

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
To unsubscribe from this group, send email to
For more options, visit this group at
Thank You,
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
To view this discussion on the web visit
Reply all
Reply to author
0 new messages