toDesignedExperiment

fun ExperimentConfiguration.toDesignedExperiment(modelBuilder: ModelBuilderIfc, pathToOutputDirectory: Path, kslDatabase: KSLDatabase? = null, name: String? = null): DesignedExperimentIfc(source)

Engine glue — build a runnable DesignedExperimentIfc from a serialised ExperimentConfiguration.

Pure function (no I/O at construction time apart from what the substrate's *DesignedExperiment constructors do internally to set up the output directory and the SQLite database). The hosting controller (Phase E3) resolves ExperimentConfiguration.modelReference to a ModelBuilderIfc, computes the workspace-nested output directory, and opens a KSLDatabase per the document's database-policy before calling this function.

Returns either a ParallelDesignedExperiment (when ExperimentConfiguration.executionMode is CONCURRENT) or a DesignedExperiment (when SEQUENTIAL). Both implement DesignedExperimentIfc, which is what ksl.app.orchestrator.ExperimentOrchestrator.submit accepts.

Stream policy applies under CONCURRENT only. The ExperimentConfiguration.streamPolicy field is read by this function only when building the parallel variant; sequential execution uses the underlying ksl.simulation.Model's own stream defaults. The hosting controller surfaces a warning when the user picks SEQUENTIAL + commonRandomNumbers to make the silent ignore visible.

Parameters

modelBuilder

factory producing fresh Model instances (CONCURRENT calls build() per design point; SEQUENTIAL calls build() exactly once for the shared model).

pathToOutputDirectory

workspace-relative output dir for the experiment's artifacts.

kslDatabase

pre-opened KSLDatabase honouring the document's database policy. null lets the substrate's constructor default kick in.

name

display name for the experiment. Defaults to the sanitised analysis name from outputConfig.analysisName.