Skip to content

LFound/control-loop-stability-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Control Loop & Stability Simulator

A discrete-time simulation framework for exploring feedback control, system stability, oscillation, and regulation tradeoffs under dynamic load.

This project models how systems respond to changing demand and how different control strategies influence stability, responsiveness, and backlog growth.


Overview

Many real-world systems must adjust capacity in response to changing load:

  • Autoscaling infrastructure
  • Congestion control in networks
  • Resource allocation systems
  • Feedback-regulated services

Poor control can lead to:

  • runaway backlog
  • oscillation
  • over-correction
  • under-reaction
  • instability

This simulator provides a controlled environment for studying those dynamics.


What This Simulator Models

The system includes:

  • Time-varying incoming load
  • Finite worker capacity
  • Queue buildup when demand exceeds processing
  • Feedback-based worker adjustment
  • Multiple control strategies
  • System state tracking over time

Control Strategies Compared

1. No Control

  • Fixed worker count
  • No adaptation to changing load
  • Demonstrates uncontrolled backlog growth

2. Aggressive Control

  • Large worker adjustments when queue deviates from target
  • Fast reaction to pressure
  • Risk of oscillation and jitter

3. Damped Control

  • Gradual worker adjustments
  • Smoother response to load changes
  • More stable but slower to correct

Core Questions Explored

  • What happens when systems do not adapt to load?
  • How does aggressive correction affect stability?
  • Can smoother control reduce oscillation?
  • What tradeoffs exist between responsiveness and stability?

Metrics Observed

  • Queue depth over time
  • Worker count over time
  • Maximum queue buildup
  • Capacity adjustment behaviour
  • Stability vs oscillation patterns

Example Results

Key Behaviour Patterns

Strategy Stability Responsiveness Behaviour
None Poor None Runaway backlog
Aggressive Medium High Fast but jittery
Damped Better Medium Smoother regulation

Example Plots

Queue Depth Over Time

Queue Depth

Worker Count Over Time

Worker Count


Project Structure

control-loop-stability-simulator/
├── sim/
│ ├── engine.py
│ ├── system_model.py
│ ├── controller.py
│ └── metrics.py
├── scripts/
│ ├── run_experiment.py
│ └── plot_results.py
├── results/
├── README.md
└── requirements.txt

Quick Start

1. Create environment

python3 -m venv venv
source venv/bin/activate
pip install matplotlib

2. Run simulation

python -m scripts.run_experiment

3. Generate plots

python -m scripts.plot_results

Results will be saved in the results/ folder.


Future Extensions

Possible next steps:

  • Proportional–Integral–Derivative (PID) controllers
  • Worker scaling delay and spin-up time
  • Noisy or stochastic load patterns
  • Target queue tuning
  • Oscillation amplitude measurement
  • Stability scoring metrics
  • Predictive control strategies

Purpose

This project is part of a systems engineering portfolio exploring:

  • System behaviour under dynamic load
  • Feedback regulation mechanisms
  • Stability vs responsiveness tradeoffs
  • Control strategy design

It is designed as an experimental learning and research tool rather than a production system.


License

MIT

About

Simulation playground for exploring feedback control, system stability, oscillation and damping under dynamic load.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages