Skip to main content

DiagnosticsState

Struct DiagnosticsState 

Source
pub struct DiagnosticsState {
    pub config: DiagnosticsConfig,
    /* private fields */
}
Expand description

Live state threaded through the solve via Rc. The IPM mutates current_iter and solves_this_iter; the dump sites read them. All fields use atomics so the type is Send + Sync even though the solver itself is single-threaded — keeps the door open for future parallel inner solvers without an ABI rewrite.

Fields§

§config: DiagnosticsConfig

Implementations§

Source§

impl DiagnosticsState

Source

pub fn new(config: DiagnosticsConfig) -> Result<Self>

Create a state and mkdir -p the dump directory. Failure to create the directory bubbles up so the CLI can exit with a clear error before the solve even starts.

Source

pub fn want(&self, cat: DiagCategory) -> bool

True if the caller should dump cat at the current iter.

Source

pub fn bump_iter(&self)

Advance the outer-iteration counter and reset the per-iter solve index. Called by IpoptAlgorithm::optimize at the top of each outer iteration.

Source

pub fn next_solve_index(&self) -> i32

Reserve the next per-iter solve index. Returned value is 1-based to match the filenames (kkt_solve_001.jsonl).

Source

pub fn enter_restoration(&self)

Mark the start of a restoration sub-IPM run. parent_iter is the outer iter that triggered restoration; dumps from the resto sub-solve land under resto/parent_iter_NNN/iter_MMM/.

Source

pub fn exit_restoration(&self)

Source

pub fn current_iter(&self) -> i32

Source

pub fn in_restoration(&self) -> bool

True if the solver is currently inside a restoration sub-IPM run. Public, side-effect-free probe for emitters that need to tag rows with the restoration flag without mkdir-ing the iter directory (which iter_dir does).

Source

pub fn iter_dir(&self) -> Option<PathBuf>

Resolve the directory a category’s dump file should live in, creating it if necessary. Returns None if the directory cannot be created (e.g., filesystem full) — callers should silently skip the dump in that case rather than fail the solve.

Source

pub fn open_writer(&self, filename: &str) -> Option<BufWriter<File>>

Open a writer for <iter_dir>/<filename>. Caller picks the filename so callers that produce multi-solve traces can use next_solve_index to disambiguate.

Source

pub fn write_top_level(&self, filename: &str, contents: &str) -> Result<()>

Write a one-shot top-level file (manifest, timing summary). Always lands directly under dump_dir, never under an iter sub-directory.

Source

pub fn append_iterate_line(&self, json: &str) -> Result<()>

Append one JSONL line to the persistent top-level iterates.jsonl stream, opening the file on first use. The writer is held across iterations so the emitter doesn’t re-open the file every step (which would also truncate it).

Caller supplies the already-encoded JSON record without a trailing newline; this method appends \n and flushes the buffer so a SIGKILL’d solve still leaves a parseable partial trace.

Source

pub fn dump_dir(&self) -> &Path

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.