Next Article in Journal
Far-Infrared Star Formation Rates of Quasar Host Galaxies from Multiwavelength Spectral Energy Distribution Decomposition
Previous Article in Journal
Research on Physics-Informed Transformer for Space Object Shape Classification
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Cosmological Parameter Estimation Using Particle Swarm Optimization

by
Daniel Morales Hernández
1,
Gabriela Garcia-Arroyo
2,* and
J. Alberto Vazquez
2,*
1
Instituto de Física, Universidad Nacional Autónoma de México, Ciudad de México 04510, Mexico
2
Instituto de Ciencias Físicas, Universidad Nacional Autónoma de México, Cuernavaca 62210, Mexico
*
Authors to whom correspondence should be addressed.
Universe 2026, 12(7), 212; https://doi.org/10.3390/universe12070212
Submission received: 4 June 2026 / Revised: 9 July 2026 / Accepted: 11 July 2026 / Published: 16 July 2026
(This article belongs to the Section Cosmology)

Abstract

The quest for a theoretical framework and ingredients that capture our current understanding of the cosmos has motivated the design of a large number of highly informative experiments, generating an abundant flow of data. Given this quantity of data and the need for thorough analysis, the main aim of this work is to present and assess the Particle Swarm Optimization (PSO) algorithm as a complementary tool to conventional cosmological data analysis techniques. PSO is one of the most representative bio-inspired algorithms, offering good robustness for high-dimensional or complex problems while remaining relatively simple to implement and requiring only a few hyperparameters. In this study, we employ two standard variants of the canonical PSO algorithm—global best and local best—to investigate dark energy models using measurements of Type Ia Supernovae and Baryon Acoustic Oscillations, focusing in particular on the DESI and DESI + Union3 datasets. Our findings demonstrate that PSO effectively recovers the best-fit parameters from observational data and show that, under suitable conditions, PSO can achieve results comparable to those of traditional MCMC techniques, but in a significantly reduced computation time. Moreover, the solutions obtained with PSO can be used as high-quality initial conditions for MCMC analyses, thereby accelerating their convergence.

1. Introduction

Current measurements of the universe offer compelling evidence that it is not only expanding but also doing so at an accelerating rate. The evidence for the expansion started with Vesto Slipher’s redshift data [1], followed by Edwin Hubble’s distance–velocity relation for galaxies [2], whereas the accelerated expansion was established later by observations of Type Ia Supernovae (SNIa) [3,4]. These findings, combined with General Relativity, established the foundations of modern cosmology and led to the establishment of the Λ CDM model, often referred to as the concordance model due to its consistency with a wide range of observational data, including data from the Cosmic Microwave Background (CMB) [5], Baryon Acoustic Oscillations (BAOs) [6], Large-Scale Structure (LSS) [7], and SNIa [8], among many others.
Despite its simplicity and remarkable success, the  Λ CDM model still faces several challenges [9]. These include small-scale problems, such as the Core–Cusp problem and the Too Big to Fail problem [10]. Moreover, the lack of compelling results in the direct detection of dark matter continues to raise questions about its nature. The model is further affected by the problem of the cosmological constant, Λ , namely, the significant discrepancy between the observed value and its predictions by quantum field theory [11,12]. Another prominent issue is what is known as the Hubble tension, referring to the mismatch between local determinations of the Hubble constant H 0  [13] and the value inferred from CMB observations, assuming the Λ CDM framework [14]. Moreover, recent BAO measurements from the Dark Energy Spectroscopic Instrument (DESI), when analyzed jointly with CMB and SNIa data, put the Λ CDM model under strain at more than 3 σ significance and instead point toward a dynamical dark energy component characterized by at least two additional parameters [15,16]. These discrepancies motivate exploring extensions of the Λ CDM model by relaxing one or more of its fundamental assumptions [17,18]. In particular, dark energy (DE) scenarios featuring a time-dependent equation of state (EoS) have been widely investigated as alternatives to the cosmological constant [19,20,21,22], enabling a more versatile characterization of cosmic acceleration. However, such extensions come with extra free parameters, which increase the model’s complexity and, consequently, make conventional inference methods more computationally expensive.
A central challenge in contemporary cosmology is to infer the parameter values that best reproduce the observational data for a given theoretical model, a problem usually tackled with Markov Chain Monte Carlo (MCMC) techniques (for an extensive review of MCMC algorithms in cosmology, see [23,24,25,26]). Despite their widespread use, these methods can become computationally expensive when the parameter space is high-dimensional, when the parameters are strongly correlated, or when the likelihood surface contains several local maxima or even discontinuities [27,28]. Such drawbacks motivate the exploration of alternative optimization strategies to accelerate convergence; increase efficiency; and improve the sampling of complex, high-dimensional parameter spaces [29,30,31].
In this work, we employ the Particle Swarm Optimization (PSO) algorithm, originally proposed by James Kennedy and Russel C. Eberhart in 1995 [32] (inspired by computer simulations of social models investigated by Reynolds in 1987 [33]), to infer the parameters from a collection of cosmological models. The PSO method was initially motivated by the collective behavior observed in social organisms, such as flocks of birds searching for food or shelter. PSO is part of the family of bio-inspired algorithms, a category that also includes genetic algorithms (GAs) and evolutionary programming (EP), both of which fall under the broader group of Evolutionary Algorithms [34]; in addition to the PSO, the Ant Colony Optimization (ACO) and Artificial Bee Colony (ABC) algorithms are classified as Swarm Algorithms. It is worth noting that numerous extensions and modifications of the original PSO, introduced by Eberhart and Kennedy, have been developed since then, such as Cooperative Particle Swarm Optimization (CPSO) [35] and Adaptive Particle Swarm Optimization (APSO) [36], among many others [37]. The primary distinction between the basic PSO algorithm and its variants lies in the number and type of hyper-parameters. While the original PSO relies mainly on random numbers to update particle positions and velocities, several variants introduce acceleration coefficients ( c 1 and c 2 ) and an inertia weight (w), the latter added by Shi and Eberhart [38] to regulate the swarm’s exploration and exploitation capabilities [39,40]. These enhancements led to what is commonly known as canonical PSO [41], which we will describe in the following sections.
The widespread adoption of PSO is largely due to its strong robustness in searching over high-dimensional spaces or dealing with complex optimization problems while remaining relatively simple to implement and requiring only a few hyperparameters. In particular, unlike genetic algorithms, PSO does not rely on explicit selection or mutation operators. By combining the intrinsic properties of PSO with the exploratory behavior, communication, and mutual influence of swarm particles, the algorithm can efficiently identify promising regions of the search space with high accuracy and in a significantly reduced runtime [40]. Consequently, the PSO algorithm is especially well suited for cosmological models characterized by high-dimensional parameter spaces and computationally expensive likelihood functions, which is precisely the scenario anticipated in upcoming cosmological analyses. PSO has already seen extensive use across multiple fields, including engineering and medicine [42,43] as well as astrophysics and cosmology [44,45,46]. In particular, ref. [44] applied PSO to cosmological parameter estimation for the standard Λ CDM model using CMB data [47], and refs. [45,46] employed it to trace periodic orbits in three-dimensional galactic potentials and for gravitational-wave data analysis, respectively. It is important to emphasize that PSO is not aiming to replace MCMC methods, which remain standard tools in cosmology. MCMC algorithms are designed to sample the entire posterior distribution, whereas PSO focuses on efficiently locating the maximum of the likelihood function, similar to the role of genetic algorithms [30]. Modern Bayesian inference frameworks already incorporate optimization routines as complementary tools to posterior sampling [48,49]. Likewise, alternative population-based Bayesian approaches have also been developed [50,51] and successfully applied to test dark energy models [52,53]. Nonetheless, the search trajectory generated by both approaches—across generations in GA or iterations in PSO—encodes useful information about the underlying posterior distribution.
The primary goal of this work is to introduce an implementation of code capable of performing rapid and precise cosmological parameter estimation for a specific model and any chosen combination of datasets. As this study is merely a proof of concept, we have restricted its scope to background-level observations; the incorporation of linear perturbations into the analysis is left for future work. We employ the two variants of the standard PSO algorithm—global best and local best—to study dark energy models using measurements of Type Ia Supernovae and Baryon Acoustic Oscillations, focusing in particular on the DESI and DESI + Union3 datasets. It is worth emphasizing that both the selected model and the dataset combinations can be easily adjusted within the code in order to explore a wide diversity of combinations. The full module generated in this analysis is publicly accessible as a modified component of the https://github.com/ja-vazquez/SimpleMC/blob/master/simplemc/analyzers/PSO_optimizer.py SimpleMC (accessed on 10 July 2026) code [54]. Finally, using the best-fit parameters, we compute the Akaike and Bayesian information criteria to perform model selection, and we apply the Fisher matrix formalism to estimate confidence intervals and produce error plots, which we then compare against MCMC posterior distributions.
The paper is organized as follows. Section 2 presents the theoretical foundation and introduces the principal equations that describe the dark energy models examined in this work. Building on this basis, Section 3 describes the inference methodology, emphasizing the use of PSO for parameter estimation and defining the criteria for model comparison, along with the observational data sets employed. Subsequently, Section 4 provides a detailed account of the PSO algorithm, including particle dynamics, the choice of hyperparameters, and the distinctions between the global best and local Best schemes. The main target of the paper is addressed in Section 5, where we implement the global best PSO for cosmological parameter estimation and present the resulting parameter values and model comparisons. Finally, Section 6 summarizes the main results and discusses the significance of PSO in cosmological studies.

2. Cosmological Framework

The standard cosmological model presumes that, on sufficiently large scales, the universe is both homogeneous and isotropic. Under this assumption, spacetime is described by the Friedmann–Lemaître–Robertson–Walker (FLRW) metric
d s 2 = d t 2 a 2 ( t ) d r 2 1 k r 2 + r 2 d θ 2 + r 2 sin 2 ( θ ) d ϕ 2 ,
where a ( t ) is the scale factor and k characterizes the spatial curvature: k = 0 corresponds to a flat universe, k > 0 to a closed one, and  k < 0 to an open geometry. Adopting this metric (Equation (1)) and treating the cosmic contents as a collection of perfect fluids, one arrives at the Friedmann equation:
H 2 = 8 π G ρ 3 k a 2 ,
where H a ˙ / a defines the Hubble parameter, while  ρ and P denote the total energy density and pressure of all components, respectively. In this framework, the expansion history of the universe is governed by its constituents, where each one satisfies the continuity equation
ρ ˙ + 3 H ( ρ + P ) = 0 .
The solution to this equation, for barotropic fluids with an equation of state (EoS) P = ω ρ , is given by
ρ ( a ) = ρ 0 exp 3 a 0 a 1 + ω ( a ) a d a ,
where ρ 0 is the present-day density and, in general, quantities with subscript ‘0’ are evaluated at the current epoch ( a = 1 ). For constant ω , this expression simplifies to the familiar power-law dependence, whereas for a time-varying ω ( a ) , one can introduce a function f such that ρ d e ( a ) = ρ d e , 0 f ( a ) . The function f ( a ) encodes the behavior of general EoS parameterizations, enabling the dark energy density to evolve in dynamical scenarios.
For a universe containing radiation (r), matter (m), spatial curvature (k), and a dark energy component ( d e ), the Friedmann equation (Equation (2)) can be rewritten as
H 2 H 0 2 = Ω r , 0 ( 1 + z ) 4 + Ω m , 0 ( 1 + z ) 3 + Ω k , 0 ( 1 + z ) 2 + Ω d e , 0 f ( z ) ,
where we have introduced the critical density ρ cr = 3 H 2 8 π G to define the dimensionless density parameters for each component as Ω i = ρ i / ρ cr . Because the radiation contribution becomes negligible at late times, we will ignore it from this point onward.
In dynamical DE scenarios, the EoS parameter ω de deviates from 1 and evolves with time. Among various possible parameterizations, a frequently used strategy is to expand ω de ( a ) in a Taylor series around a = 1 :
ω d e ( a ) = j = 0 N ( 1 a ) j ω j ,
where each coefficient ω j represents the contribution of the jth order term in the expansion. In this analysis, we keep only the lowest-order terms, which already offer a convenient framework to investigate departures from Λ CDM; this same approach can, however, be straightforwardly extended to more elaborate models.

2.1. Λ CDM Model

The Λ CDM scenario constitutes the most straightforward dark energy model, as it does not introduce any extra degrees of freedom into Equation (5). In this framework, dark energy is described by a cosmological constant with ω d e = 1 , implying f ( z ) = 1 . The parameters to be optimized are the matter density Ω m , 0 , the curvature Ω k , 0 , and the Hubble constant H 0 , while the dark energy density is determined by the relation Ω d e , 0 = 1 Ω m , 0 Ω k , 0 .

2.2. ω 0 CDM

This model represents the zeroth-order truncation of Equation (6), obtained by taking a constant equation-of-state parameter ω d e = ω 0 . For the universe to undergo accelerated expansion, ω 0 must fulfill ω 0 < 1 / 3 , with the specific case of ω 0 = 1 that reproduces the cosmological constant. Values ω 0 1 characterize the so-called quintessence-like regime, whereas ω 0 < 1 corresponds to the phantom regime [19]. Within the ω 0 CDM framework, the solution of Equation (4) expressed as a function of redshift is
f ( z ) = ( 1 + z ) 3 ( 1 + ω 0 ) .
As a result, Equation (5) contains one extra free parameter ( ω 0 ) in comparison with the Λ CDM model.

2.3. CPL

The Chevallier–Polarski–Linder (CPL) parametrization [55] corresponds to the first-order truncation of the Taylor expansion in Equation (6) and introduces a linearly varying EoS:
ω CPL ( a ) = ω 0 + ω 1 ( 1 a ) , ω CPL ( z ) = ω 0 + ω 1 z 1 + z .
In the early universe ( a 0 ), the EoS tends to ω d e = ω 0 + ω 1 , whereas at the present epoch ( a = 1 ), it becomes ω d e = ω 0 . The parameter ω 1 quantifies the slope of ω CPL at z = 0 , and its sign determines whether the EoS increases or decreases with redshift [56]. From Equation (4), the corresponding dark energy density evolves as
f ( z ) = ( 1 + z ) 3 ( 1 + ω 0 + ω 1 ) exp 3 ω 1 z 1 + z .
Thus, the CPL scenario is specified by two additional free parameters: ω 0 and ω 1 (the latter is often denoted by ω a ).

3. Parameter Estimation

To identify the cosmological model that most accurately reproduces the observational data, we begin by determining the parameter set θ i that maximizes the likelihood function L ( θ i ) . Assuming that the observational errors follow a Gaussian distribution, the likelihood can be written as [26,57,58]
L ( θ i ) exp 1 2 χ 2 ( θ i ) ,
where
χ 2 ( θ i ) = ( D th D obs ) T C 1 ( D th D obs ) ,
measures the mismatch between theoretical predictions D th , which depend on the cosmological parameters θ i , and the observational data vector D obs ; C is the covariance matrix associated with the data.
This parameter inference task can be cast as an optimization problem [44]. In this work, we employ the Particle Swarm Optimization (PSO) algorithm to carry out this optimization. While PSO is well suited to locating the minimum of χ 2 , it does not, by itself, yield estimates of parameter uncertainties or confidence regions around θ i 0 . To characterize these, we approximate the log-likelihood as Gaussian in the vicinity of its maximum:
ln L ( θ i ) = ln L ( θ i 0 ) 1 2 Δ θ i H i j Δ θ j ,
where Δ θ i = θ i θ i 0 and H i j is the Hessian matrix of second derivatives of the negative log-likelihood, evaluated at the best-fit point. Within this Gaussian approximation, the inverse of the Hessian serves as an estimator for the parameter covariance matrix, from which one can derive confidence intervals and parameter correlations. Consequently, this approach provides a local Gaussian approximation of the likelihood, yielding symmetric confidence intervals. Strongly non-Gaussian posterior distributions are more accurately characterized through full posterior sampling or more complex approximation methods, i.e., [59].
In addition to obtaining best-fit parameters and their uncertainties, we compare the relative performance of different models by examining both their goodness of fit and their complexity. For this purpose, we adopt the Akaike [60] and Bayesian [61] information criteria (AIC and BIC, respectively), which score models by combining the maximum likelihood with a penalty for complexity. The AIC penalizes the number of free parameters k, while the BIC further incorporates the total number of data points N, as follows:
A I C = 2 ln L max + 2 k ,
B I C = 2 ln L max + k ln N .
Lower AIC and BIC values correspond to models that are preferred according to their respective selection criteria.
To carry out our analysis, we employed the set of theoretical models described in the previous section together with different combinations of observational datasets. These datasets offer complementary constraints and thereby enable a consistent and unbiased comparison between models and observations. The observational samples used in this study are as follows:
  • Type Ia Supernovae. Owing to their well-standardized luminosities, SNIa serve as highly effective distance indicators. In this work, we use the most recent compilation sample of Union3:
    Union3 [62] is a compilation of 2087 SNIa drawn from 24 different datasets, providing a large and heterogeneous sample. In contrast to earlier Union analyses, it adopts a Bayesian inference framework instead of a frequentist approach, utilizes revised calibration procedures, and implements a new selection strategy.
  • Baryon Acoustic Oscillations. BAOs act as cosmological standard rulers, arising from sound waves in the early universe that left a characteristic scale imprinted on the large-scale matter distribution. Measuring this scale with different tracers of the matter field makes BAOs a powerful probe of cosmic expansion history.
    DESI BAO [15], based on the DR1 data release of the DESI survey, delivers precise BAO measurements over the redshift interval 0.1 < z < 4.16 , using more than 6 million tracers, including galaxies, quasars, and the Lyman- α forest.
We therefore constrain the cosmological parameters of several dark energy scenarios using DESI data alone and the combined dataset DESI + Union3.

