object
particle_swarm_optimization(Problem,RandomAlgorithm)
Problem- Problem object implementingparticle_swarm_optimization_protocol.RandomAlgorithm- Random number generator algorithm for thefast_randomlibrary.
Continuous bounded global-best particle swarm optimization algorithm. Parameterized by a problem object implementing the particle_swarm_optimization_protocol protocol and by a random number generator algorithm for the fast_random library. The algorithm minimizes or maximizes the fitness function defined by the problem.
logtalk_load(particle_swarm_optimization(loader))static, context_switching_calls
Algorithm: Uses synchronous global-best particle swarm optimization. Every particle update in an iteration uses the global best from the start of that iteration.
Optimization objective: The
objective(minimize|maximize)option selects the fitness ordering. Fitness values are otherwise used unchanged.Target fitness: The
target_fitness(Fitness)option stops the run when the best fitness reaches or passes the target in the selected objective direction.Stagnation stopping: The
stagnation_iterations(N)option stops the run afterNconsecutive iterations without a strict global-best improvement; zero disables this condition.Initial velocities: If the problem defines
initial_velocities/1, its velocities are validated and used. Otherwise, velocities are sampled randomly.Boundary handling: Velocities are limited to plus or minus the range of each dimension. A position crossing a bound is clamped to that bound and its velocity component is set to zero.
Progress reporting: If the problem object defines
progress/5, it is called periodically and once when the loop terminates.Seed control: The
seed(S)option initializes the random number generator for reproducible runs.
Public predicates
run/2
Runs the particle swarm optimization algorithm using default options and returns the best position and fitness found.
staticrun(BestPosition,BestFitness)run(-list(number),-number) - onerun/3
Runs the particle swarm optimization algorithm using the given options and returns the best position and fitness found.
staticrun(BestPosition,BestFitness,Options)run(-list(number),-number,+list(compound)) - one
objective(Objective)option: Optimization objective, eitherminimizeormaximize(default:minimize).
target_fitness(Fitness)option: Numeric target that stops the run when reached or passed in the selected objective direction (default:none).
max_iterations(N)option: Maximum number of swarm iterations (default:1000).
stagnation_iterations(N)option: Number of consecutive iterations without a strict global-best improvement before stopping; zero disables this condition (default:0).
inertia_weight(W)option: Velocity inertia weight (default:0.7298).
cognitive_coefficient(C)option: Personal-best acceleration coefficient (default:1.49618).
social_coefficient(C)option: Global-best acceleration coefficient (default:1.49618).
updates(N)option: Number of progress reports during the run; zero disables reporting (default:0).
seed(S)option: Positive integer random seed for reproducible runs.
run/4
Runs the particle swarm optimization algorithm using the given options and returns the best position, best fitness, and run statistics.
staticrun(BestPosition,BestFitness,Statistics,Options)run(-list(number),-number,-list(compound),+list(compound)) - one
Statistics list: A list containing
iterations(N),evaluations(E),improvements(I),final_mean_fitness(M), andfinal_diversity(D). Improvements are measured in the selected objective direction.
Protected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)