#[unsafe(no_mangle)]pub unsafe extern "C" fn IpoptSetNonlinearVariables(
ipopt_problem: IpoptProblem,
num_nonlin_vars: Index,
pos_nonlin_vars: *const Index,
) -> BoolExpand description
Declare which variables enter the problem nonlinearly (gh#624).
This is the C-API face of Ipopt’s TNLP::get_number_of_nonlinear_variables
/ get_list_of_nonlinear_variables pair, which upstream exposes only
to C++ callers. It exists so a frontend that already knows the
structure of its model — CasADi’s pass_nonlinear_variables, an
algebraic modeling language, a hand-written driver — can hand that
knowledge to pounce.
Effect is confined to the limited-memory Hessian: curvature is
approximated over the declared subset only, and the Hessian is
exactly zero for every other variable. Exact-Hessian solves ignore
the declaration entirely, and so does any solve that never calls
this function — the default remains “all variables are nonlinear”.
The subset takes precedence over the num_linear_variables option,
matching Ipopt’s own ordering.
pos_nonlin_vars holds num_nonlin_vars variable indices in the
problem’s index style (the index_style passed to
CreateIpoptProblem). The subset may be arbitrary and
noncontiguous; order does not matter. Passing num_nonlin_vars == n
is equivalent to not calling this at all.
Returns FALSE (leaving any previous declaration untouched) on a
NULL problem, a negative or oversized count, a NULL array with a
positive count, or an index outside the problem’s variable range.
Note the deliberate signature choice: the issue that requested this
suggested a const Bool* mask, but Bool in the Ipopt C API is a
C99 bool, and a array of those would be a per-element
data-layout contract that is easy to get wrong from a caller with a
different boolean width. The count-plus-index-list shape is the one
the TNLP callbacks already use.
§Safety
ipopt_problem must be a valid IpoptProblem or NULL.
pos_nonlin_vars, when non-NULL, must point at num_nonlin_vars
readable ipindex values.