Skip to content

iannsp/shiftopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShiftOpt: Evolutionary Workforce Scheduling Engine

ShiftOpt is a high-performance resource allocation engine designed to solve the "Retail Rostering Problem."

It bridges the gap between Operational Constraints (Labor laws, availability, cost budgets) and Mathematical Optimization (Cost minimization, coverage maximization).

Project Status: Phase 1 (MVP - Greedy Algorithm & Simulation)


πŸ“– The Use Case (The Problem)

In Retail, Logistics, and Hospitality, managers spend 10-20 hours a week manually creating shift rosters. This leads to two critical failures:

  1. Overstaffing: Paying for staff during quiet hours (High Cost).
  2. Understaffing: Losing revenue during peak hours (Lost Opportunity).

The Challenge: Assigning 50 employees to 30 days of shifts is not a CRUD problem; it is a combinatorial optimization problem with millions of potential permutations.

The Solution: ShiftOpt automates this by treating the schedule as a math equation. It ingests "Demand Curves" (predicted foot traffic) and "Employee Constraints" to generate a mathematically optimal roster in milliseconds.


🧠 Mental Model & Architecture

This project is designed as a Simulation & Optimization Pipeline.

1. The Simulation Layer (Data Seeding)

Instead of relying on static data, ShiftOpt uses a Monte Carlo-style simulation to generate:

  • Demand Curves: Uses Sine waves + Noise to simulate realistic retail traffic (Pe

2. The Optimization Layer (The Engine)

  • Current State (Baseline): A Greedy Algorithm that iteratively selects the lowest-cost available resource for every open slot.
  • Future State: A Constraint Satisfaction Solver (or Genetic Algorithm) that optimizes for "Global Cost" rather than "Local Cost," taking into account fatigue, overtime rules, and skill mixing.

3. The Tech Stack

  • Language: Go (Golang) - Chosen for raw performance and concurrency in calculation loops.
  • Database: SQLite - Embedded, low-latency storage for rapid simulation resets.
  • Build System: GNU Make.

πŸ—ΊοΈ Roadmap

We are following an evolutionary development path:

  • Phase 1: Foundation (Current)

    • Domain Modeling (Employees, Demands).
    • Simulation Engine (Generating realistic test data).
    • Baseline "Greedy" Scheduler (Finding the minimum viable roster).
    • Clean Architecture (cmd/ vs internal/).
  • Phase 2: The "Real" World (Constraints)

    • Implement hard constraints (e.g., "Max 8 hours/day", "Must have 1 Manager on site").
    • Refactor algorithm to handle backtracking or penalty scoring.
  • Phase 3: AI Integration

    • LLM-based parser: Convert unstructured texts ("I can't work Friday") into structured DB constraints.
    • Demand Prediction: Use external factors (Weather/Holidays) to adjust demand curves.
  • Phase 4: Operational Dashboard

    • HTML/CSS Visualization of the roster vs. the budget.

πŸš€ Quick Start

This project uses Make for build automation.

Prerequisites

  • Go 1.21+
  • Make
  • GCC (for SQLite CGO, though we use a pure-Go driver where possible)

Commands

# 1. Run the simulation and scheduler immediately
make run

# 2. Build the optimized binary to ./bin/shiftopt
make build

# 3. Clean up the database and binaries to start fresh
make clean

# 4. Run tests
make test


πŸ“‚ Project Structure
We follow the standard Go project layout:
.
β”œβ”€β”€ bin
β”‚   β”œβ”€β”€ shiftopt
β”‚   └── shiftsummary
β”œβ”€β”€ cmd
β”‚   β”œβ”€β”€ shiftopt
β”‚   β”‚   └── main.go
β”‚   └── shiftsummary
β”‚       └── main.go
β”œβ”€β”€ doc
β”‚   β”œβ”€β”€ 001_genesis_and_stack.md
β”‚   β”œβ”€β”€ 002_the_greedy_baseline.md
β”‚   β”œβ”€β”€ 003_the_safety_constraint.md
β”‚   β”œβ”€β”€ 004_stochastic_simulation.md
β”‚   β”œβ”€β”€ 005_product_checkpoint.md
β”‚   β”œβ”€β”€ 006_visualization_and_fragmentation.md
β”‚   β”œβ”€β”€ 007tetris_and_edge_cases.md
β”‚   β”œβ”€β”€ 008_diagnostic_observability.md
β”‚   β”œβ”€β”€ 009_optimization_strategy.md
β”‚   └── 010_availability_architecture.md
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ internal
β”‚   β”œβ”€β”€ ai
β”‚   β”‚   └── parser.go
β”‚   β”œβ”€β”€ database
β”‚   β”‚   └── sqlite.go
β”‚   β”œβ”€β”€ models
β”‚   β”‚   └── models.go
β”‚   └── scheduler
β”‚       β”œβ”€β”€ export.go
β”‚       β”œβ”€β”€ greedy.go
β”‚       β”œβ”€β”€ max-hours.go
β”‚       β”œβ”€β”€ safe-shift.go
β”‚       β”œβ”€β”€ scored.go
β”‚       └── tetris.go
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
β”œβ”€β”€ roster.csv
β”œβ”€β”€ shiftopt.db
└── tests
    └── integration_test.go

Topics

  1. Combinatorial Optimization Problem
  2. Monte Carlo-style simulation
  3. Operational Constraints
  4. The Roadmap.

About

An AI-Driven Workforce Scheduler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published