# baopng/nsga-ii architecture

> Architecture diagram of the GitHub repository baopng/nsga-ii, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baopng/nsga-ii
- Repository: https://github.com/baopng/nsga-ii

## Overview

This is a small Python library for multi-objective optimization. The user defines objectives and variable bounds in a Problem, then runs Evolution; its utilities create and evaluate candidates, select and vary them, rank populations, and return the final nondominated front. The graph focuses on this runtime workflow and its core data structures. README documentation establishes the public workflow; source excerpts show the internal calls. Example problems are documented but are not part of the library runtime.

Main entry points: [`nsga2/evolution.py`](https://github.com/baopng/nsga-ii/blob/master/nsga2/evolution.py) (Evolution runner), [`nsga2/utils.py`](https://github.com/baopng/nsga-ii/blob/master/nsga2/utils.py) (NSGA-II operators), [`nsga2/problem.py`](https://github.com/baopng/nsga-ii/blob/master/nsga2/problem.py) (Problem definition), [`nsga2/population.py`](https://github.com/baopng/nsga-ii/blob/master/nsga2/population.py) (Population)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Problem Model"]
  node_problem["Problem definition<br/>[problem.py]"]
end

subgraph group_runtime["Evolution Runtime"]
  node_evolution["Evolution runner<br/>[evolution.py]"]
  node_utils["NSGA-II operators<br/>[utils.py]"]
end

subgraph group_data["Optimization Data"]
  node_population["Population<br/>[population.py]"]
  node_individual["Individual<br/>[individual.py]"]
end

node_user(("Library user"))

node_user -->|"defines objectives"| node_problem
node_user -->|"runs evolution"| node_evolution
node_evolution -->|"delegates evolution"| node_utils
node_utils -->|"generates and evaluates"| node_problem
node_utils -->|"builds and ranks"| node_population
node_problem -->|"creates candidates"| node_individual
node_evolution -->|"returns final front"| node_user

click node_problem "https://github.com/baopng/nsga-ii/blob/master/nsga2/problem.py"
click node_evolution "https://github.com/baopng/nsga-ii/blob/master/nsga2/evolution.py"
click node_utils "https://github.com/baopng/nsga-ii/blob/master/nsga2/utils.py"
click node_population "https://github.com/baopng/nsga-ii/blob/master/nsga2/population.py"
click node_individual "https://github.com/baopng/nsga-ii/blob/master/nsga2/individual.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_problem,node_user toneBlue
class node_evolution,node_utils toneAmber
class node_population,node_individual toneMint
```

## Components

### Problem Model

- [Problem definition](https://github.com/baopng/nsga-ii/blob/master/nsga2/problem.py): `nsga2/problem.py`

### Evolution Runtime

- [Evolution runner](https://github.com/baopng/nsga-ii/blob/master/nsga2/evolution.py): `nsga2/evolution.py`
- [NSGA-II operators](https://github.com/baopng/nsga-ii/blob/master/nsga2/utils.py): `nsga2/utils.py`

### Optimization Data

- [Population](https://github.com/baopng/nsga-ii/blob/master/nsga2/population.py): `nsga2/population.py`
- [Individual](https://github.com/baopng/nsga-ii/blob/master/nsga2/individual.py): `nsga2/individual.py`

### Other components

- **Library user**

## Connections

- Library user → Problem definition: defines objectives (evidence: `README.md`)
- Library user → Evolution runner: runs evolution (evidence: `README.md`)
- Evolution runner → NSGA-II operators: delegates evolution (evidence: `nsga2/evolution.py`)
- NSGA-II operators → Problem definition: generates and evaluates (evidence: `nsga2/utils.py`)
- NSGA-II operators → Population: builds and ranks (evidence: `nsga2/utils.py`)
- Problem definition → Individual: creates candidates (evidence: `nsga2/problem.py`)
- Evolution runner → Library user: returns final front (evidence: `README.md`)
