# Multi-Objective PSO in MATLAB

URL: https://yarpiz.com/mopso-ypea121
Author: Mostapha Kalami Heris
Published: 2015-09-01
Updated: 2026-10-30
Topics: Multiobjective Optimization

> Run multi-objective PSO in MATLAB with an external repository, grid-based leader selection, mutation, and a two-objective test problem.

Multi-Objective Particle Swarm Optimization (MOPSO) was proposed by Coello Coello, Toscano Pulido and Salazar Lechuga in 2004 ([paper](https://doi.org/10.1109/TEVC.2004.826067)). It is a multi-objective version of PSO. It uses a Pareto envelope and a grid technique, similar to the Pareto Envelope-based Selection Algorithm, to handle multi-objective optimization problems.

As in PSO, the particles share information and move toward global best particles and their own personal (local) best memory. Unlike PSO, there is more than one criterion for defining the best particle. All non-dominated particles in the swarm are collected in a sub-swarm called the Repository, and every particle chooses its global best target from the Repository. For the personal best, MOPSO uses a domination-based probabilistic rule.

## How MOPSO works

Each particle has a position $x_i$, a velocity $v_i$ and a personal best $p_i$. In each iteration, it picks a leader $h$ from the Repository and moves with the usual PSO rule:

$$
v_i \leftarrow w\,v_i + c_1 r_1 \odot (p_i - x_i) + c_2 r_2 \odot (h - x_i), \qquad x_i \leftarrow x_i + v_i
$$

The other steps are specific to the multi-objective case:

- **Grid.** The objective space around the Repository is divided into hypercubes (cells). Each Repository member belongs to one cell.
- **Leader selection.** A cell is chosen by roulette wheel selection, with a higher chance for cells that hold fewer members. A random member of that cell becomes the leader. This pulls the swarm toward less crowded parts of the front.
- **Personal best.** If the new position dominates $p_i$, it replaces $p_i$. If $p_i$ dominates the new position, $p_i$ stays. If neither dominates the other, one of them is kept at random.
- **Repository update.** New non-dominated particles join the Repository, and members that are now dominated leave it. If the Repository is too large, members are deleted from crowded cells first.
- **Mutation.** A particle may be mutated, with a probability that is high at the start and falls to zero at the last iteration. This helps the swarm explore early in the run.

## Implementation in MATLAB

This post shares an open-source MATLAB implementation of MOPSO. The algorithm is implemented in a structured way, so if you know MATLAB, you can easily use the code in your research projects.

To run the code, open the `MOPSO` folder in MATLAB and run `main.m`, which calls the main script `mopso.m`. In each iteration the program prints the number of Repository members and plots the particles and the Repository in objective space. The default problem is `ZDT.m`, the ZDT1 test function with two objectives. `MOP2.m` and `MOP4.m` are two more test problems. The code uses `unifrnd`, a function of the Statistics and Machine Learning Toolbox, so it probably needs that toolbox.

The parameters are set at the top of `mopso.m`:

| Parameter | Meaning | Value |
| --- | --- | ---: |
| `nVar` | Number of decision variables | 5 |
| `VarMin`, `VarMax` | Lower and upper bounds of the variables | 0, 1 |
| `MaxIt` | Maximum number of iterations | 200 |
| `nPop` | Swarm size | 200 |
| `nRep` | Repository size | 100 |
| `w`, `wdamp` | Inertia weight and its damping rate | 0.5, 0.99 |
| `c1`, `c2` | Personal and global learning coefficients | 1, 2 |
| `nGrid` | Number of grid cells per objective | 7 |
| `alpha` | Inflation rate of the grid | 0.1 |
| `beta` | Leader selection pressure | 2 |
| `gamma` | Deletion selection pressure | 2 |
| `mu` | Mutation rate | 0.1 |

In the code, a cell that holds $N$ Repository members is chosen as the leader cell with a probability proportional to $e^{-\beta N}$, and as the cell to delete from with a probability proportional to $e^{\gamma N}$. The mutation probability in iteration $t$ is $(1 - (t-1)/(\text{MaxIt}-1))^{1/\mu}$.

::: callout {type="note"}
The MATLAB implementation of single-objective Particle Swarm Optimization (PSO) is also available: [Particle Swarm Optimization in MATLAB](https://yarpiz.com/particle-swarm-optimization-ypea102).
:::

Other multi-objective algorithms on Yarpiz include [NSGA-II](https://yarpiz.com/nsga2-ypea120) and [PESA-II](https://yarpiz.com/pesa2-ypea123), which uses a similar grid.

## Check the result

Treat the repository as an approximation to the Pareto front. Recompute dominance from the returned objective values and inspect both coverage and variable bounds across repeated runs. A source review flagged that domination flags in the swarm may not be refreshed on every iteration before candidates enter the repository. Check that update path before using the implementation for comparative research. This review did not execute or change the optimizer.

## How to cite

Mostapha Kalami Heris, Multi-Objective PSO in MATLAB (YPEA121), Yarpiz, 2015. https://yarpiz.com/mopso-ypea121
