Skip to main content

Module intermediate

Module intermediate 

Source
Expand description

Per-iteration “intermediate” context shared with downstream callers (notably the C-API inspector functions GetIpoptCurrentIterate / GetIpoptCurrentViolations).

Mirrors upstream Ipopt’s OrigIpoptNLP::GetIpoptCurrent* flow: the main loop installs a snapshot of the algorithm-side state into thread-local storage immediately before invoking the user’s intermediate callback, and clears it on return. Inspector functions consult the TLS slot; outside the callback window every accessor reports “not available”.

The snapshot is intentionally cheap to assemble — we stash Rc handles to IpoptData, IpoptCq, and the algorithm-side IpoptNlp rather than precomputing every field, so callers that read just one quantity pay only for what they look at.

Structs§

CtxGuard
RAII guard — installs ctx on construction, clears on drop. Used by the algorithm to scope visibility of live iterate state to one callback fire.
IntermediateContext
Snapshot stashed in TLS for the duration of one TNLP::intermediate_callback invocation.
UserIterate
The materialised iterate of the user’s problem (full n, full m, original g order), and its window. Defined in pounce_nlp::live_iterate so the decorators that lift it one layer per intermediate_callback forward — presolve’s above all — can reach it; re-exported here, where callers have always found it.
UserIterateGuard
The materialised iterate of the user’s problem (full n, full m, original g order), and its window. Defined in pounce_nlp::live_iterate so the decorators that lift it one layer per intermediate_callback forward — presolve’s above all — can reach it; re-exported here, where callers have always found it.

Functions§

algorithm_x_bounds
The variable bounds nlp iterates against — its live x_L / x_U, i.e. the declared box after bound_relax_factor widened it and any safe-slack adjustment moved it (upstream IpoptNLP::x_L(), what curr_slack_x_L is measured to) — in the shape of the TNLP it wraps (UserIterate::x_l_alg): ±∞ at a column with no such bound, and at a fixed variable the algorithm does not hold, its value x[j].
ipm_user_iterate
The interior-point iterate in the space of the TNLP the NLP wraps, by the conversions finalize_via_orig_nlp applies to the final one, so the iterate read at the last fire is the solution finalize_solution reports:
is_active
Whether a context is currently installed.
iterate_scaling
The IterateScaling of the problem nlp iterates on, in the shape of the TNLP it wraps — the objective factor and the per-row c / d factors, and which columns the algorithm holds (not a fixed variable, which upstream’s ResortX reports at the TNLP’s own value). The per-variable factor is 1 here: a ScalingTnlp substituting x̃ = d ⊙ x multiplies its d in when it lifts the iterate. Both arms solve through the same OrigIpoptNlp, so both read their scaling here.
user_grad_lag
The algorithm’s own ∇L (var-x, scaled: obj·∇f + J̃ᵀỹ − z̃_L + z̃_U, upstream curr_grad_lag_x) as the unscaled ∇f + Jᵀλ − z_L + z_U of the TNLP nlp wraps — ÷ obj, the row factors cancelling in J̃ᵀỹ — at full x, 0 at a column the algorithm does not hold (upstream ResortX(…, usefixedvals=false)). Its ∇f and J are the ones the algorithm evaluated at the iterate, so this costs no evaluation.
with_current
Read access to the currently installed context. Returns None outside the intermediate-callback window.
with_current_user_iterate
The materialised iterate of the user’s problem (full n, full m, original g order), and its window. Defined in pounce_nlp::live_iterate so the decorators that lift it one layer per intermediate_callback forward — presolve’s above all — can reach it; re-exported here, where callers have always found it.