SimulatedAnnealing

class SimulatedAnnealing @JvmOverloads constructor(evaluator: EvaluatorIfc, initialTemperature: Double = defaultInitialTemperature, var coolingSchedule: CoolingScheduleIfc = ExponentialCoolingSchedule(initialTemperature), stoppingTemperature: Double = defaultStoppingTemperature, maxIterations: Int = defaultMaxNumberIterations, replicationsPerEvaluation: ReplicationPerEvaluationIfc, streamNum: Int = 0, streamProvider: RNStreamProviderIfc = KSLRandom.DefaultRNStreamProvider, name: String? = null) : StochasticSolver(source)

A class that implements the simulated annealing optimization algorithm for solving stochastic or deterministic problems. Simulated annealing is an iterative optimization method inspired by the physical process of annealing in metallurgy. It uses a probabilistic approach to escape local optima by accepting worse solutions with a certain probability, which decreases over time according to a cooling schedule.

Parameters

evaluator

The evaluator responsible for calculating the objective function value of a solution. It must implement the EvaluatorIfc interface.

initialTemperature

The starting temperature for the simulated annealing algorithm. Must be greater than 0.0.

coolingSchedule

the cooling schedule for the annealing process

stoppingTemperature

the temperature used to stop the annealing process. If the current temperature goes below this temperature, the search process stops.

maxIterations

the maximum number of iterations permitted for the search process

replicationsPerEvaluation

An instance of ReplicationPerEvaluationIfc defining the strategy for determining the number of replications per evaluation.

rnStream

An optional random number stream used for stochastic behavior. Defaults to KSLRandom.defaultRNStream().

name

An optional name for this solver instance.

Constructors

Link copied to clipboard
constructor(evaluator: EvaluatorIfc, initialTemperature: Double = defaultInitialTemperature, coolingSchedule: CoolingScheduleIfc = ExponentialCoolingSchedule(initialTemperature), stoppingTemperature: Double = defaultStoppingTemperature, maxIterations: Int = defaultMaxNumberIterations, replicationsPerEvaluation: Int = defaultReplicationsPerEvaluation, streamNum: Int = 0, streamProvider: RNStreamProviderIfc = KSLRandom.DefaultRNStreamProvider, name: String? = null)

Secondary constructor for the SimulatedAnnealing class. This constructor provides a simplified way to initialize the Simulated Annealing algorithm with configurable parameters, while delegating certain default parameters to their respective values or functional objects.

constructor(evaluator: EvaluatorIfc, initialTemperature: Double = defaultInitialTemperature, coolingSchedule: CoolingScheduleIfc = ExponentialCoolingSchedule(initialTemperature), stoppingTemperature: Double = defaultStoppingTemperature, maxIterations: Int = defaultMaxNumberIterations, replicationsPerEvaluation: ReplicationPerEvaluationIfc, streamNum: Int = 0, streamProvider: RNStreamProviderIfc = KSLRandom.DefaultRNStreamProvider, name: String? = null)

Constructs a SimulatedAnnealing solver with the specified parameters.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Represents the difference in cost between the current solution and a potential new solution in the simulated annealing process. This value directly influences the acceptance probability of new solutions as the algorithm progresses.

Link copied to clipboard

Represents the current temperature in the simulated annealing process. It is initialized to the value of initialTemperature and dynamically updated during each iteration of the algorithm based on the cooling schedule.

Link copied to clipboard

Changing the initial temperature will also change it for the associated cooling schedule.

Link copied to clipboard

Tracks the last computed acceptance probability in the simulated annealing process.

Link copied to clipboard

Represents the temperature threshold at which the simulated annealing algorithm will stop iterating. The stopping temperature serves as a termination criterion, ensuring the optimization process concludes when the system has sufficiently cooled.

Functions

Link copied to clipboard
fun acceptanceProbability(costDifference: Double, temperature: Double): Double

Calculates the probability of accepting a new solution in the simulated annealing algorithm. The probability is determined based on the difference in cost between the current and new solutions, as well as the current temperature of the system.

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