Skip to main content

GetIpoptCurrentIterate

Function GetIpoptCurrentIterate 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn GetIpoptCurrentIterate( ipopt_problem: IpoptProblem, scaled: Bool, n: Index, x: *mut Number, z_l: *mut Number, z_u: *mut Number, m: Index, g: *mut Number, lambda: *mut Number, ) -> Bool
Expand description

Port of IpStdCInterface.cpp:GetIpoptCurrentIterate (Ipopt 3.14+). Designed to be called from inside an intermediate callback to inspect x, the bound multipliers z_L/z_U, the constraint values g, and the constraint multipliers lambda at the current iterate.

All output buffers are optional — pass NULL to skip. n and m must match the dimensions the problem was created with; mismatched sizes cause the function to return FALSE without writing.

scaled keeps upstream’s meaning (TNLP::get_curr_iterate, Ipopt 3.14 IpTNLP.cpp), on both the interior-point and the active-set SQP arm:

  • FALSE — the user TNLP’s unscaled space, the units IpoptSolve writes back: objective, constraint and per-variable (SetIpoptProblemScaling x_scaling) scaling all undone.
  • TRUE — the algorithm’s scaled space in the TNLP’s shape: x̃ = d ⊙ x (a fixed variable at its own value, as upstream’s ResortX writes it), z̃ = obj·z/d (at a fixed variable obj·z, z_L/z_U swapped when obj < 0, upstream’s manual rescale of ResortBoundMultipliers), g̃ = s ⊙ g (row factor; equality right-hand sides scaled too) and λ̃ = obj·λ/s (pounce_nlp::live_iterate::scaled_iterate). With presolve on, the scaled values of the problem the algorithm solved, lifted to the user’s shape like the unscaled ones: a column or row the algorithm holds carries its factor, one presolve removed carries factor 1 (a multiplier there still carries obj).

Both arms answer from the iterate the algorithm materialises before each fire (pounce_algorithm::intermediate::UserIterate), built by the conversions finalize_solution applies — so at the last fire this reads what IpoptSolve writes back. That includes the bound multipliers of fixed variables, recovered from ∇f + Jᵀλ as upstream’s TNLPAdapter::ResortBoundMultipliers does (not under fixed_variable_treatment=make_parameter_nodual), and, with presolve on, the rows and columns it removed.

Returns FALSE when called outside an active intermediate callback (no live iterate to inspect).

§Safety

ipopt_problem must be a valid IpoptProblem. Each output buffer, when non-NULL, must hold at least the declared length.