Particle Swarm Solver
A global-best (gbest) Particle Swarm Optimization (PSO) solver for simulation optimization.
Each call to mainIteration performs one swarm move: every particle's velocity is updated from its inertia, its pull toward its personal best, and its pull toward the single shared global best; the velocity is clamped to a per-coordinate maximum; the particle's continuous position is advanced and brought back within the input ranges by the boundaryHandler; and the whole swarm is then evaluated in a single batch oracle call (via the inherited requestEvaluations), so a parallel evaluator fans the particles across workers with no concurrency code here. Per particle, the personal best is refreshed and the global best (the inherited currentSolution, hence bestSolution) is updated.
Particles move in continuous space; only the evaluated position is snapped to granularity (via ProblemDefinition.toInputMap), avoiding granularity lock-in. All randomness is drawn through the solver's single random number stream (rnStream), so a run is reproducible for a fixed stream number.
Parameters
the problem being solved
the evaluator responsible for assessing the quality of solutions
the random number stream number; 0 (the default) means the next available stream
the provider of random number streams; defaults to a fresh RNStreamProvider
the number of particles in the swarm
the inertia-weight schedule; when omitted (null) a LinearDecreasingInertia is created whose horizon matches maximumIterations, so the weight decays across the whole run (raising maximumIterations without also passing a schedule no longer leaves the tail at floor inertia)
the cognitive acceleration coefficient c1 (pull toward personal best)
the social acceleration coefficient c2 (pull toward global best)
how out-of-range positions are handled; defaults to ClampToBounds
how initial velocities are set; defaults to ZeroVelocity
the maximum number of iterations
strategy to determine the number of replications per evaluation
used to detect no-improvement convergence. The default is InputsAndConfidenceIntervalEquality.
an optional name for the solver
Constructors
Constructs a particle swarm solver using a fixed number of replications per evaluation.
Properties
The boundary handler for out-of-range positions. Cannot be changed while the solver is running.
If supplied, this function determines (c1, c2) each iteration, overriding the scalars.
The cognitive acceleration coefficient c1 (pull toward the personal best). Must be >= 0.
Structured, ordered snapshot of the solver's configuration — the same fields the toString implementations expose, in a form that downstream consumers can iterate (reporting, machine-readable summary artifacts, "compare two runs" tooling).
When true, the search stops once the normalized swarm diameter falls to or below diameterThreshold (in addition to the no-improvement criterion). Enabled by default.
The normalized swarm-diameter threshold for convergence. The normalized diameter is the swarm's bounding-box diagonal divided by the search-space diagonal (in 0,1). Must be > 0.
The current global best solution (equal to the inherited bestSolution).
The inertia-weight schedule. Cannot be changed while the solver is running.
The social acceleration coefficient c2 (pull toward the global best). Must be >= 0.
Used to check whether the most recent best solutions have converged (no improvement).
The number of particles in the swarm. Must be at least defaultMinSwarmSize.
If supplied, this function determines the swarm size, overriding swarmSize.
When true, the whole swarm is evaluated under common random numbers within an iteration (which disables caching for that batch). Default is false.
The velocity initializer. Cannot be changed while the solver is running.
The fraction of each input's range used as that coordinate's maximum speed (velocity clamp). Must be in (0,1].
Functions
A hook for subclasses to inject their specific internal state metrics into the snapshot without having to override the entire makeSolverStateSnapshot method.
Subclasses may implement this function to prepare the solver before running the first iteration. Generally, it is sufficient to just implement the startingPoint() function.
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.
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.
The effective swarm size: swarmSizeFn if supplied, otherwise swarmSize.