CrossEntropySolver

class CrossEntropySolver @JvmOverloads constructor(problemDefinition: ProblemDefinition, evaluator: EvaluatorIfc, val ceSampler: CESamplerIfc = CENormalSampler(problemDefinition), maxIterations: Int = ceDefaultMaxIterations, replicationsPerEvaluation: ReplicationPerEvaluationIfc, solutionEqualityChecker: SolutionEqualityIfc = InputsAndConfidenceIntervalEquality(), name: String? = null) : StochasticSolver(source)

Constructs an instance of CrossEntropySolver with specified parameters.

Parameters

evaluator

The evaluator responsible for assessing the quality of solutions. Must implement the EvaluatorIfc interface.

ceSampler

the cross-entropy sampler for the cross-entropy distribution

maxIterations

The maximum number of iterations allowed for the search process.

replicationsPerEvaluation

Strategy to determine the number of replications to perform for each evaluation.

solutionEqualityChecker

Used when testing if solutions have converged for equality between solutions. The default is InputsAndConfidenceIntervalEquality, which checks if the inputs are the same and their is no statistical difference between the solutions

name

Optional name identifier for this instance of solver.

Constructors

Link copied to clipboard
constructor(problemDefinition: ProblemDefinition, evaluator: EvaluatorIfc, ceSampler: CESamplerIfc = CENormalSampler(problemDefinition), maxIterations: Int = ceDefaultMaxIterations, replicationsPerEvaluation: ReplicationPerEvaluationIfc, solutionEqualityChecker: SolutionEqualityIfc = InputsAndConfidenceIntervalEquality(), name: String? = null)
constructor(problemDefinition: ProblemDefinition, evaluator: EvaluatorIfc, ceSampler: CESamplerIfc = CENormalSampler(problemDefinition), maxIterations: Int = ceDefaultMaxIterations, replicationsPerEvaluation: Int = defaultReplicationsPerEvaluation, solutionEqualityChecker: SolutionEqualityIfc = InputsAndConfidenceIntervalEquality(), name: String? = null)

Constructs an instance of CrossEntropySolver with specified parameters.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

The sample size associated with the CE algorithm used to determine the elite solutions. By default, this is determined by the function recommendCESampleSize() within the companion object. The value cannot be less than defaultMinCESampleSize or greater than defaultMaxCESampleSize

Link copied to clipboard

A value between 0 and 1 that represents the proportion of the CE sample that determines the elite sample. By default, this is 0.1, which can be controlled globally via the companion object's defaultElitePct.

Link copied to clipboard

The current list of elite solutions ordered from the best

Link copied to clipboard

If supplied, this function will be used to determine the size of the elite sample during the cross-entropy process. Supplying a function can permit dynamic changes when determining the elite sample.

Link copied to clipboard

If supplied, this function will be used to determine the size of the cross-entropy sample during the cross-entropy process. Supplying a function can permit dynamic changes when determining the size of the cross-entropy sample (population).

Link copied to clipboard

Used to check if the last set of solutions that were captured are the same.

Functions

Link copied to clipboard
fun eliteSize(): Int

If eliteSizeFn is supplied it will be used; otherwise, the elite percentage is used to determine the size of the elite sample.

Link copied to clipboard
protected open override fun initializeIterations()

Subclasses may implement this function to prepare the solver before running the first iteration. Generally, it is sufficient to just implement the startingPoint() function.

Link copied to clipboard
protected open override fun isStoppingCriteriaSatisfied(): Boolean

Subclasses should implement this function to determine if the solver should continue running iterations. This will likely include some implementation of stopping criteria. This function should implement stopping criteria based on the quality of the solution. The number of iterations, compared to the maximum number of iterations, is automatically checked after each step in the iterative process. Unless overridden, this function returns false by default, which indicates that the solution quality criteria have not been satisfied. This will cause the solver to iterate through all iterations of the solution process up to the maximum number of iterations. Alternatively, the user can specify an instance of the SolutionQualityEvaluatorIfc interface to determine if the solution quality has been reached.

Link copied to clipboard
protected open override fun mainIteration()

This function should contain the logic that iteratively executes until the maximum number of iterations is reached or until the stopping criteria is met. The base implementation calls nextPoint() to determine the next point to evaluate, requests an evaluation of the point, and then updates the current solution if the resulting solution is better than the current solution. Generally, implementing startingPoint() and nextPoint() should be adequate. The property iterationCounter represents the current iteration within the mainIteration() function. That is, the value of iterationCounter is incremented prior to the execution of the mainIteration() function.

Link copied to clipboard

If sampleSizeFn is supplied it will be used; otherwise, the value of ceSampleSize is used to determine the size of the cross-entropy sample (population).

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