4. Particle Swarm Optimization

Particle Swarm Optimization is a stochastic, population-based method originally inspired by the social interactions of birds in a flock, aiming to mimic the (seemingly) random collective motion as they search for food. In this approach, each particle in the swarm corresponds to a candidate solution, modeled as a computational agent that moves through a multidimensional search space [40]. A central feature of the algorithm is that individual behavior and group dynamics jointly determine overall performance. In other words, the success of one particle can affect its neighbors and, in turn, guide the entire swarm toward an optimal region: all particles benefit from the synergy among members. Effective performance relies on communication, shared information, accumulated experience, and dynamic adaptation.
Since its introduction in 1995, Particle Swarm Optimization has been extensively investigated and progressively refined. In this work, we outline the fundamental concepts and provide a concise, general description to convey the core idea of the algorithm; we then justify its main hyperparameters and, consequently, its implementation. For a comprehensive discussion, see [32,39,40,45,63].

4.1. Particle Dynamics

Let x i ( t ) denote the position vector of the ith particle in the swarm, located in an n-dimensional search space at time t. To enable communication and thus information sharing, the particle’s position is updated by assigning a velocity v i to its current state:
x i [ t + 1 ] = x i [ t ] + v i [ t + 1 ] .
The objective, or fitness function f, given by f : U V with U R n and V R , assesses the quality of each position and consequently governs the subsequent moves.
The velocity vector is the central element that guides the optimization and is typically decomposed into three components:
v i = v inertia + v cognitive + v social .
  • The inertia component, v i [ t ] , regulates the momentum of particle i by scaling the influence of its previous velocity on the new one, thereby avoiding abrupt changes in its direction: the particle retains memory.
  • The cognitive component, ( p i [ t ] x i [ t ] ) , measures how well particle i has performed based on its own search history. This term is often referred to as the “nostalgia” component, the inclination to return to the most favorable position encountered so far, since it is proportional to the distance between the current position of particle i and its personal best position p i = ( p i 1 , p i 2 , , p i n ) , or pbesti, defined as
    min k = 0 , , t 1 , t f ( x i [ k ] ) = f ( p i [ t ] ) .
  • The social component characterizes the performance of particle i relative to that of its neighbors. It reflects a social inclination of individuals to imitate the success of their nearby peers. The neighborhood topology determines the social structure of the algorithm. Common choices in standard PSO include the star topology, which yields the global best PSO, or Gbest, and the ring topology, which leads to the local best PSO, or Lbest.

4.2. Global Best PSO

In the Gbest PSO, the neighborhood of each particle is defined as the complete swarm, and this is implemented using a star topology; the left panel of Figure 1 depicts this type of topology. In this configuration, every particle is linked to all others; thus, at each iteration, the whole swarm is drawn toward the best solution found so far.
For the Gbest PSO, the social term is expressed as
p g [ t ] x i [ t ] ,
where p g denotes the global best, or gbest, position among all N particles in the swarm. In a minimization context, this is the position associated with the smallest fitness value, defined as
min j = 1 , , N f ( p j [ t ] ) = f ( p g [ t ] ) .
Consequently, the three components of the velocity update (Equation (15)) for the Gbest PSO reduce to
v i [ t + 1 ] = w v i [ t ] + r 1 c 1 p i [ t ] x i [ t ] + r 2 c 2 p g [ t ] x i [ t ] .
The pseudo-code, shown in Algorithm 1, outlines the procedure to implement Gbest PSO (adapted from [64]).
Algorithm 1 Global best algorithm.
Require: 
initialize: Size of the swarm N. Maximum number of iterations m a x _ i t e r .
  1:
while not (end condition) do
  2:
    for  i = ( 1 t o n )  do
  3:
         x i , v i initialize ith particle’s position and velocity.
  4:
        if  f ( x i ) < f ( p i )  then
  5:
            p i = x i
  6:
        end if
  7:
        if  f ( p i ) < f ( g ) )  then
  8:
            p i = g set best global position.
  9:
        end if
10:
    end for
11:
    for  i = ( 1 t o n )  do
12:
         v i update ith particle’s velocity using
13:
         x i ( t + 1 ) = x i ( t ) + v i ( t + 1 )
14:
    end for
15:
until the condition is satisfied
For both variants, Gbest PSO (Equation (19)) and Lbest PSO (Equation (21)), the inertia weight w mediates the trade-off between global exploration and local exploitation. The positive coefficients c 1 and c 2 , termed the cognitive and social parameters, respectively, modulate the search behavior of the swarm. The cognitive parameter c 1 enhances the particle’s individual exploration, whereas the social parameter c 2 governs the influence of the collective swarm search. To incorporate randomness into the algorithm, r 1 and r 2 U ( 0 , 1 ) are random variables uniformly distributed in the interval [ 0 , 1 ] .

4.3. Local Best PSO

In the global best configuration, particles generally converge rapidly; however, this occurs at the expense of diversity and makes the swarm more prone to becoming trapped in local optima [65]. To enhance the exploration of the search space and mitigate stagnation, the local version of PSO, known as Lbest, was proposed. The Lbest PSO variant employs small neighborhood structures in its implementation to encourage more effective search behavior, albeit with a reduced convergence speed [66].
Consider a swarm of particles S = { x 1 , x 2 , , x N } , where N denotes the total number of particles. The neighborhood of the ith particle, x i , is defined as
B i = { x n 1 , x n 2 , , x n s } ,
where N = { n 1 , n 2 , , n s } I = { 1 , 2 , , N } is the set of indices corresponding to the neighbors of x i . A frequently adopted structure for the Lbest PSO is the ring topology, in which each particle is connected to its n N closest neighbors. The particular case with n N = 2 is depicted in the right panel of Figure 1. Note that the Gbest algorithm can be regarded as a special instance of the Lbest PSO in which n N = n s .
Therefore, the structure of the velocity for Lbest PSO becomes
v i [ t + 1 ] = w v i [ t ] + r 1 c 1 p i [ t ] x i [ t ] + r 2 c 2 p g i [ t ] x i [ t ] ,
where p g i represents the best position found by the neighborhood of the ith particle. The pseudo-code, Algorithm 2, shows the steps to implement Lbest PSO (from [64]).
Algorithm 2 Local best algorithm.
Require: 
initialize: Size of the swarm N. Number of neighborhoods k. Maximum number of iterations m a x _ i t e r .
  1:
while not (end condition) do
  2:
    for  i = ( 1 t o n )  do
  3:
         x i , v i initialize ith particle’s position and velocity.
  4:
        if  f ( x i ) < f ( p i )  then
  5:
            p i = x i
  6:
        end if
  7:
        if  f ( p i ) < f ( g i ) )  then
  8:
            p i = g i set best neighborhood position.
  9:
        end if
10:
    end for
11:
    for  i = ( 1 t o n )  do
12:
         v i update ith particle’s velocity using Equation (21).
13:
         x i ( t + 1 ) = x i ( t ) + v i ( t + 1 )
14:
    end for
15:
until the end condition is satisfied
In addition to the ring topology, a few examples of local structures are the following [67,68,69]:
  • The pyramid structure forms a three-dimensional wireframe triangle.
  • In a von Neumann neighborhood, the population is arranged in a rectangular grid structure.
  • In the random structure, as its name states, particles are connected to n s random particles.

4.4. General Aspects of PSO

4.4.1. Initial Conditions

A typical strategy for selecting the particles’ initial positions is to sample them uniformly at random within the hypercube domain defined by x min and x max , that is, x i ( 0 ) U ( x min , x max ) , or, more explicitly,
x i ( 0 ) = x min , i + r i ( x max , i x min , i ) ,
with r i U ( 0 , 1 ) . In addition, the personal best position can be initialized directly from the initial position:
p i ( 0 ) = x i ( 0 ) .
If the particles are assumed to be at rest initially, their velocities can be set to zero:
v i = 0 .
The velocities may also be initialized randomly in a way analogous to the positions; however, this must be performed carefully. Various approaches for initializing both the position and the velocity of the particles have been proposed and analyzed in the literature [70,71].

4.4.2. Stopping Criteria

A straightforward stopping rule is to terminate the algorithm after a predefined number of iterations. However, this basic approach can be ambiguous: selecting an arbitrary upper limit for the iterations may lead either to premature convergence (ending the search before a sufficiently good solution is obtained) or, conversely, to unnecessary evaluations of the fitness function, thus increasing the computational cost.
A more suitable way to determine convergence is to stop when an acceptable solution has been reached, namely, when
| | f ( x i [ t ] ) f ( x * [ t ] ) | | < ε ,
where f ( x * [ t ] ) denotes the fitness function evaluated at the position x * [ t ] of the best global minimum found so far, while ε is a predefined positive tolerance level [72]. If no improvement is observed over several consecutive iterations and condition (25) remains satisfied throughout this interval, the PSO algorithm can be terminated. Appropriate choices for both the accuracy threshold and the required number of consecutive iterations help ensure that the optimal value is correctly identified.

