Package-level declarations

Types

Link copied to clipboard
open class ConfidenceIntervalEquality(level: Double = DEFAULT_CONFIDENCE_LEVEL, indifferenceZone: Double = 0.0) : SolutionEqualityIfc

Checks for equality between solutions based whether the confidence interval on the difference contains the indifference zone parameter.

Link copied to clipboard
@Serializable
data class EstimatedResponse(val name: String, val average: Double, val variance: Double, val count: Double) : EstimatedResponseIfc

Represents an estimated response based on an independent sample. For the case of sample size 1 (count equals 1), the variance will be undefined (Double.NaN).

Link copied to clipboard

An interface to define basic statistics for something that is estimated.

Link copied to clipboard
class EstimateResponseComparator(level: Double = DEFAULT_CONFIDENCE_LEVEL, indifferenceZone: Double = 0.0) : Comparator<EstimatedResponseIfc>
Link copied to clipboard
@Serializable
data class EvaluationRequest @JvmOverloads constructor(val modelIdentifier: String, val modelInputs: List<ModelInputs>, val crnOption: Boolean = false, val cachingAllowed: Boolean = true)

An evaluation request is used to request simulation oracle execution on a model.

Link copied to clipboard
class Evaluator @JvmOverloads constructor(val problemDefinition: ProblemDefinition, simulator: SimulationOracleIfc, val cache: SolutionCacheIfc? = null) : EvaluatorIfc

An evaluator should communicate with the simulation oracle to determine solutions for requests for evaluation from solvers.

Link copied to clipboard
interface EvaluatorIfc
Link copied to clipboard
class FeasibilityFirstComparator(val overallCILevel: Double = 0.99) : Comparator<Solution>

A clock-independent, feasibility-first ordering used to select the recommended solution — distinct from the penalized-objective ordering (Solution.compareTo) used to guide the search within an iteration.

Link copied to clipboard

This solution comparator returns 0 if the inputs are the same for the two solutions. If the solutions do not have the same inputs, then the penalized objective function is used to determine the ordering. Thus, two solutions are considered the same if they have the same input values, regardless of the value of the objective functions.

Link copied to clipboard
class InputsAndConfidenceIntervalEquality(level: Double = DEFAULT_CONFIDENCE_LEVEL, indifferenceZone: Double = 0.0) : ConfidenceIntervalEquality

Checks for equality between solutions based whether the confidence interval on the difference contains the indifference zone parameter and whether the input variable values are the same.

Link copied to clipboard

One observation of a single response at a design point — the single-response form of ResponseFunctionIfc, in the style of ksl.utilities.mcintegration.MCReplicationIfc extended with design-point inputs. The same component contract applies: acquire all randomness at construction from the provider the instance was built against, and be pure apart from consuming those streams.

Link copied to clipboard
class MCReplicationOracle @JvmOverloads constructor(val modelIdentifier: String, val responseName: String, replicationFunctionBuilder: (streamProvider: RNStreamProviderIfc) -> MCReplicationFunctionIfc, microRepSampleSize: Int = 1, streamProvider: RNStreamProviderIfc = RNStreamProvider(), streamTapePolicy: StreamTapePolicy = StreamTapePolicy()) : SimulationOracleIfc

A convenience adaptor: a single-response SimulationOracleIfc over a static Monte Carlo replication function. All behavior (macro/micro replication semantics, provider-wide stream positioning, CRN, contract enforcement, failure mapping, thread confinement) is delegated to a ResponseFunctionOracle over the single response.

Link copied to clipboard
@Serializable
data class ModelInputs(val modelIdentifier: String, val numReplications: Int, val inputs: Map<String, Double> = emptyMap(), val responseNames: Set<String> = emptySet(), val requestTime: Instant = Clock.System.now())

The data associated with a request for a simulation evaluation. A critical aspect of this implementation is how the equality of instances is determined.

Link copied to clipboard
class ModelNotProvidedException(message: String? = null, cause: Throwable? = null) : Exception
Link copied to clipboard

Compares solutions based on granular objective function values.

Link copied to clipboard
data class ParallelEvaluationOptions(val enabled: Boolean = false, val numWorkers: Int? = null, val shortCircuitSinglePoint: Boolean = true)

Options that select and configure parallel evaluation when building an evaluator via Evaluator.createProblemEvaluator (and the Solver.create* factories that delegate to it).

Link copied to clipboard
class ParallelSimulationProvider @JvmOverloads constructor(modelBuilder: ModelBuilderIfc, modelConfiguration: Map<String, String>? = null, baseRunParameters: ExperimentRunParametersIfc? = null, templateModel: Model? = null, simulationRunCache: SimulationRunCacheIfc? = null, shortCircuitSinglePoint: Boolean = true, dispatcher: CoroutineDispatcher = Dispatchers.IO.limitedParallelism(SimulationDispatcher.availableProcessors)) : SimulationOracleIfc

A SimulationOracleIfc that executes the points of an EvaluationRequest concurrently, each on its own freshly built Model, honoring the request's common-random-numbers (CRN) vs. independent stream choice through per-point run parameters.

Link copied to clipboard

A comparator for solutions based on the penalized objective function values.

class PenalizedObjectiveFunctionConfidenceIntervalComparator(level: Double = DEFAULT_CONFIDENCE_LEVEL, indifferenceZone: Double = 0.0) : Comparator<Solution>

Checks for equality between solutions based whether the confidence interval on the difference contains the indifference zone parameter.

Link copied to clipboard
class PenalizedObjectiveFunctionEquality(val solutionPrecision: Double = defaultNumericalPrecision) : SolutionEqualityIfc

Equality of the solutions is based on the penalized objective function values being within a specific precision.

Compares solutions based on granular penalized objective function values.

Link copied to clipboard

Builds a fresh ResponseFunctionIfc bound to the supplied stream provider — the response-function counterpart of ksl.simulation.ModelBuilderIfc. Concurrent execution creates one instance per member, each against that member's own identically seeded provider, so members are isolated while remaining reproducible.

Link copied to clipboard
fun interface ResponseFunctionIfc

One observation of every response at a design point. Implementations are small components in the standard KSL style: they acquire ALL of their randomness at construction time from the stream provider they are built against (typically as random variables with explicit stream numbers, exactly like a simulation model's random variables), and each call to the replication function makes one noisy observation by drawing from those pre-acquired streams.

Link copied to clipboard
class ResponseFunctionOracle @JvmOverloads constructor(val modelIdentifier: String, val responseNames: Set<String>, responseFunctionBuilder: ResponseFunctionBuilderIfc, val microRepSampleSize: Int = 1, streamProvider: RNStreamProviderIfc = RNStreamProvider(), streamTapePolicy: StreamTapePolicy = StreamTapePolicy()) : SimulationOracleIfc

A SimulationOracleIfc over a response function instead of a discrete-event simulation model. Everything above the oracle seam — caching, common random numbers, solution merging, the solvers, and the concurrent execution substrate — is oracle-agnostic, so a cheap synthetic problem (noisy test function, static Monte Carlo model) evaluated through this class exercises exactly the same machinery as an expensive simulation.

Link copied to clipboard
@Serializable
data class ResponseMap(val modelIdentifier: String, val responseNames: Set<String>, map: MutableMap<String, EstimatedResponse> = mutableMapOf()) : Map<String, EstimatedResponse>

A response map holds replication data from evaluations of the simulation oracle. The key to the map is the response name, which should match a named response within the simulation model and within the problem definition. The associated list of doubles is the within replication average for each replication.

Link copied to clipboard
class SearchStateSnapshot(val bestFeasibleObjective: Double? = null, val bestOverallObjective: Double? = null)

A snapshot of solver-level search state captured at evaluation time and carried on a Solution, for self-scaling penalty functions (e.g., near-feasibility-threshold schemes) that need global context rather than only per-solution memory. Null until such penalties are used; populating it is a future (solver-level) concern.

Link copied to clipboard

An interface to define something that can simulate evaluation requests.

Link copied to clipboard

This simulation provider will execute evaluation requests on the same model and collect the desired responses. This provider runs the model's replications locally and sequentially in the same execution thread as the requests.

Link copied to clipboard

An interface that promises to run simulations on instances of input/output pairs. The keys of the map are evaluation requests for a specific number of replications for specific input variable values. The associated ResponseMap represents the desired responses from the simulation. It should contain the replication averages for each desired response.

Link copied to clipboard
class SimulationRunException(val simulationRun: SimulationRun, message: String? = simulationRun.runErrorMsg, cause: Throwable? = null) : Exception
Link copied to clipboard
abstract class SimulationService(val simulationRunCache: SimulationRunCacheIfc? = null) : SimulationServiceIfc
Link copied to clipboard

This simulation service will execute evaluation requests on models and collect the desired responses.

Link copied to clipboard
data class Solution(val inputMap: InputMap, val estimatedObjFnc: EstimatedResponse, val responseEstimates: List<EstimatedResponse>, val evaluationNumber: Int, val isValid: Boolean = true, val id: Int = solutionCounter++, val penaltyMemory: Map<String, PenaltyMemory> = emptyMap(), val searchState: SearchStateSnapshot? = null) : Comparable<Solution> , FeasibilityIfc, EstimatedResponseIfc

A solution represents the evaluated inputs for on a problem definition. Solution also implements the EstimatedResponseIfc interface by delegating to the supplied estimated objective function. The FeasibilityIfc interface is implemented by delegating to the supplied input map.

Link copied to clipboard
class SolutionChecker(var equalityChecker: SolutionEqualityIfc = InputEquality, noImproveThreshold: Int = defaultNoImproveThreshold)

A solution checker holds solutions up to a capacity (threshold). The solution checker will hold a maximum number of solutions to check (capacity/threshold). If the contained solutions all test as equal, then the checker returns true.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun interface SolutionEqualityIfc

A functional interface for checking if two solutions are equal.

Link copied to clipboard
class Solutions(capacity: Int = defaultCapacity, var allowInfeasibleSolutions: Boolean = false) : SolutionsIfc

Class to support a group of solutions (all containing inputs, responses, objective fns, penalties) The solutions are naturally ordered by comparison of Solution instances based on their penalized objective functions (without regard to sampling error).

Link copied to clipboard
interface SolutionsIfc : List<Solution>
Link copied to clipboard
class StreamTapePolicy(initialPosition: Int = 0)

Computes the sub-stream advance applied before each point of an EvaluationRequest is run, so that consecutive requests draw fresh, non-overlapping random numbers — exactly the way a reused model's streams advance continuously in SimulationProvider.

Functions

Link copied to clipboard
fun List<Solution>.toDataFrame(): AnyFrame

Returns a DataFrame of the data associated with the solutions.

Link copied to clipboard

Returns a map of the data associated with the solutions.

Link copied to clipboard

A simple extension function to compute the total number of replications within a set of evaluation requests.