DesignedExperiment

class DesignedExperiment(name: String, model: Model, factorSettings: Map<Factor, String>, val design: ExperimentalDesignIfc, val kslDb: KSLDatabase = KSLDatabase("${name}.db".replace(" ", "_"), model.outputDirectory.dbDir)) : Identity

Facilitates the simulation of a model via an experimental design.

The map representing the factor and its associated string requires some further discussion. The naming convention for controls and random variable parameters is important to note.

For controls, by default, the key to associate with the value is the model element's name concatenated with the property that was annotated with the control. For example, if the resource had name Worker and annotated property initialCapacity, then the key will be "Worker.initialCapacity". Note the use of the "." character to separate the model element name and the property name. Since, the KSL model element naming convention require unique names for each model element, the key will be unique for the control. However, the model element name may be a very long string depending on your approach to naming the model elements. The name associated with each control can be inspected by asking the model for its controls via model.controls() and then using the methods on the Controls class for the names. The controlsMapAsJsonString() or asMap() functions are especially helpful for this purpose.

For the parameters associated with random variables, the naming convention is different. Again, the model element name is used as part of the identifier, then the value of rvParamConCatString from the companion object is concatenated between the name of the model element and the name of its parameter. For example, suppose there is a random variable that has been named ServiceTimeRV that is exponentially distributed. Also assume that rvParamConCatString is ".", which is its default value. Then, to access the mean of the service time random variable, we use "ServiceTimeRV.mean". Thus, it is important to note the name of the random variable within the model and the KSL's default names for the random variable parameters. When random variables are not explicitly named by the modeler, the KSL will automatically provide a default unique name. Thus, if you plan to control a specific random variable's parameters, you should strongly consider providing an explicit name. To get the names (and current values) of the random variable parameters, you can print out the toString() method of the RVParameterSetter class after obtaining it from the model via the model's rvParameterSetter property.

Suppose factor A was associated with the worker's initial capacity and factor B was associated with the mean of the service time distribution, then the factor settings map would be mapOf(factorA to "Worker.initialCapacity", factorB to "ServiceTimeRV.mean") where factorA and factorB are references to the associated Factor instances.

Parameters

name

the name of the experiment for saving simulation results

model

The model to simulate.

factorSettings

A mapping between each factor and a string representing the name of the control or parameter to associate with the factor.

design

The design that will be simulated. The factors specified in the design must be contained in the factor settings.

kslDb

a KSLDatabase that will hold the data from the experiment.

Constructors

Link copied to clipboard
constructor(name: String, model: Model, twoLevelSettings: Map<TwoLevelFactor, String>, design: TwoLevelFactorialDesign, kslDb: KSLDatabase = KSLDatabase("${name}.db".replace(" ", "_"), model.outputDirectory.dbDir))
constructor(name: String, model: Model, factorSettings: Map<Factor, String>, design: ExperimentalDesignIfc, kslDb: KSLDatabase = KSLDatabase("${name}.db".replace(" ", "_"), model.outputDirectory.dbDir))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The database observer of the model. Can be used to stop observing, etc. The observer is created to clear data before experiments. Assumes that if the user is re-running the design that existing data for the experiment should be deleted.

Link copied to clipboard

A default value for the number of replications per design point. Used only if specified greater that or equal to 1. This will overwrite the number of replications for every design point if specified greater than 0. By default, it is set to -1, causing the design points to use the specification from the design.

Link copied to clipboard
Link copied to clipboard
override val id: Int
Link copied to clipboard
Link copied to clipboard
open override var label: String?
Link copied to clipboard
override val name: String
Link copied to clipboard

The number of design points executed in the base design (without replications)

Link copied to clipboard

The names of the responses or counters in the model

Link copied to clipboard

Returns the list of executed runs, one run for each design point simulated

Functions

Link copied to clipboard

Causes any previous simulation runs associated with the execution of design points to be cleared.

Link copied to clipboard
fun regressionData(responseName: String, linearModel: LinearModel, coded: Boolean = true): RegressionData

The regression data to perform the regression of the linear model

Link copied to clipboard
fun regressionDataAsDataFrame(responseName: String, linearModel: LinearModel, coded: Boolean = true): AnyFrame

The regression data to perform the regression of the linear model

Link copied to clipboard
fun regressionResults(responseName: String, linearModel: LinearModel, coded: Boolean = true): RegressionResultsIfc

Perform the regression of the linear model for predicting the response.

Link copied to clipboard

Returns replicated design point information in the order that the points were executed as a data frame.

Link copied to clipboard
Link copied to clipboard
fun replicatedDesignPointsAsDataFrame(coded: Boolean = false): AnyFrame

Each design point in the associated factorial design is replicated by the number of associated replications held in the property designPointReplications. This results in an expanded list of design points within a dataframe with repeated copies of the design points within the data frame. The number of copies of each design point is based on its associated number of replications. The data frame has columns (exp_name, rep_id, factor1, factor2, ..., factorN) where factorK is the name of the kth factor.

Link copied to clipboard
fun replicatedDesignPointsWithResponse(responseName: String, coded: Boolean = false): AnyFrame

Returns a data frame that has columns (point, exp_name, rep_id, responseName, factor1, factor2, ..., factorN) where the values in the responseName column have the value of the response for the named experiments and the replication id (number) for the value. The dataframe provides the data for performing a response surfacing model for the named response.

Link copied to clipboard
fun replicatedDesignPointsWithResponses(names: Set<String> = responseNames.toSet(), coded: Boolean = false): AnyFrame

Returns a data frame that has columns:

Link copied to clipboard
fun responseAsDataFrame(responseName: String): AnyFrame

Returns a data frame that has columns (exp_name, rep_id, responseName) where the values in the responseName column have the value of the response for the named experiments and the replication id (number) for the value.

Link copied to clipboard
fun resultsToCSV(fileName: String = name.replace(" ", "_") + ".csv", directory: Path = model.outputDirectory.csvDir, coded: Boolean = false)

Writes the results to a csv formatted file

Link copied to clipboard
fun simulate(iterator: Iterator<DesignPoint>, numRepsPerDesignPoint: Int? = null, clearRuns: Boolean = true, addRuns: Boolean = true)

Causes all design points to be simulated as presented by the iterator using the number of replications specified by the design points.

Link copied to clipboard
fun simulateAll(numRepsPerDesignPoint: Int? = null, clearRuns: Boolean = true, addRuns: Boolean = true)

Causes all design points to be simulated as presented by the design's default iterator using the number of replications specified by the design points.

Link copied to clipboard
open override fun toString(): String