4.4.3. Acceleration Coefficients

The choice of acceleration parameters depends on the specific goals of the search. Early formulations of PSO typically used identical values for the cognitive and social components, i.e., c 1 = c 2 . When strong global exploration is desired, both c 1 and c 2 should be set to relatively large values. In contrast, smaller values are preferable when focusing on local refinement near optimal solutions. Furthermore, by considering the geometry of the objective function, it is possible to impose additional preferences, such as c 1 < c 2 for convex unimodal objective functions [72]. To guarantee convergence, the acceleration coefficients must satisfy
c 1 + c 2 4 .
If this condition is violated, particle velocities and positions can become unbounded and diverge [40].

4.4.4. Velocity Clamping and Inertia Weight

Although the acceleration coefficients tune the search capability via the pbest and gbest values, the velocity itself can still become unbounded, allowing particles to make excessively long moves that may cause the swarm to diverge. To address this, the earliest PSO variants introduced boundary constraints so that the velocity is restricted to remain within the search space. By defining a maximum allowable velocity v max > 0 , the particle position updates are controlled through the velocity magnitude:
v i [ t + 1 ] = v i [ t + 1 ] , if v i [ t + 1 ] < v max , v max , if v i [ t + 1 ] > v max ,
where v i is computed either from Equation (19) or from Equation (21).
While the maximum velocity bound regulates the global exploration behavior of the particles, it also introduces additional challenges. If v max is set too small, more iterations are required, and the swarm is more likely to become trapped in local optima. Conversely, if v max is too large, particles may skip over promising regions and move directly into unproductive areas. Several guidelines have been proposed for choosing v max ; for instance, ref. [40] suggests
v max = δ ( x max x min ) ,
where [ x min , x max ] denotes the domain bounds, while δ ( 0 , 1 ] . The choice of δ is problem-dependent; for example, setting δ = 0.5 implies that the largest possible move of a particle corresponds to half of the search space.
The inertia weight parameter, w, can mitigate the need for a finely tuned maximum velocity v max . This parameter is widely regarded as having the strongest impact on PSO performance, as it governs the balance between exploration and exploitation and typically requires less delicate tuning [73]. In particular, small values of w promote local exploitation, so that the cognitive and social terms dominate the position updates, whereas large values of w enhance exploration by increasing swarm diversity. However, under velocity clamping, if w 1 , the velocities grow over time and the swarm diverges, while for w < 1 , the particles gradually slow down and their velocities eventually vanish.
As with velocity clamping, an appropriate choice of inertia weight is problem-specific. Nevertheless, several strategies have been proposed to obtain desirable behavior of w, and its selection must be coordinated with that of c 1 and c 2 . Some examples include the following:
  • Static inertia weight. As the term indicates, the constant w is kept unchanged throughout all swarm iterations. It has been demonstrated that if the condition
    w > 1 2 ( c 1 + c 2 ) 1
    is satisfied, then convergence of the algorithm is ensured. Shi and Eberhart [74] recommended choosing w within the range [0.9, 1.2]; otherwise, the swarm may fail to converge and instead diverge or enter into oscillatory (cyclic) patterns [40].
  • Linear time decreasing. In this strategy, w varies over time. It begins at a relatively high value and is gradually reduced to a lower value over the course of the iterations t. This linear reduction enables broader global exploration at early stages, followed by more intensive local refinement near the end [75]. The linear schedule is defined as:
    w [ t ] = w [ 0 ] w [ n t ] n t t n t + w [ n t ] ,
    where w [ 0 ] and w [ n t ] are the initial and final inertia weights, respectively, with w [ 0 ] > w [ n t ] , while n t denotes the maximum number of iterations. Typical choices of w [ 0 ] and w [ n t ] are 0.9 and 0.4 , respectively.
  • Exponential decreasing. The scheme proposed in [76] is another time-varying approach for w that aims to trade off global exploitation and local exploration. Here, the inertia weight decays exponentially as t increases. It is defined by
    w [ t ] = w [ n t ] + ( w [ 0 ] w [ n t ] ) · exp c t n t ,
    where c is a positive control parameter that determines the rate at which w converges.
Given the Gbest and Lbest algorithms, a natural question that arises is which one is more suitable for a particular optimization task. The key difference between them lies in the neighborhood topology and, consequently, in how information is shared within the swarm. In [77], the authors evaluated both approaches on several optimization benchmarks (test functions) and found that Gbest tended to converge too quickly to local optima, whereas Lbest converged more slowly but exhibited stronger exploration capabilities. They also reported that Gbest and Lbest achieved similarly accurate solutions for a comparable number of functions. Thus, the choice between Gbest and Lbest depends on the problem. Before applying them to cosmological problems, we therefore carried out a set of preliminary tests.
The PSO algorithm has been extensively modified and implemented in many programming languages. In the present study, we integrate the PySwarms Python library, described in [69], into the https://github.com/ja-vazquez/SimpleMC/blob/master/simplemc/analyzers/PSO_optimizer.py SimpleMC (accessed on 10 July 2026) code. PySwarms is advantageous because it is straightforward to implement and offers the flexibility needed to tailor the algorithm to our specific goals. Using this library, we apply the Gbest and Lbest PSO variants to compare their behaviors. The Lbest variant additionally requires two parameters to be specified: the number of neighborhoods k and a flag indicating the distance metric, which can be either Euclidean or absolute.

4.5. Testing the Code

The test functions serve as important tools for analyzing an algorithm’s performance and behavior, since their true solutions are already known. There exist a large variety of test functions with diverse properties, and locating the global optimum is considerably harder for some of them than for others. We concentrate on a small subset: we chose several functions that are multimodal, multidimensional, convex, or even discontinuous. They are shown in Figure 2 and are defined as follows:
f 1 ( x ) = x 2 , f 2 ( x ) = sin ( x ) + sin ( ( 10 / 3 ) x ) , f 3 ( x ) = x 2 , si x 1 , 2 x , si x < 1 , f 4 ( x ) = ( x + ( U ( 0 , 1 ) · 0.3 x ) ) 2 , f 5 ( x ) = cos ( x ) · cos ( y ) exp ( ( x π ) 2 ( y π ) 2 ) , f 6 ( x ) = 20 + ( x 2 10 cos ( 2 π x ) + y 2 10 cos ( 2 π y ) ) , f 7 ( x ) = x 2 + y 2 .
Table 1 presents the chosen PSO hyperparameters—selected according to the criteria discussed above—together with the outcomes obtained with the Gbest and Lbest variants. The results closely reproduce the true position and fitness values, as can be seen by comparing the last three columns.
After validating the code with several analytical test functions, we perform an analogous study, but now using a toy data problem: fitting a straight line to synthetic data.
In this case, we employ the PSO algorithm to infer the parameters m and b of a linear model ( y = m x + b ) by minimizing the chi-squared function χ 2 (Equation (10)) for a given mock data set. The synthetic data set is composed of 30 points generated from the underlying values m = 2 and b = 6 , with Gaussian noise added to each point and standard deviations, represented by black dots and red error bars in Figure 3.
To determine the best-fit parameters, we adopt the static global best PSO scheme and explore several combinations of inertia (w) and acceleration coefficients ( c 1 and c 2 ), seeking the configuration that yields the minimum value of the χ 2 function. In line with the previous procedure, the final PSO settings are reported in Table 2.
The optimization yields the following results: the minimum value of the fitness function is χ line 2 = 28.59 , with a best-fit slope m = 2.054 and intercept b = 6.025 , which are very close to the true values used to generate the data. The upper panel of Figure 3 displays the best-fitting (blue) line obtained with the PSO-derived parameters ( m , b ) , while the lower panel shows the evolution of the iterations, illustrating how the swarm particles converge toward the minimum.

5. Parameter Estimation on Dark Energy Models

