Skip to main content

GetIpoptCurrentViolations

Function GetIpoptCurrentViolations 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn GetIpoptCurrentViolations( ipopt_problem: IpoptProblem, scaled: Bool, n: Index, x_l_violation: *mut Number, x_u_violation: *mut Number, compl_x_l: *mut Number, compl_x_u: *mut Number, grad_lag_x: *mut Number, m: Index, nlp_constraint_violation: *mut Number, compl_g: *mut Number, ) -> Bool
Expand description

Port of IpStdCInterface.cpp:GetIpoptCurrentViolations (Ipopt 3.14+). Same contract as GetIpoptCurrentIterate; returns FALSE when called outside an active intermediate callback.

scaled keeps upstream’s meaning (TNLP::get_curr_violations):

  • FALSE — the user’s problem, unscaled: objective, constraint and per-variable scaling undone, full n with fixed variables, rows in g order. Computed from the live iterate GetIpoptCurrentIterate reads (so with presolve on, the user’s own rows and columns) against the declared bounds: x_L_violation = max(0, x_L − x), compl_x_L = (x − x_L^alg)·z_L with x_L^alg the bound the algorithm’s slack is measured to (declared, widened by bound_relax_factor: upstream’s curr_compl_x_L / obj, except under per-variable user scaling, where pounce relaxes in the scaled frame and Ipopt in the unscaled one), grad_lag_x = ∇f + Jᵀλ − z_L + z_U (0 at fixed variables, as upstream’s ResortX leaves them; ∇f and J come from this problem’s eval_grad_f / eval_jac_g, called only when grad_lag_x is requested), per-row violation |g − g_L| / max(0, g_L − g, g − g_U) and compl_g with upstream’s signs. Both arms.
  • TRUE — upstream’s get_curr_violations(scaled = true): the same quantities in the algorithm’s scaled space, each a fixed factor of its unscaled counterpart (pounce_nlp::live_iterate::scale_violations): bound violations × d, complementarities × obj, grad_lag_x × obj/d, row violations × s — the factors GetIpoptCurrentIterate (scaled = TRUE) applies. Both arms (the SQP arm’s scaled space is d and the obj_scaling_factor option: it runs no other scaling), and under presolve, where a removed column or row carries factor 1.

§Safety

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