NestedCsvSolverStateTracker

class NestedCsvSolverStateTracker(macroSolver: Solver, microSolver: Solver, outputFile: File, columns: List<NestedTrackerColumn> = defaultColumns) : AbstractNestedSolverStateTracker(source)

An autonomous, persistent tracker that logs both macro and micro iterations of a nested solver architecture to a single CSV file.

  • Autonomous Lifecycle Management

This tracker listens to the parent (macro) solver's lifecycle to automatically manage OS file locks. It lazily opens the CSV file in append mode when a run starts and safely closes the file when the run ends. This allows a user to execute the solver multiple times sequentially without manually managing the tracker, resulting in all consecutive runs being cleanly appended to the same file.

  • Data Structure

The output CSV inherently interleaves "MACRO" summary rows and "MICRO" detail rows. It leverages the TrackingContext to stamp each row with a run number, an optional experiment name, and to correlate micro iterations to their parent macro iteration.

Parameters

macroSolver

The outer solver managing the high-level algorithm (e.g., RandomRestartSolver).

microSolver

The inner solver executing the detailed optimization steps (e.g., RSplineSolver).

outputFile

The file destination for the CSV data.

columns

A list of NestedTrackerColumn definitions detailing the CSV structure. Defaults to defaultColumns.

Constructors

Link copied to clipboard
constructor(macroSolver: Solver, microSolver: Solver, outputFile: File, columns: List<NestedTrackerColumn> = defaultColumns)
constructor(macroSolver: Solver, microSolver: Solver, fileName: String)

Convenience constructor that creates a CSV file in the standard KSL output directory.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
protected open override fun consumeMacro(outerSnapshot: SolverStateSnapshot)

Formats and writes an overarching macro iteration row to the CSV.

Link copied to clipboard
protected open override fun consumeMicro(innerSnapshot: SolverStateSnapshot)

Formats and writes a detailed micro iteration row to the CSV.

Link copied to clipboard
protected open override fun onMacroLifecycleEvent(status: SolverStatus)

Responds to the outer solver's lifecycle events to safely manage file streams.