We incorporated the PSO algorithm into a modified version of the https://github.com/ja-vazquez/SimpleMC/blob/master/simplemc/analyzers/PSO_optimizer.py SimpleMC (accessed on 10 July 2026) code to minimize the χ 2 function (Equation (10)) for several cosmological models: the flat Λ CDM scenario, Λ CDM with free spatial curvature (denoted Λ CDM + Ω k ), and the flat CPL model ( ω 0 ω a CDM). The Λ CDM + Ω k model is constrained using only DESI BAO data, whereas the flat Λ CDM and CPL models are constrained with a combination of DESI and Union3 supernova measurements. The set of free cosmological parameters includes Ω m , Ω k , the reduced Hubble parameter h = H 0 / 100 , and, where applicable, the dark energy equation-of-state parameters ( ω 0 , ω a ) . To guarantee a coherent scan of the parameter space, we defined the priors within which the particles can move ( [ x min , x max ] ) as h [ 0.4 , 0.9 ] , Ω m [ 0.1 , 0.5 ] , Ω b h 2 [ 0.02 , 0.025 ] , Ω k [ 0.3 , 0.3 ] , ω 0 [ 2 , 0 ] , and ω a [ 2 , 2 ] . For comparison, we also integrated into the SimpleMC framework [54] a modified version of the dynesty nested sampling algorithm, a dynamic sampling that efficiently computes the Bayesian evidence while performing parameter estimation [78,79].
As it is well established that the posterior distributions under consideration are unimodal, and to reduce computational cost, the best-fit parameters were determined by using the global best PSO scheme, adopting the hyperparameter settings identified as optimal in prior tests: w = 0.9 , c 1 = 0.5 , c 2 = 0.8 , 100 particles with uniformly random initial positions, and a static configuration, with a maximum of 150 iterations. We verified that different random realizations of the initial swarm consistently converged to the same best-fit solution within the adopted convergence criterion. We also imposed a tolerance criterion of ε > 10 5 1, stopping the algorithm if the likelihood showed no improvement after, for instance, 10 consecutive iterations. Table 3 summarizes the resulting best-fit parameters and the corresponding maximum value of the fitness function. The table further lists the AIC and BIC differences with respect to the flat Λ CDM model; positive values indicate a poorer fit, while negative values favor the extended (beyond- Λ CDM) model.
To gain deeper insight into the algorithm’s behavior, we examine the motion of the particles within the parameter space. Figure 4 and Figure 5 offer complementary perspectives on the convergence of the PSO algorithm in the parameter space for the Λ CDM+ Ω k model, depicting the locations of particles in the ( Ω m , Ω k ) plane at different stages or iterations of the optimization process. Figure 4 shows how the particles gradually cluster around the best-fit point as the number of iterations increases (from blue to pink, as indicated in the color bar). Once the best-fit values have been identified, we overlay the 68% and 95% confidence regions derived from a Fisher matrix analysis (solid red curves); for comparison, we also show the 1 and 2 σ contour levels obtained with the MCMC algorithm (contours colored purple). The resulting constraints from both methods are qualitatively indistinguishable, while PSO achieves them roughly with fewer likelihood evaluations, as shown in Table 3; the two algorithms are implemented with the same level of parallelization within the cluster. Figure 5 complements this view by presenting the particle distributions iteration by iteration in the same parameter space. The rightmost panel displays the evolution of the cost function in terms of the iteration number, summarizing the efficiency of the optimization. Note that after about 50 iterations, the algorithm has nearly converged, yet it continues to refine the solution until the target accuracy is reached. The best-fit parameters for the Λ CDM+ Ω k model obtained from DESI BAO data are in agreement with those reported by the DESI DR1 collaboration [15]. This level of consistency demonstrates the reliability of the PSO algorithm for constraining cosmological parameters from observational data and shows that, under suitable conditions, PSO can provide results comparable to those of standard MCMC-based inference pipelines in significantly reduced computational time.
We now focus on the CPL model, whose upper panel in Figure 6 shows how the particles are distributed in the ( ω 0 , ω a ) plane over successive iterations. In this case, by construction, we initialized the entire swarm far outside the target region to show how the particles’ capacity for flexible, interconnected decision-making enabled the swarm to locate a favorable region (around iteration 18) and subsequently climb toward the peak of the likelihood function. The gray dashed lines denote the Λ CDM boundary, while the 68% and 95% confidence contours derived from a Fisher matrix analysis are indicated in red for comparison. As in the previous example, we also overlay the contour levels resulting from the MCMC analysis (purple for 1 σ and lilac for 2 σ ), and the agreement between the contours is almost exact, except for a small deviation in the upper part of the ellipse. This representation demonstrates that, as the number of iterations grows (with particle colors evolving from blue to pink), the swarm gradually converges toward the best-fit region, indicated by the cross formed by the red lines. The lower panel supports this conclusion, showing that the fitness function ( χ 2 ) decreases as the iterations progress.

6. Conclusions

In this work, we have presented and assessed the Particle Swarm Optimization algorithm as an efficient tool for estimating free cosmological parameters across different dark energy models. Through its mechanisms of communication and exploration within the swarm, PSO becomes a powerful method for locating global optima in high-dimensional or multimodal functions.
We investigated the performance of the Gbest and Lbest variants of PSO in identifying global minima over one- and two-dimensional test-function landscapes. Our findings indicate that both approaches are effective at locating the optimal fitness. However, Gbest requires only three hyperparameters ( c 1 , c 2 and ω ), whereas Lbest needs five to achieve a more thorough exploration, particularly when local minima appear during the search. Motivated by this, we also employed a toy model with synthetic data to test the Gbest PSO and found that it is likewise able to recover parameter values. In addition, the paper analyzed the required PSO hyperparameters and the swarm topology needed to ensure efficient communication among particles.
We emphasize that our use of PSO focuses on maximizing the likelihood function and is not meant as a substitute for MCMC methods. Rather, PSO provides complementary benefits, such as faster convergence and accurate best-fit estimates, which can be combined with MCMC approaches. For instance, once PSO has identified the best-fit parameters and the confidence contours have been derived (perhaps via Fisher matrix analysis), these initial values and the covariance matrix can be used as informative starting points along with its proposal distribution for MCMC, thereby accelerating the overall analysis. Such features are especially relevant in cosmology, given the vast quantities of current and upcoming data, the high dimensionality of the parameter space, and the complexity of proposed cosmological models.
From a cosmological standpoint, our best-fit estimates agree well with those obtained from MCMC. Notably, when only DESI data are used, the flat Λ CDM model is slightly favored over its Ω k extension. However, when a dynamical dark energy equation of state is allowed, the CPL model is preferred over flat Λ CDM according to both the AIC and the BIC on the combined DESI and Union3 datasets. These results not only reinforce the robustness of the standard cosmological model under current observations but also highlight the potential importance of evolving dark energy scenarios. In this context, PSO emerges as a powerful and versatile optimization technique, capable of efficiently probing high-dimensional parameter spaces and aiding in cosmological model selection.

Author Contributions

Conceptualization, D.M.H., G.G.-A. and J.A.V.; methodology, D.M.H., G.G.-A. and J.A.V.; software, D.M.H. and J.A.V.; validation, D.M.H. and J.A.V.; formal analysis, D.M.H., G.G.-A. and J.A.V.; investigation, D.M.H., G.G.-A. and J.A.V.; writing—original draft preparation, D.M.H., G.G.-A. and J.A.V.; writing—review and editing, D.M.H., G.G.-A. and J.A.V. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by FOSEC SEP-CONACYT Ciencia Básica, grant number A1-S-21925, and UNAM-DGAPA-PAPIIT, grant numbers IN109126 and IN110325.

Data Availability Statement

The data analyzed in this study, together with the corresponding code required to reproduce the results, are publicly available in the SimpleMC repository at https://github.com/ja-vazquez/SimpleMC, (accessed on 10 July 2026).

Acknowledgments

G.G.-A. acknowledges the support of the SECIHTI. J.A.V. acknowledges support from FOSEC SEP-CONACYT Ciencia Básica A1-S-21925, UNAM-DGAPA-PAPIIT IN109126, IN110325 and Cátedra de Investigación Marcos Moshinsky. Special acknowledgments are directed toward Francisco Bustos and Reyes García, who assisted considerably with the high-performance computing at the ICF-UNAM.

Conflicts of Interest

The authors declare no conflicts of interest.

Note

1
The selected tolerance was determined according to the minimum difference attained by the MCMC algorithm in the vicinity of its convergence phase.

References

  1. Slipher, V.M. The radial velocity of the Andromeda Nebula. Lowell Obs. Bull. 1913, 2, 56–57. [Google Scholar]
  2. Hubble, E. A relation between distance and radial velocity among extra-galactic nebulae. Proc. Nat. Acad. Sci. USA 1929, 15, 168–173. [Google Scholar] [CrossRef] [PubMed]
  3. Riess, A.G.; Filippenko, A.V.; Challis, P.; Clocchiatti, A.; Diercks, A.; Garnavich, P.M.; Gillil, R.L.; Hogan, C.J.; Jha, S.; Kirshner, R.P.; et al. Observational evidence from supernovae for an accelerating universe and a cosmological constant. Astron. J. 1998, 116, 1009–1038. [Google Scholar] [CrossRef]
  4. Perlmutter, S.; Aldering, G.; Goldhaber, G.; Knop, R.A.; Nugent, P.; Castro, P.G.; Deustua, S.; Fabbro, S.; Goobar, A.; Groom, D.E.; et al. Measurements of Ω and Λ from 42 High Redshift Supernovae. Astrophys. J. 1999, 517, 565–586. [Google Scholar] [CrossRef]
  5. Aghanim, N.; Akrami1, Y.; Ashdown, M.; Aumont, J.; Baccigalupi, C.; Ballardini, M.; Banday, A.J.; Barreiro, R.B.; Bartolo, N.; Basak, S.; et al. Planck 2018 results. VI. Cosmological parameters. Astron. Astrophys. 2020, 641, A6, Erratum in Astron. Astrophys. 2021, 652, C4. [Google Scholar] [CrossRef]
  6. Eisenstein, D.J.; Zehavi, I.; Hogg, D.W.; Scoccimarro, R.; Blanton, M.R.; Nichol, R.C.; Scranton, R.; Seo, H.J.; Tegmark, M.; Zheng, Z.; et al. Detection of the Baryon Acoustic Peak in the Large-Scale Correlation Function of SDSS Luminous Red Galaxies. Astrophys. J. 2005, 633, 560–574. [Google Scholar] [CrossRef]
  7. Tegmark, M.; Strauss, M.A.; Blanton, M.R.; Abazajian, K.; Dodelson, S.; Sandvik, H.; Wang, X.; Weinberg, D.H.; Zehavi, I.; Bahcall, N.A.; et al. Cosmological parameters from SDSS and WMAP. Phys. Rev. D 2004, 69, 103501. [Google Scholar] [CrossRef]
  8. Suzuki, N.; Rubin, D.; Lidman, C.; Aldering, G.; Amanullah, R.; Barbary, K.; Barrientos, L.F.; Botyanszki, J.; Brodwin, M.; Connolly, N.; et al. The Hubble Space Telescope Cluster Supernova Survey: V. Improving the Dark Energy Constraints Above z>1 and Building an Early-Type-Hosted Supernova Sample. Astrophys. J. 2012, 746, 85. [Google Scholar] [CrossRef]
  9. Bull, P.; Akrami, Y.; Adamek, J.; Baker, T.; Bellini, E.; Jimenez, J.B.; Bentivegna, E.; Camera, S.; Clesse, S.; Davis, J.H.; et al. Beyond ΛCDM: Problems, solutions, and the road ahead. Phys. Dark Univ. 2016, 12, 56–99. [Google Scholar] [CrossRef]
  10. Vázquez-González, A.; Matos, T. La materia oscura del universo: Retos y perspectivas. Rev. Mex. Física E 2008, 54, 193–202. [Google Scholar]
  11. Weinberg, S. The Cosmological Constant Problem. Rev. Mod. Phys. 1989, 61, 1–23. [Google Scholar] [CrossRef]
  12. Shi, K.; Huang, Y.; Lu, T. A comprehensive comparison of cosmological models from latest observational data. Mon. Not. Roy. Astron. Soc. 2012, 426, 2452–2462. [Google Scholar] [CrossRef]
  13. Riess, A.G.; Yuan, W.; Macri, L.M.; Scolnic, D.; Brout, D.; Casertano, S.; Jones, D.O.; Murakami, Y.; An, G.S.; Breuval, L.; et al. A Comprehensive Measurement of the Local Value of the Hubble Constant with 1 km s−1 Mpc−1 Uncertainty from the Hubble Space Telescope and the SH0ES Team. Astrophys. J. Lett. 2022, 934, L7. [Google Scholar] [CrossRef]
  14. Verde, L.; Protopapas, P.; Jimenez, R. The expansion rate of the intermediate Universe in light of Planck. Phys. Dark Univ. 2014, 5–6, 307–314. [Google Scholar] [CrossRef]
  15. Adame, A.G. et al. [DESI Collaboration]. DESI 2024 VI: Cosmological Constraints from the Measurements of Baryon Acoustic Oscillations. arXiv 2024, arXiv:2404.03002. [Google Scholar] [CrossRef]
  16. Abdul Karim, M. et al. [DESI Collaboration]. DESI DR2 Results II: Measurements of Baryon Acoustic Oscillations and Cosmological Constraints. arXiv 2025, arXiv:2503.14738. [Google Scholar] [CrossRef]
  17. Di Valentino, E.; Said, J.L.; Riess, A.; Pollo, A.; Poulin, V.; Gómez-Valent, A.; Weltman, A.; Palmese, A.; Huang, C.D.; van de Bruck, C.; et al. The CosmoVerse White Paper: Addressing observational tensions in cosmology with systematics and fundamental physics. Phys. Dark Univ. 2025, 49, 101965. [Google Scholar] [CrossRef]
  18. Arun, K.; Gudennavar, S.B.; Sivaram, C. Dark matter, dark energy, and alternate models: A review. Adv. Space Res. 2017, 60, 166–186. [Google Scholar] [CrossRef]
  19. Copeland, E.J.; Sami, M.; Tsujikawa, S. Dynamics of dark energy. Int. J. Mod. Phys. D 2006, 15, 1753–1936. [Google Scholar] [CrossRef]
  20. Linder, E.V. Exploring the expansion history of the universe. Phys. Rev. Lett. 2003, 90, 091301. [Google Scholar] [CrossRef] [PubMed]
  21. Chevallier, M.; Polarski, D. Accelerating universes with scaling dark matter. Int. J. Mod. Phys. D 2001, 10, 213–224. [Google Scholar] [CrossRef]
  22. Escamilla, L.A.; Pan, S.; Di Valentino, E.; Paliathanasis, A.; Vázquez, J.A.; Yang, W. Testing an oscillatory behavior of dark energy. Phys. Rev. D 2025, 111, 023531. [Google Scholar] [CrossRef]
  23. Lewis, A.; Bridle, S. Cosmological parameters from CMB and other data: A Monte Carlo approach. Phys. Rev. D 2002, 66, 103511. [Google Scholar] [CrossRef]
  24. Trotta, R. Bayesian Methods in Cosmology. arXiv 2017, arXiv:1701.01467. [Google Scholar] [CrossRef]
  25. Gilks, W.R.; Richardson, S.; Spiegelhalter, D. Markov Chain Monte Carlo in Practice; CRC Press: Boca Raton, FL, USA, 1995. [Google Scholar]
  26. Padilla, L.E.; Tellez, L.O.; Escamilla, L.A.; Vazquez, J.A. Cosmological Parameter Inference with Bayesian Statistics. Universe 2021, 7, 213. [Google Scholar] [CrossRef]
  27. Akarsu, Ö.; Barrow, J.D.; Escamilla, L.A.; Vazquez, J.A. Graduated dark energy: Observational hints of a spontaneous sign switch in the cosmological constant. Phys. Rev. D 2020, 101, 063528. [Google Scholar] [CrossRef]
  28. Vázquez, J.A.; Tamayo, D.; Sen, A.A.; Quiros, I. Bayesian model selection on scalar ϵ-field dark energy. Phys. Rev. D 2021, 103, 043506. [Google Scholar] [CrossRef]
  29. Gómez-Vargas, I.; Vázquez, J.A. Deep learning and genetic algorithms for cosmological Bayesian inference speed-up. Phys. Rev. D 2024, 110, 083518. [Google Scholar] [CrossRef]
  30. Medel-Esquivel, R.; Gómez-Vargas, I.; Sánchez, A.A.M.; García-Salcedo, R.; Alberto Vázquez, J. Cosmological Parameter Estimation with Genetic Algorithms. Universe 2024, 10, 11. [Google Scholar] [CrossRef]
  31. Gómez-Vargas, I.; Andrade, J.B.; Vázquez, J.A. Neural networks optimized by genetic algorithms in cosmology. Phys. Rev. D 2023, 107, 043509. [Google Scholar] [CrossRef]
  32. Kennedy, J.; Eberhart, R. Particle swarm optimization. In Proceedings of ICNN’95—International Conference on Neural Networks; IEEE: Piscataway, NJ, USA, 1995. [Google Scholar] [CrossRef]
  33. Reynolds, C.W. Flocks, herds and schools: A distributed behavioral model. In Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques; Association for Computing Machinery: New York, NY, USA, 1987; pp. 25–34. [Google Scholar]
  34. Darwish, A. Bio-inspired computing: Algorithms review, deep analysis, and the scope of applications. Future Comput. Inform. J. 2018, 3, 231–246. [Google Scholar] [CrossRef]
  35. Van den Bergh, F.; Engelbrecht, A.P. Cooperative learning in neural networks using particle swarm optimizers. S. Afr. Comput. J. 2000, 2000, 84–90. [Google Scholar]
  36. Zhan, Z.H.; Zhang, J.; Li, Y.; Chung, H.S.H. Adaptive particle swarm optimization. IEEE Trans. Syst. Man Cybern. Part B (Cybern.) 2009, 39, 1362–1381. [Google Scholar] [CrossRef]
  37. Freitas, D.; Lopes, L.G.; Morgado-Dias, F. Particle swarm optimisation: A historical review up to the current developments. Entropy 2020, 22, 362. [Google Scholar] [CrossRef] [PubMed]
  38. Shi, Y.; Eberhart, R. A modified particle swarm optimizer. In Proceedings of the 1998 IEEE International Conference on Evolutionary Computation Proceedings. IEEE World Congress on Computational Intelligence (Cat. No. 98TH8360); IEEE: Piscataway, NJ, USA, 1998; pp. 69–73. [Google Scholar]
  39. Eberhart; Shi, Y. Particle swarm optimization: Developments, applications and resources. In Proceedings of the 2001 Congress on Evolutionary Computation (IEEE Cat. No. 01TH8546); IEEE: Piscataway, NJ, USA, 2001; Volume 1, pp. 81–86. [Google Scholar]
  40. Engelbrecht, A.P. Computational Intelligence: An Introduction; John Wiley & Sons: Hoboken, NJ, USA, 2007. [Google Scholar]
  41. Sengupta, S.; Basak, S.; Peters, R.A. Particle Swarm Optimization: A survey of historical and recent developments with hybridization perspectives. Mach. Learn. Knowl. Extr. 2018, 1, 157–191. [Google Scholar] [CrossRef]
  42. Poli, R. Analysis of the publications on the applications of particle swarm optimisation. J. Artif. Evol. Appl. 2008, 2008, 685175. [Google Scholar] [CrossRef]
  43. Abido, M.A. Optimal power flow using particle swarm optimization. Int. J. Electr. Power Energy Syst. 2002, 24, 563–571. [Google Scholar] [CrossRef]
  44. Prasad, J.; Souradeep, T. Cosmological parameter estimation using Particle Swarm Optimization (PSO). Phys. Rev. D 2012, 85, 123008, Erratum in Phys. Rev. D 2014, 90, 109903. [Google Scholar] [CrossRef]
  45. Skokos, C.; Parsopoulos, K.E.; Patsis, P.A.; Vrahatis, M.N. Particle swarm optimization: An Efficient method for tracing periodic orbits in 3-D Galactic potentials. Mon. Not. Roy. Astron. Soc. 2005, 359, 251–260. [Google Scholar] [CrossRef]
  46. Wang, Y. First-Stage LISA Data Processing and Gravitational Wave Data Analysis: Ultraprecise Inter-Satellite Laser Ranging, Clock Synchronization and Novel Gravitational Wave Data Analysis Algorithms. Ph.D. Thesis, Max Planck Inst. Grav., Hannover, Germany, 2014. [Google Scholar] [CrossRef]
  47. Komatsu, E.; Smith, K.M.; Dunkley, J.; Bennett, C.L.; Gold, B.; Hinshaw, G.; Jarosik, N.; Larson, D.; Nolta, M.R.; Page, L.; et al. Seven-Year Wilkinson Microwave Anisotropy Probe (WMAP) Observations: Cosmological Interpretation. Astrophys. J. Suppl. 2011, 192, 18. [Google Scholar] [CrossRef]
  48. Zuntz, J.; Paterno, M.; Jennings, E.; Rudd, D.; Manzotti, A.; Dodelson, S.; Bridle, S.; Sehrish, S.; Kowalkowski, J. CosmoSIS: Modular cosmological parameter estimation. Astron. Comput. 2015, 12, 45–59. [Google Scholar] [CrossRef]
  49. Torrado, J.; Lewis, A. Cobaya: Code for Bayesian Analysis of hierarchical physical models. J. Cosmol. Astropart. Phys. 2021, 5, 057. [Google Scholar] [CrossRef]
  50. Toni, T.; Welch, D.; Strelkowa, N.; Ipsen, A.; Stumpf, M.P. Approximate Bayesian computation scheme for parameter inference and model selection in dynamical systems. J. R. Soc. Interface 2008, 6, 187–202. [Google Scholar] [CrossRef] [PubMed]
  51. Toni, T.; Stumpf, M.P.H. Simulation-based model selection for dynamical systems in systems and population biology. arXiv 2010, arXiv:0911.1705. [Google Scholar] [CrossRef]
  52. Bernardo, R.C.; Grandón, D.; Levi Said, J.; Cárdenas, V.H. Dark energy by natural evolution: Constraining dark energy using Approximate Bayesian Computation. Phys. Dark Univ. 2023, 40, 101213. [Google Scholar] [CrossRef]
  53. Bernardo, R.C.; Lee, Y.R. Hubble constant by natural selection: Evolution chips in the Hubble tension. Astron. Comput. 2023, 44, 100740. [Google Scholar] [CrossRef]
  54. Aubourg, É.; Bailey, S.; Bautista, J.E.; Beutler, F.; Bhardwaj, V.; Bizyaev, D.; Blanton, M.; Blomqvist, M.; Bolton, A.S.; Bovy, J.; et al. Cosmological implications of baryon acoustic oscillation measurements. Phys. Rev. D 2015, 92, 123516. [Google Scholar] [CrossRef]
  55. Scherrer, R.J. Mapping the Chevallier-Polarski-Linder parametrization onto Physical Dark Energy Models. Phys. Rev. D 2015, 92, 043001. [Google Scholar] [CrossRef]
  56. Pantazis, G.; Nesseris, S.; Perivolaropoulos, L. Comparison of thawing and freezing dark energy parametrizations. Phys. Rev. D 2016, 93, 103503. [Google Scholar] [CrossRef]
  57. Heavens, A. Statistical techniques in cosmology. arXiv 2009, arXiv:0906.0664. [Google Scholar] [CrossRef]
  58. Verde, L. Statistical methods in cosmology. In Lectures on Cosmology; Lecture Notes in Physics; Springer: Berlin/Heidelberg, Germany, 2010; Volume 800, pp. 147–177. [Google Scholar] [CrossRef]
  59. Amendola, L.; Gómez-Valent, A. Boosting Monte Carlo sampling with a non-Gaussian fit. Mon. Not. Roy. Astron. Soc. 2020, 498, 181–193. [Google Scholar] [CrossRef]
  60. Akaike, H. A new look at the statistical model identification. IEEE Trans. Autom. Control 1974, 19, 716–723. [Google Scholar] [CrossRef]
  61. Schwarz, G. Estimating the Dimension of a Model. Ann. Stat. 1978, 6, 461–464. [Google Scholar] [CrossRef]
  62. Rubin, D.; Aldering, G.; Betoule, M.; Fruchter, A.; Huang, X.; Kim, A.G.; Lidman, C.; Linder, E.; Perlmutter, S.; Ruiz-Lapuente, P.; et al. Union Through UNITY: Cosmology with 2,000 SNe Using a Unified Bayesian Framework. arXiv 2023, arXiv:2311.12098. [Google Scholar] [CrossRef]
  63. Clerc, M. Particle Swarm Optimization; John Wiley & Sons: Hoboken, NJ, USA, 2010; Volume 93. [Google Scholar]
  64. Mratinković, A. Illustrated Handbook of Particle Swarm Optimisation; 3g E-Learning LLC: New York, NY, USA, 2019. [Google Scholar]
  65. Kennedy, J.; Eberhart, R.; Shi, Y. The Morgan Kaufmann Series in Evolutionary Computation; Morgan Kaufmann Publishers: San Francisco, CA, USA, 2001. [Google Scholar]
  66. Mohanty, S.D. Particle Swarm Optimization and regression analysis–I. Astron. Rev. 2012, 7, 29–35. [Google Scholar] [CrossRef]
  67. Kennedy, J.; Mendes, R. Population structure and particle swarm performance. In Proceedings of the 2002 Congress on Evolutionary Computation. CEC’02 (Cat. No. 02TH8600); IEEE: Piscataway, NJ, USA, 2002; Volume 2, pp. 1671–1676. [Google Scholar]
  68. Kennedy, J.; Mendes, R. Neighborhood topologies in fully informed and best-of-neighborhood particle swarms. IEEE Trans. Syst. Man Cybern. Part C (Appl. Rev.) 2006, 36, 515–519. [Google Scholar] [CrossRef]
  69. Miranda, L.J.V. Pyswarms Documentation. 2020. Available online: https://app.readthedocs.org/projects/pyswarms/downloads/pdf/development/ (accessed on 10 July 2026).
  70. Engelbrecht, A. Particle swarm optimization: Velocity initialization. In Proceedings of the 2012 IEEE Congress on Evolutionary Computation; IEEE: Piscataway, NJ, USA, 2012; pp. 1–8. [Google Scholar]
  71. Helwig, S.; Wanka, R. Theoretical analysis of initial particle swarm behavior. In Proceedings of the International Conference on Parallel Problem Solving from Nature; Springer: Berlin/Heidelberg, Germany, 2008; pp. 889–898. [Google Scholar]
  72. Parsopoulos, K.E.; Vrahatis, M.N. Particle Swarm Optimization and Intelligence: Advances and Applications: Advances and Applications; Information Science Reference: Hershey, NY, USA, 2010. [Google Scholar]
  73. Wang, D.; Tan, D.; Liu, L. Particle swarm optimization algorithm: An overview. Soft Comput. 2018, 22, 387–408. [Google Scholar] [CrossRef]
  74. Shi, Y.; Eberhart, R.C. Parameter selection in particle swarm optimization. In Proceedings of the Evolutionary Programming VII: 7th International Conference, EP98 San Diego, California, USA, 25–27 March 1998; Proceedings 7; Springer: Berlin/Heidelberg, Germany, 1998; pp. 591–600. [Google Scholar]
  75. Shi, Y.; Eberhart, R.C. Empirical study of particle swarm optimization. In Proceedings of the 1999 Congress on Evolutionary Computation-CEC99 (Cat. No. 99TH8406); IEEE: Piscataway, NJ, USA, 1999; Volume 3, pp. 1945–1950. [Google Scholar]
  76. Lu, J.; Hu, H.; Bai, Y. Generalized radial basis function neural network based on an improved dynamic particle swarm optimization and AdaBoost algorithm. Neurocomputing 2015, 152, 305–315. [Google Scholar] [CrossRef]
  77. Engelbrecht, A.P. Particle swarm optimization: Global best or local best? In Proceedings of the 2013 BRICS Congress on Computational Intelligence and 11th Brazilian Congress on Computational Intelligence; IEEE: Piscataway, NJ, USA, 2013; pp. 124–135. [Google Scholar]
  78. Vazquez, J.A.; Gomez-Vargas, I.; Slosar, A. SimpleMC: A Simple MCMC Code for Cosmological Parameter Estimation. GitHub Repository. Available online: https://igomezv.github.io/SimpleMC/ (accessed on 16 December 2025).
  79. Speagle, J.S. dynesty: A dynamic nested sampling package for estimating Bayesian posteriors and evidences. Mon. Not. Roy. Astron. Soc. 2020, 493, 3132–3158. [Google Scholar] [CrossRef]
