Package-level declarations

Types

Link copied to clipboard
fun interface BoundaryHandlerIfc

Strategy interface for handling particles that move outside the input ranges. Given a continuous position, a boundary handler returns a position brought back within each input's [lowerBound, upperBound]. The handler returns a new array; it does not modify the supplied one. The result is still passed through ksl.simopt.problem.ProblemDefinition.toInputMap by the solver for granularity rounding before evaluation.

Link copied to clipboard

Clamps each coordinate to its input range: values below the lower bound become the lower bound, values above the upper bound become the upper bound. This is the default boundary handler.

Link copied to clipboard

If supplied, this function determines the cognitive and social acceleration coefficients (c1, c2) each iteration, overriding the scalar ParticleSwarmSolver.cognitiveCoefficient and ParticleSwarmSolver.socialCoefficient. The returned pair is (c1, c2).

Link copied to clipboard
class ConstantInertia(initialInertia: Double = ParticleSwarmSolver.defaultInitialInertia) : InertiaWeightSchedule

A constant inertia-weight schedule: the inertia weight is the same at every iteration.

Link copied to clipboard
abstract class InertiaWeightSchedule(initialInertia: Double) : InertiaWeightScheduleIfc

Abstract base class for inertia-weight schedules.

Link copied to clipboard

Defines the inertia-weight schedule used by particle swarm optimization. The inertia weight scales the contribution of a particle's previous velocity at each iteration, trading off exploration (large weight) for exploitation (small weight) as the search progresses. This is the PSO analogue of the simulated-annealing cooling schedule.

Link copied to clipboard
class LinearDecreasingInertia(initialInertia: Double = ParticleSwarmSolver.defaultInitialInertia, finalInertia: Double = ParticleSwarmSolver.defaultFinalInertia, horizon: Int = ParticleSwarmSolver.psoDefaultMaxIterations) : InertiaWeightSchedule

A linearly decreasing inertia-weight schedule. The inertia weight decreases linearly from initialInertia toward finalInertia over horizon iterations, then is held at finalInertia. This is the most common PSO inertia schedule.

Link copied to clipboard
class Particle

A mutable holder for the per-iteration state of a single particle in a particle swarm. A particle moves in continuous space: its position and velocity are off-grid coordinate vectors. The particle is evaluated at the granular point obtained by rounding position to the problem's granularity; that evaluated Solution is its currentSolution. The particle remembers its personal best Solution (bestSolution) and the continuous position at which it occurred (bestPosition).

Link copied to clipboard
class ParticleSwarmSolver @JvmOverloads constructor(problemDefinition: ProblemDefinition, evaluator: EvaluatorIfc, streamNum: Int = 0, streamProvider: RNStreamProviderIfc = RNStreamProvider(), swarmSize: Int = defaultSwarmSize, inertiaSchedule: InertiaWeightScheduleIfc? = null, cognitiveCoefficient: Double = defaultCognitiveCoefficient, socialCoefficient: Double = defaultSocialCoefficient, boundaryHandler: BoundaryHandlerIfc = ClampToBounds(), velocityInitializer: VelocityInitializerIfc = ZeroVelocity(), maximumIterations: Int = psoDefaultMaxIterations, replicationsPerEvaluation: ReplicationPerEvaluationIfc, solutionEqualityChecker: SolutionEqualityIfc = InputsAndConfidenceIntervalEquality(), name: String? = null) : StochasticSolver

A global-best (gbest) Particle Swarm Optimization (PSO) solver for simulation optimization.

Link copied to clipboard

Reflects overshoot back into the input range: a value that exceeds a bound is mirrored back inside by the amount of the overshoot. A final clamp guards against a reflection that would overshoot the opposite bound (possible only when the overshoot exceeds the range width).

Link copied to clipboard
fun interface SwarmSizeFnIfc

If supplied, this function determines the swarm size during the particle swarm process, overriding the scalar ParticleSwarmSolver.swarmSize.

Link copied to clipboard

Initializes each velocity component uniformly on [-vMax_d, +vMax_d]. Coordinates with a non-positive maximum speed are initialized to zero.

Link copied to clipboard

Strategy interface for initializing a particle's velocity at the start of a run. Randomness is drawn through the supplied solver's single random number stream (ParticleSwarmSolver.rnStream).

Link copied to clipboard

Initializes every particle's velocity to zero. This is the default and a common, stable choice: the swarm is initially driven only by the cognitive and social pulls.