MemorySimulationRunCache

A memory-based cache to hold simulation runs. A simplified cache to avoid including more advanced caches in the dependency tree. This cache holds simulation runs in a map based on (RequestData, SimulationRun) pairs. The cache capacity is constrained to the specified capacity. The user can supply an eviction rule that will identify a simulation run to evict when the capacity is reached. If no eviction rule is supplied, then by default, the algorithm removes the oldest simulation run.

Parameters

capacity

the maximum permitted size of the cache

map

the map to use as the cache. The map must be mutable.

Throws

if the capacity is less than 2.

Constructors

Link copied to clipboard
constructor(capacity: Int = defaultCacheSize)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val capacity: Int
Link copied to clipboard
Link copied to clipboard

A rule to govern which solution should be evicted when the cache capacity is met.

Link copied to clipboard
open override val keys: Set<RequestData>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: Collection<SimulationRun>

Functions

Link copied to clipboard

Computes the box plot summaries for the data within the map

Link copied to clipboard
open fun clear()

Removes all items from the cache

Link copied to clipboard

Computes the confidence intervals for the data in the map

Link copied to clipboard
open override fun containsKey(key: RequestData): Boolean
Link copied to clipboard
open override fun containsValue(value: SimulationRun): Boolean
Link copied to clipboard

By default, the eviction candidate will be the oldest request in the cache.

Link copied to clipboard
open operator override fun get(key: RequestData): SimulationRun?
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard

The map of arrays is considered rectangular if all arrays in the map have the same number of elements (same size).

Link copied to clipboard
open override fun put(requestData: RequestData, simulationRun: SimulationRun): SimulationRun?

Places the simulation run into the cache. It is important that implementors ensure that the input names and response names associated with the request are consistent with the input names and response names of the simulation run.

Link copied to clipboard
open fun putAll(from: Map<out RequestData, SimulationRun>)

Places all input-solution pairs into the cache

Link copied to clipboard
open override fun remove(requestData: RequestData): SimulationRun?

Looks up and removes the simulation run associated with the supplied request. Null is returned if there is no associated simulation run. It is important that implementors handle the reduced size relative to the cache.

Link copied to clipboard

Retrieves the simulation runs associated with the requests

Link copied to clipboard
open operator fun set(requestData: RequestData, simulationRun: SimulationRun)

Allows use of bracket operator for setting values

Link copied to clipboard
open override fun simulationRuns(): List<SimulationRun>

Retrieves the simulation runs in the cache as a list of simulation runs

Link copied to clipboard
fun <K, V : Comparable<V>> Map<K, V>.sortMapByValue(): Map<K, V>
Link copied to clipboard
Link copied to clipboard

Computes the statistical summaries for the data within the map

Link copied to clipboard

Converts the data map to a 2-D array. The values of the map are extracted

Link copied to clipboard
fun Map<String, DoubleArray>.toDataFrame(): AnyFrame

Converts the data stored in each array to columns within a DataFrame, with the column names as the key from the map and the columns holding the data. Each array must have the same size.

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

Converts the inner DoubleArray to List

Link copied to clipboard
fun Map<String, DoubleArray>.toObservationData(tableName: String = "tblObservations", context: String? = null, subject: String? = null): List<ObservationDataDb>

Converts the data map to a long format view of the observations.

Link copied to clipboard
fun validatePair(requestData: RequestData, simulationRun: SimulationRun): Boolean

Validates whether a given RequestData instance is compatible with a specified SimulationRun instance.