# guofei9987/scikit-opt architecture

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

- Interactive diagram: https://gitdiagram.com/guofei9987/scikit-opt
- Repository: https://github.com/guofei9987/scikit-opt

## Overview

scikit-opt is a Python library for swarm-intelligence and evolutionary optimization. A user supplies an objective function and configures an algorithm, runs its iterative search, and receives a best solution and objective value. The principal workflow is clearest for genetic algorithms and differential evolution: GA evaluates populations through transformed objective functions and uses selectable operators; DE specializes the shared genetic-algorithm base. The README also documents PSO, annealing, ant-colony, fish-swarm, and immune algorithms, plus custom operators, continued runs, and acceleration modes. Several algorithm implementations were not excerpted, so their internal links are omitted.

Main entry points: [`sko/GA.py`](https://github.com/guofei9987/scikit-opt/blob/master/sko/GA.py) (Genetic algorithm), [`sko/DE.py`](https://github.com/guofei9987/scikit-opt/blob/master/sko/DE.py) (Differential evolution), [`sko/tools.py`](https://github.com/guofei9987/scikit-opt/blob/master/sko/tools.py) (Function modes), [`sko/PSO.py`](https://github.com/guofei9987/scikit-opt/blob/master/sko/PSO.py) (Particle swarm)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_algorithms["Search algorithms"]
  node_de["Differential evolution<br/>[DE.py]"]
  node_ga["Genetic algorithm<br/>[GA.py]"]
  node_pso["Particle swarm<br/>[PSO.py]"]
  node_sa["Simulated annealing<br/>[SA.py]"]
  node_aca["Ant colony<br/>[ACA.py]"]
  node_afsa["Artificial fish swarm<br/>[AFSA.py]"]
  node_ia["Immune algorithm<br/>[IA.py]"]
end

subgraph group_operators["GA operators"]
  node_crossover["Crossover operators<br/>[crossover.py]"]
  node_mutation["Mutation operators<br/>[mutation.py]"]
  node_selection["Selection operators<br/>[selection.py]"]
  node_ranking["Fitness ranking<br/>[ranking.py]"]
  node_gpuops["GPU operators"]
end

subgraph group_runtime["Evaluation runtime"]
  node_tools["Function modes<br/>[tools.py]"]
end

subgraph group_extension["Extension layer"]
  node_base["Algorithm base<br/>[base.py]"]
end

node_user(("Optimization user"))
node_objective["Objective function"]
node_result["Best solution"]

node_user -->|"configures and runs"| node_de
node_user -->|"configures and runs"| node_ga
node_user -->|"selects algorithm"| node_pso
node_user -->|"selects algorithm"| node_sa
node_user -->|"selects algorithm"| node_aca
node_user -->|"selects algorithm"| node_afsa
node_user -->|"selects algorithm"| node_ia
node_objective -->|"evaluated by"| node_de
node_objective -->|"evaluated by"| node_ga
node_de -->|"inherits search base"| node_ga
node_de -->|"returns best"| node_result
node_ga -->|"returns best"| node_result
node_ga -->|"transforms objective"| node_tools
node_pso -->|"transforms objective"| node_tools
node_ga -->|"inherits base"| node_base
node_de -->|"imports operators"| node_crossover
node_de -->|"imports operators"| node_mutation
node_de -->|"imports operators"| node_selection
node_ga -->|"uses operator"| node_crossover
node_ga -->|"uses operator"| node_mutation
node_ga -->|"uses operator"| node_ranking
node_ga -->|"uses operator"| node_selection
node_ga -->|"registers GPU variants"| node_gpuops
node_ia -->|"imports algorithm base"| node_ga
node_user -->|"registers custom operators"| node_base
node_user -->|"selects run mode"| node_tools

click node_de "https://github.com/guofei9987/scikit-opt/blob/master/sko/DE.py"
click node_ga "https://github.com/guofei9987/scikit-opt/blob/master/sko/GA.py"
click node_pso "https://github.com/guofei9987/scikit-opt/blob/master/sko/PSO.py"
click node_sa "https://github.com/guofei9987/scikit-opt/blob/master/sko/SA.py"
click node_aca "https://github.com/guofei9987/scikit-opt/blob/master/sko/ACA.py"
click node_afsa "https://github.com/guofei9987/scikit-opt/blob/master/sko/AFSA.py"
click node_ia "https://github.com/guofei9987/scikit-opt/blob/master/sko/IA.py"
click node_crossover "https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/crossover.py"
click node_mutation "https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/mutation.py"
click node_selection "https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/selection.py"
click node_ranking "https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/ranking.py"
click node_gpuops "https://github.com/guofei9987/scikit-opt/tree/master/sko/operators_gpu"
click node_base "https://github.com/guofei9987/scikit-opt/blob/master/sko/base.py"
click node_tools "https://github.com/guofei9987/scikit-opt/blob/master/sko/tools.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_de,node_ga,node_pso,node_sa,node_aca,node_afsa,node_ia,node_user toneBlue
class node_crossover,node_mutation,node_selection,node_ranking,node_gpuops toneAmber
class node_tools toneMint
class node_base toneRose
class node_objective,node_result toneIndigo
```

## Components

### Search algorithms

- [Differential evolution](https://github.com/guofei9987/scikit-opt/blob/master/sko/DE.py): `sko/DE.py`
- [Genetic algorithm](https://github.com/guofei9987/scikit-opt/blob/master/sko/GA.py): `sko/GA.py`
- [Particle swarm](https://github.com/guofei9987/scikit-opt/blob/master/sko/PSO.py): `sko/PSO.py`
- [Simulated annealing](https://github.com/guofei9987/scikit-opt/blob/master/sko/SA.py): `sko/SA.py`
- [Ant colony](https://github.com/guofei9987/scikit-opt/blob/master/sko/ACA.py): `sko/ACA.py`
- [Artificial fish swarm](https://github.com/guofei9987/scikit-opt/blob/master/sko/AFSA.py): `sko/AFSA.py`
- [Immune algorithm](https://github.com/guofei9987/scikit-opt/blob/master/sko/IA.py): `sko/IA.py`

### GA operators

- [Crossover operators](https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/crossover.py): `sko/operators/crossover.py`
- [Mutation operators](https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/mutation.py): `sko/operators/mutation.py`
- [Selection operators](https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/selection.py): `sko/operators/selection.py`
- [Fitness ranking](https://github.com/guofei9987/scikit-opt/blob/master/sko/operators/ranking.py): `sko/operators/ranking.py`
- [GPU operators](https://github.com/guofei9987/scikit-opt/tree/master/sko/operators_gpu): `sko/operators_gpu`

### Evaluation runtime

- [Function modes](https://github.com/guofei9987/scikit-opt/blob/master/sko/tools.py): `sko/tools.py`

### Extension layer

- [Algorithm base](https://github.com/guofei9987/scikit-opt/blob/master/sko/base.py): `sko/base.py`

### Other components

- **Optimization user**
- **Objective function**
- **Best solution**

## Connections

- Optimization user → Differential evolution: configures and runs (evidence: `README.md`)
- Optimization user → Genetic algorithm: configures and runs (evidence: `README.md`)
- Optimization user → Particle swarm: selects algorithm (evidence: `README.md`)
- Optimization user → Simulated annealing: selects algorithm (evidence: `README.md`)
- Optimization user → Ant colony: selects algorithm (evidence: `README.md`)
- Optimization user → Artificial fish swarm: selects algorithm (evidence: `README.md`)
- Optimization user → Immune algorithm: selects algorithm (evidence: `README.md`)
- Objective function → Differential evolution: evaluated by (evidence: `README.md`)
- Objective function → Genetic algorithm: evaluated by (evidence: `README.md`)
- Differential evolution → Genetic algorithm: inherits search base (evidence: `sko/DE.py`)
- Differential evolution → Best solution: returns best (evidence: `sko/DE.py`)
- Genetic algorithm → Best solution: returns best (evidence: `sko/GA.py`)
- Genetic algorithm → Function modes: transforms objective (evidence: `sko/GA.py`)
- Particle swarm → Function modes: transforms objective (evidence: `sko/PSO.py`)
- Genetic algorithm → Algorithm base: inherits base (evidence: `sko/GA.py`)
- Differential evolution → Crossover operators: imports operators (evidence: `sko/DE.py`)
- Differential evolution → Mutation operators: imports operators (evidence: `sko/DE.py`)
- Differential evolution → Selection operators: imports operators (evidence: `sko/DE.py`)
- Genetic algorithm → Crossover operators: uses operator (evidence: `sko/GA.py`)
- Genetic algorithm → Mutation operators: uses operator (evidence: `sko/GA.py`)
- Genetic algorithm → Fitness ranking: uses operator (evidence: `sko/GA.py`)
- Genetic algorithm → Selection operators: uses operator (evidence: `sko/GA.py`)
- Genetic algorithm → GPU operators: registers GPU variants (evidence: `sko/GA.py`)
- Immune algorithm → Genetic algorithm: imports algorithm base (evidence: `sko/IA.py`)
- Optimization user → Algorithm base: registers custom operators (evidence: `README.md`)
- Optimization user → Function modes: selects run mode (evidence: `README.md`)