Figure 1. (Left panel) Star topology, where the size of the swarm corresponds to N = 8 and all particles are connected. (Right panel) Ring topology, with N = 8 and n N = 2 neighbors. Obtained from [40].
Figure 1. (Left panel) Star topology, where the size of the swarm corresponds to N = 8 and all particles are connected. (Right panel) Ring topology, with N = 8 and n N = 2 neighbors. Obtained from [40].
Universe 12 00212 g001
Figure 2. (Top panel) One-dimensional test functions, from left to right: f 1 , f 2 , f 3 and f 4 . (Bottom panel) Two-dimensional test functions: Easom ( f 5 ), Rastrigin ( f 6 ) and sphere ( f 7 ).
Figure 2. (Top panel) One-dimensional test functions, from left to right: f 1 , f 2 , f 3 and f 4 . (Bottom panel) Two-dimensional test functions: Easom ( f 5 ), Rastrigin ( f 6 ) and sphere ( f 7 ).
Universe 12 00212 g002
Figure 3. (Left panel) Blue line that best fits the synthetic data using PSO: m = 2.05 and b = 6.02 . (Right panel) Cost history of χ line 2 over 90 iterations.
Figure 3. (Left panel) Blue line that best fits the synthetic data using PSO: m = 2.05 and b = 6.02 . (Right panel) Cost history of χ line 2 over 90 iterations.
Universe 12 00212 g003
Figure 4. Evolution of ( Ω m , Ω k ) points during PSO for the Λ CDM + Ω k model using DESI data. The color bar indicates the number of iterations, and the dashed horizontal line represents the flat case. Solid red curves represent 1 σ and 2 σ confidence regions derived from a Fisher matrix analysis, whereas contour levels obtained with the MCMC algorithm are shown in purple.
Figure 4. Evolution of ( Ω m , Ω k ) points during PSO for the Λ CDM + Ω k model using DESI data. The color bar indicates the number of iterations, and the dashed horizontal line represents the flat case. Solid red curves represent 1 σ and 2 σ confidence regions derived from a Fisher matrix analysis, whereas contour levels obtained with the MCMC algorithm are shown in purple.
Universe 12 00212 g004
Figure 5. Sequential evolution of the particle distribution in the ( Ω m , Ω k ) as the iterations of PSO progresses. The right panel displays the cost function value in terms of the number of iterations.
Figure 5. Sequential evolution of the particle distribution in the ( Ω m , Ω k ) as the iterations of PSO progresses. The right panel displays the cost function value in terms of the number of iterations.
Universe 12 00212 g005
Figure 6. (Left panel) Distribution of particles in the ( ω 0 , ω a ) plane during the PSO process for the CPL model, using DESI + Union3 data. The color bar indicates the number of iterations, and the gray dashed lines displays the Λ CDM limit. Solid red curves represent 1 σ and 2 σ confidence regions derived from a Fisher matrix analysis, whereas contour levels obtained with the MCMC algorithm are shown in purple. (Right panel) The cost function value versus the iteration number.
Figure 6. (Left panel) Distribution of particles in the ( ω 0 , ω a ) plane during the PSO process for the CPL model, using DESI + Union3 data. The color bar indicates the number of iterations, and the gray dashed lines displays the Λ CDM limit. Solid red curves represent 1 σ and 2 σ confidence regions derived from a Fisher matrix analysis, whereas contour levels obtained with the MCMC algorithm are shown in purple. (Right panel) The cost function value versus the iteration number.
Universe 12 00212 g006
Table 1. PSO hyperparameters and optimization results for one- and two-dimensional test functions.
Table 1. PSO hyperparameters and optimization results for one- and two-dimensional test functions.
FunctionStruct. c 1 c 2 wIter.ParticlesNeigh. kDistance pBest PositionBest FitnessReal Pos./Fitness
f 1 ( x ) Gbest0.30.50.42010−6.05   ×   10 6 3.66   ×   10 11 0/0
Lbest0.20.50.530205Euclidean6.19   ×   10 6 3.84   ×   10 11
f 2 ( x ) Gbest0.70.30.930905.146−1.8995.147/−1.9
Lbest0.80.30.51122010Euclidean5.146−1.899
f 3 ( x ) Gbest0.20.70.720250.9991.0001/1
Lbest0.40.90.733107Abs.0.9991.000
f 4 ( x ) Gbest0.50.50.915550.1297.92   ×   10 7 0/0
Lbest0.80.30.950105Abs0.0792.08   ×   10 6
EasomGbest0.30.90.97320(3.142, 3.142)−0.999( π , π )/−1
Lbest0.50.80.745309Abs.(3.142, 3.141)−0.999
RastriginGbest0.80.40.915050(−4.31   ×   10 6 , 3.02   ×   10 5 )1.85   ×   10 7 (0, 0)/0
Lbest0.80.40.72004515Euclidean(−3.27   ×   10 6 , 6.31   ×   10 9 )0.000
SphereGbest0.30.60.76030(5.55 × 10−7, 6.31 × 10−7)7.06 × 10−13(0, 0)/0
Lbest0.30.60.730205Euclidean(0.000, −0.000)1.99 × 10−7
Table 2. PSO parameters to optimize the χ 2 function for a straight line.
Table 2. PSO parameters to optimize the χ 2 function for a straight line.
Global Best Hyperparameters for χ line 2 .
FunctionParameter c 1 Parameter c 2 Inertia Weight ω IterationsParticlesBoundaries
χ line 2 0.10.50.990200 [ 10 , 10 ] × [ 10 , 10 ]
Table 3. Parameter estimation comparison between the PSO algorithm and MCMC for the different models and dataset combinations. The bottom rows report the minimum chi-squared value achieved, or, equivalently, 2 ln L max , the number of likelihood evaluations for each algorithm (ncalls); Δ AIC and Δ BIC values are computed relative to flat Λ CDM.
Table 3. Parameter estimation comparison between the PSO algorithm and MCMC for the different models and dataset combinations. The bottom rows report the minimum chi-squared value achieved, or, equivalently, 2 ln L max , the number of likelihood evaluations for each algorithm (ncalls); Δ AIC and Δ BIC values are computed relative to flat Λ CDM.
DESIDESI + Union3
Parameter Λ CDM Λ CDM + Ω k Λ CDMCPL
PSOMCMCPSOMCMCPSOMCMCPSOMCMC
H 0 68.30768.33566.06666.24968.36868.37767.33167.4651
Ω m 0.29360.29350.28230.28400.30990.31010.33780.3366
Ω b h 2 0.022020.022010.022020.022030.022020.022020.022010.02202
Ω k 0.0630.057
ω 0 0.637 0.647
ω a 1.53 1.49
2 ln L max   12.719012.719512.01812.01840.98240.98232.04632.094
ncalls234416,804474018,726660014,238792020,497
Δ AIC1.2981.298 4.936 4.925
Δ BIC1.7831.783 5.409 5.398
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Hernández, D.M.; Garcia-Arroyo, G.; Vazquez, J.A. Cosmological Parameter Estimation Using Particle Swarm Optimization. Universe 2026, 12, 212. https://doi.org/10.3390/universe12070212

AMA Style

Hernández DM, Garcia-Arroyo G, Vazquez JA. Cosmological Parameter Estimation Using Particle Swarm Optimization. Universe. 2026; 12(7):212. https://doi.org/10.3390/universe12070212

Chicago/Turabian Style

Hernández, Daniel Morales, Gabriela Garcia-Arroyo, and J. Alberto Vazquez. 2026. "Cosmological Parameter Estimation Using Particle Swarm Optimization" Universe 12, no. 7: 212. https://doi.org/10.3390/universe12070212

APA Style

Hernández, D. M., Garcia-Arroyo, G., & Vazquez, J. A. (2026). Cosmological Parameter Estimation Using Particle Swarm Optimization. Universe, 12(7), 212. https://doi.org/10.3390/universe12070212

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop