# chafik-akmouche/genetic-algorithm architecture

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

- Interactive diagram: https://gitdiagram.com/chafik-akmouche/genetic-algorithm
- Repository: https://github.com/chafik-akmouche/genetic-algorithm

## Overview

This is a Java One-Max genetic-algorithm experiment with classic evolution and adaptive mutation-operator selection using Probability Matching (PM) or UCB. The visible workflows initialize a population, run genetic-algorithm cycles, track fitness, and—on the bandit path—update operator rewards and selection scores. Fitness and operator-usage chart generation is also documented. The excerpts show the core calls, but not the application entry point or how chart generation is invoked, so those connections are left out.

Main entry points: [`src/geneticalgorithm/Bandit.java`](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Bandit.java) (Bandit runner), [`src/geneticalgorithm/GeneticAlgorithm.java`](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/GeneticAlgorithm.java) (Genetic algorithm), [`src/geneticalgorithm/Operator.java`](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Operator.java) (Mutation operator state), [`src/geneticalgorithm/Population.java`](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Population.java) (Population)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runs["Experiment runners"]
  node_classic["Classic AG<br/>[ClassicAG.java]"]
  node_bandit["Bandit runner<br/>[Bandit.java]"]
  node_test["Experiment settings<br/>[Test.java]"]
end

subgraph group_evolution["Genetic evolution"]
  node_ga["Genetic algorithm"]
  node_population["Population<br/>[Population.java]"]
  node_individual["One-Max individual<br/>[Individu.java]"]
end

subgraph group_adaptive["Adaptive operators"]
  node_operator["Mutation operator state<br/>[Operator.java]"]
  node_pm["Probability Matching<br/>[PM.java]"]
  node_ucb["UCB selection<br/>[UCB.java]"]
  node_reward["Reward updates<br/>[Reward.java]"]
end

subgraph group_reporting["Fitness reporting"]
  node_display["Console display<br/>[Display.java]"]
  node_curve["Chart data export<br/>[Curve.java]"]
end

node_classic -->|"runs cycles"| node_ga
node_bandit -->|"runs cycles"| node_ga
node_ga -->|"creates and updates"| node_population
node_ga -->|"crosses and mutates"| node_individual
node_population -->|"initializes members"| node_individual
node_bandit -->|"selects and updates"| node_pm
node_bandit -->|"selects and updates"| node_ucb
node_bandit -->|"updates rewards"| node_reward
node_pm -->|"reads and scores"| node_operator
node_ucb -->|"reads and scores"| node_operator
node_reward -->|"updates state"| node_operator
node_bandit -->|"prints fitness"| node_display

click node_classic "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/ClassicAG.java"
click node_bandit "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Bandit.java"
click node_test "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Test.java"
click node_ga "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/GeneticAlgorithm.java"
click node_population "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Population.java"
click node_individual "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Individu.java"
click node_operator "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Operator.java"
click node_pm "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/PM.java"
click node_ucb "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/UCB.java"
click node_reward "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Reward.java"
click node_display "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Display.java"
click node_curve "https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Curve.java"

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_classic,node_bandit,node_test toneBlue
class node_ga,node_population,node_individual toneAmber
class node_operator,node_pm,node_ucb,node_reward toneMint
class node_display,node_curve toneRose
```

## Components

### Experiment runners

- [Classic AG](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/ClassicAG.java): `src/geneticalgorithm/ClassicAG.java`
- [Bandit runner](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Bandit.java): `src/geneticalgorithm/Bandit.java`
- [Experiment settings](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Test.java): `src/geneticalgorithm/Test.java`

### Genetic evolution

- [Genetic algorithm](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/GeneticAlgorithm.java): `src/geneticalgorithm/GeneticAlgorithm.java`
- [Population](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Population.java): `src/geneticalgorithm/Population.java`
- [One-Max individual](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Individu.java): `src/geneticalgorithm/Individu.java`

### Adaptive operators

- [Mutation operator state](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Operator.java): `src/geneticalgorithm/Operator.java`
- [Probability Matching](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/PM.java): `src/geneticalgorithm/PM.java`
- [UCB selection](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/UCB.java): `src/geneticalgorithm/UCB.java`
- [Reward updates](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Reward.java): `src/geneticalgorithm/Reward.java`

### Fitness reporting

- [Console display](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Display.java): `src/geneticalgorithm/Display.java`
- [Chart data export](https://github.com/chafik-akmouche/genetic-algorithm/blob/master/src/geneticalgorithm/Curve.java): `src/geneticalgorithm/Curve.java`

## Connections

- Classic AG → Genetic algorithm: runs cycles (evidence: `src/geneticalgorithm/ClassicAG.java`)
- Bandit runner → Genetic algorithm: runs cycles (evidence: `src/geneticalgorithm/Bandit.java`)
- Genetic algorithm → Population: creates and updates (evidence: `src/geneticalgorithm/GeneticAlgorithm.java`)
- Genetic algorithm → One-Max individual: crosses and mutates (evidence: `src/geneticalgorithm/GeneticAlgorithm.java`)
- Population → One-Max individual: initializes members (evidence: `src/geneticalgorithm/Population.java`)
- Bandit runner → Probability Matching: selects and updates (evidence: `src/geneticalgorithm/Bandit.java`)
- Bandit runner → UCB selection: selects and updates (evidence: `src/geneticalgorithm/Bandit.java`)
- Bandit runner → Reward updates: updates rewards (evidence: `src/geneticalgorithm/Bandit.java`)
- Probability Matching → Mutation operator state: reads and scores (evidence: `src/geneticalgorithm/PM.java`)
- UCB selection → Mutation operator state: reads and scores (evidence: `src/geneticalgorithm/UCB.java`)
- Reward updates → Mutation operator state: updates state (evidence: `src/geneticalgorithm/Reward.java`)
- Bandit runner → Console display: prints fitness (evidence: `src/geneticalgorithm/Bandit.java`)
