KSLDatabaseComparisonSource

class KSLDatabaseComparisonSource(db: KSLDatabase, val sourceLabel: String = defaultLabel(db)) : ComparisonDataSourceIfc(source)

Database-backed adapter exposing the experiments stored in a KSLDatabase as a ComparisonDataSourceIfc — the third member of the comparison-source family alongside InMemoryComparisonSource (test fixture / programmatic use) and BatchCompletedComparisonSource (live scenario-sweep result).

Each experiment found in tblExperiment becomes one ExperimentRow. The experiment's response set is the union of every response stat present in tblWithinRepStat and every counter stat present in tblWithinRepCounterStat for that experiment, in first-encountered order. Response-vs-time-weighted discrimination uses the class_name field on the joined tblModelElement row; this is information the batch and in-memory adapters cannot supply but the database always carries.

observations returns per-replication values in rep-id order, drawn from KSLDatabase.replicationDataArraysByExperimentAndResponse: for response statistics the average field, for counters the last_value field. Missing-rep NaN entries (filled in by the underlying cross-experiment view) are dropped before the array is returned, so consumers see a clean, length-matched observation vector.

The adapter takes an eager snapshot of the database in its constructor — the per-experiment row metadata and the cross-experiment observation map are both materialised once and reused thereafter. The database is treated as frozen for the lifetime of the adapter, matching the behaviour of the in-memory and batch sources. Construct a new adapter if the underlying DB has been written to and you need to see the new state.

Constructors

Link copied to clipboard
constructor(db: KSLDatabase, sourceLabel: String = defaultLabel(db))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val sourceLabel: String

Human-readable label for the source — shown in the comparison-analyzer header. Free-form; typical values: "Scenario run · 2025-05-15 · 4 scenarios", "Designed experiment · 12 points", "KSL database · queue-study.db".

Functions

Link copied to clipboard

All experiments available for comparison from this source, in source-natural order (commit order for scenarios, execution order for design points, table order for DB loads). Empty when the source has no experiments.

Link copied to clipboard
open override fun observations(experimentName: String, responseName: String): DoubleArray?

Per-replication observations for the given experimentName / responseName pair. Returns null when the experiment did not record that response, when the experiment is unknown, or when no per-replication data is available (counters that record only an end-of-replication count are surfaced as last_value and still return a one-value-per-rep array). Empty array is reserved for "experiment recorded the response but produced no values" — vanishingly rare in practice but worth distinguishing from "no recording at all".