# ekallevik/flexible_employee_scheduling architecture

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

- Interactive diagram: https://gitdiagram.com/ekallevik/flexible_employee_scheduling
- Repository: https://github.com/ekallevik/flexible_employee_scheduling

## Overview

##### Main Components

a) Core System Components:
- Problem Runner (Main Controller)
- Model Layer (Multiple Model Types)
- Heuristic Layer
- Preprocessing Layer
- Results Management
- Visualization System

b) Model Types:
- ESP (Employee Scheduling Problem) Model
- IMP-MIP (Implicit Mixed Integer Programming) Model
- Base Model Components
- Specialized Model Variants (Construction, Feasibility, Optimality)

c) Heuristic Components:
- PALNS (Parallel Adaptive Large Neighborhood Search)
- SDH (Shift Design Heuristic)
- SDH-SR (Shift Design Heuristic with Shift Reduction)
- Various Operators (Destroy/Repair)

**┌─────────────────────────────────────────────┐**
- User Interface               │
- (Command Line Interface)          │
- ┬───┘

**┌─────────────────────────────────────────────┐**
- Problem Runner Layer             │
- (Orchestrates the solution process)     │
- ┬───┘

**┌─────────────────────────┬───────────────────┐**
- Preprocessing Layer   │   Model Layer     │
- XML Loading          │   - Base Model    │
- Demand Processing    │   - ESP Model     │
- Shift Generation     │   - IMP-MIP Model │
- ┴───────────────────┘

**┌─────────────────────────────────────────────┐**
- Heuristic Layer                  │
- PALNS                                    │
- SDH/SDH-SR                              │
- Operators (Destroy/Repair)               │
- ┬───┘

**┌─────────────────────────┬───────────────────┐**
- Results Management   │   Visualization    │
- JSON Output         │   - Plots          │
- Solution Storage    │   - Charts         │
- ┴───────────────────┘

##### Component Details
- Input formats (XML, command line arguments)
- Processing steps (preprocessing → model building → optimization)
- Output formats (JSON, visualizations)
- Key algorithms (PALNS, SDH-SR)
- Data storage (solutions, results)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["Command Line Interface"]
        CLI_Node["CLI Input/Output"]
    end

    subgraph Runner["Problem Runner Layer"]
        ProblemRunner["Problem Runner"]:::controller
    end

    subgraph PreProc["Preprocessing Layer"]
        XMLLoader["XML Loader"]:::preproc
        DemandProc["Demand Processing"]:::preproc
        ShiftGen["Shift Generation"]:::preproc
        EmpData["Employee Data"]:::preproc
        Prefs["Preferences"]:::preproc
    end

    subgraph Models["Model Layer"]
        BaseModel["Base Model"]:::model
        ESPModel["ESP Model"]:::model
        IMPMIPModel["IMP-MIP Model"]:::model
        ConstructModel["Construction Model"]:::model
        FeasModel["Feasibility Model"]:::model
    end

    subgraph Heuristics["Heuristic Layer"]
        PALNS["PALNS"]:::heuristic
        DestroyOps["Destroy Operators"]:::heuristic
        RepairOps["Repair Operators"]:::heuristic
        LocalSearch["Local Search"]:::heuristic
        State["State Management"]:::heuristic
    end

    subgraph Output["Output Layer"]
        direction TB
        subgraph Results["Results Management"]
            ResultsStore["Results Storage"]:::output
            SolutionStore["Solution Storage"]:::output
            Converter["Results Converter"]:::output
        end

        subgraph Viz["Visualization System"]
            AbstractPlot["Abstract Plotter"]:::viz
            SolutionViz["Solution Visualizer"]:::viz
            ObjPlot["Objective Plotter"]:::viz
            HeatMap["Heatmap Plotter"]:::viz
            BarChart["Barchart Plotter"]:::viz
        end
    end

    %% Connections
    CLI_Node --> ProblemRunner
    ProblemRunner --> XMLLoader
    XMLLoader --> DemandProc
    DemandProc --> ShiftGen
    XMLLoader --> EmpData
    XMLLoader --> Prefs

    ProblemRunner --> BaseModel
    BaseModel --> ESPModel & IMPMIPModel
    BaseModel --> ConstructModel & FeasModel

    Models --> PALNS
    PALNS --> DestroyOps & RepairOps
    PALNS --> LocalSearch
    PALNS --> State

    PALNS --> ResultsStore
    ResultsStore --> Converter
    Converter --> SolutionStore

    SolutionStore --> AbstractPlot
    AbstractPlot --> SolutionViz & ObjPlot & HeatMap & BarChart

    %% Click Events
    click ProblemRunner "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/main.py"
    click BaseModel "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/model/base_model.py"
    click ESPModel "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/model/optimality_model.py"
    click IMPMIPModel "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/model/implicit_model.py"
    click ConstructModel "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/model/construction_model.py"
    click FeasModel "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/model/feasibility_model.py"
    click PALNS "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/heuristic/palns.py"
    click DestroyOps "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/heuristic/destroy_operators.py"
    click RepairOps "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/heuristic/repair_operators.py"
    click LocalSearch "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/heuristic/local_search_operators.py"
    click State "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/heuristic/state.py"
    click XMLLoader "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/preprocessing/xml_loader.py"
    click DemandProc "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/preprocessing/demand_processing.py"
    click ShiftGen "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/preprocessing/shift_generation.py"
    click EmpData "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/preprocessing/employee.py"
    click Prefs "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/preprocessing/preferences.py"
    click ResultsStore "https://github.com/ekallevik/flexible_employee_scheduling/tree/master/results/"
    click SolutionStore "https://github.com/ekallevik/flexible_employee_scheduling/tree/master/solutions/"
    click Converter "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/results/converter.py"
    click AbstractPlot "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/visualisation/abstract_plotter.py"
    click SolutionViz "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/visualisation/solution_visualizer.py"
    click ObjPlot "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/visualisation/objective_plotter.py"
    click HeatMap "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/visualisation/heatmap_plotter.py"
    click BarChart "https://github.com/ekallevik/flexible_employee_scheduling/blob/master/visualisation/barchart_plotter.py"

    %% Styles
    classDef controller fill:#3498db,stroke:#2980b9,color:white
    classDef preproc fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#e74c3c,stroke:#c0392b,color:white
    classDef heuristic fill:#f1c40f,stroke:#f39c12,color:black
    classDef output fill:#9b59b6,stroke:#8e44ad,color:white
    classDef viz fill:#1abc9c,stroke:#16a085,color:white
```
