pounce_algorithm/output/trait.rs
1//! Iteration-output trait — port of `IpIterationOutput.hpp`.
2
3use crate::ipopt_cq::IpoptCqHandle;
4use crate::ipopt_data::IpoptDataHandle;
5
6/// Strategy that emits one row of the iter-by-iter table. The default
7/// `write_output` is a no-op so structural unit tests can drive the
8/// algorithm without an output sink. Phase 7 ports `OrigIterationOutput`
9/// with the full upstream column format.
10pub trait IterationOutput {
11 fn write_output(&mut self) {}
12
13 /// Format the next iteration row into a fresh `String`, given the
14 /// current data + CQ snapshots. Default returns an empty string.
15 /// Mirrors `IpOrigIterationOutput::WriteOutput` minus the
16 /// journalist write — callers route the returned line wherever
17 /// they want (stdout, file, log buffer for tests).
18 fn format_row(&mut self, _data: &IpoptDataHandle, _cq: &IpoptCqHandle) -> String {
19 String::new()
20 }
21
22 /// The `(objective, inf_pr)` pair the row prints, for the structured
23 /// per-iteration event, so the solve report carries the console's
24 /// numbers rather than a neighbouring quantity (gh#979). `None` means
25 /// this output prints no such columns, and the caller falls back to
26 /// the algorithm's own `unscaled_curr_f` / internal infeasibility.
27 fn printed_objective_inf_pr(
28 &mut self,
29 _data: &IpoptDataHandle,
30 _cq: &IpoptCqHandle,
31 ) -> Option<(f64, f64)> {
32 None
33 }
34
35 /// Whether the rows this output prints belong to the restoration
36 /// phase (the `r`-suffixed rows). Tags the structured event.
37 fn is_restoration(&self) -> bool {
38 false
39 }
40}