Contype in API

Skip to first unread message


Jul 4, 2023, 3:01:46 AM7/4/23
to Artelys Knitro forum
Hi there

In the oldAPI (10.x and earlier), it is clearly shown how the array cType can be used to describe the type of constraints of the constraint function. This used to be done in KTR_init_problem().

Is this still possible in the latest API? (And if so, how would this now be done?)

Kind regards

Richard Waltz

Jul 4, 2023, 3:09:05 AM7/4/23

In the current API, the cType array is no longer used -- rather, the constraint type is automatically determined based on the API functions used to specify the constraint.  For example, linear constraints should be loaded using the API function "KN_add_con_linear_struct()"

Quadratic constraints should be loaded using the function above to load the linear terms and "KN_add_con_quadratic_struct()" for the quadratic terms:

General, nonlinear (beyond quadratic) constraints/structures should be handled through a callback function in the same way as the 10.x and earlier old API.  Anything specified through a callback is automatically treated as general nonlinear so it is always best to use the specified API functions for loading linear and quadratic structures in your model so that Knitro can be aware of, and exploit these special structures whenever possible.

Kind regards,

From: <> on behalf of TD <>
Sent: Monday, July 3, 2023 7:47 AM
To: Artelys Knitro forum <>
Subject: [Knitro] Contype in API
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


Jul 4, 2023, 3:27:00 AM7/4/23
to Artelys Knitro forum
Thanks, Richard!
Reply all
Reply to author
0 new messages