MemorySolutionCache

class MemorySolutionCache(val capacity: Int = defaultCacheSize, var allowInfeasibleSolutions: Boolean = false) : SolutionCacheIfc(source)

A memory-based cache to hold solutions. A simplified cache to avoid including more advanced caches in the dependency tree. This cache holds solutions in a map based on (RequestData, Solution) pairs. The cache is capacity constrained to the specified capacity. The user can supply an eviction rule that will identify a solution to evict when the capacity is reached. If no eviction rule is supplied, then by default the algorithm removes the first solution that is deterministically infeasible, infinite, or undefined in some manner. Then, it will identify the oldest solution with the largest penalized objective function for removal.

Parameters

capacity

the maximum permitted size of the cache

allowInfeasibleSolutions

if true, the input infeasible solutions are allowed to be saved in the cache. If false, input-infeasible solutions are silently ignored. The default is false (do not allow input infeasible solutions to be saved)

Constructors

Link copied to clipboard
constructor(capacity: Int = defaultCacheSize, allowInfeasibleSolutions: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open override val capacity: Int
Link copied to clipboard
open override val entries: Set<Map.Entry<RequestData, Solution>>
Link copied to clipboard
open override var evictionRule: EvictionRuleIfc?

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<Solution>

Functions

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

By default, the eviction candidate will be:

Link copied to clipboard
open operator override fun get(key: RequestData): Solution?
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open override fun put(requestData: RequestData, solution: Solution): Solution?

Places the solution into the cache. It is important that implementors handle the insertion of infeasible inputs and ensure that the input map is associated with the solution

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

Looks up and removes the solution associated with the supplied input map. Null is returned if there is no associated solution. It is important that implementor handle the reduced size relative to the cache.

Link copied to clipboard
open override fun solutions(): Solutions

Retrieves the solution in the cache as a group of solutions

Link copied to clipboard

Converts the data in the cache to a list containing instances of the SolutionData