omega-sleep
Biologically-inspired sleep/wake cycle simulation with memory consolidation, circadian rhythms, and sleep architecture.
Part of the ExoGenesis-Omega cognitive architecture.
Overview
omega-sleep implements the neuroscience of sleep for artificial cognitive systems. Sleep is essential for memory consolidation, synaptic homeostasis, and cognitive maintenance. This crate provides:
- Sleep Stages: N1, N2, N3 (SWS), and REM sleep
- Slow Wave Sleep (SWS): Deep sleep with delta waves and memory consolidation
- REM Sleep: Rapid eye movement with dreaming and memory reorganization
- Sleep Spindles: Thalamocortical oscillations during N2
- Circadian Rhythm: 24-hour biological clock with melatonin/temperature
- Sleep Pressure: Homeostatic sleep drive (Process S)
Features
- Two-Process Model: Circadian (Process C) + Homeostatic (Process S)
- Memory Consolidation: Declarative in SWS, procedural in REM
- Sleep Architecture: Realistic progression through sleep stages
- Slow Oscillations: Delta waves (0.5-4 Hz) during N3
- Sleep Spindles: Sigma activity (12-16 Hz) during N2
- K-Complexes: Large deflections during N2
- Circadian Markers: Melatonin, core body temperature
Installation
Add this to your Cargo.toml:
[]
= "1.0.0"
Quick Start
use ;
Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ SLEEP SYSTEM │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ TWO-PROCESS MODEL │ │
│ │ │ │
│ │ Process S (Homeostatic) Process C (Circadian) │ │
│ │ ┌──────────────────┐ ┌──────────────────────┐ │ │
│ │ │ Sleep pressure │ │ 24-hour rhythm │ │ │
│ │ │ builds during │ │ • Melatonin │ │ │
│ │ │ wake, decays │ │ • Temperature │ │ │
│ │ │ during sleep │ │ • Alertness │ │ │
│ │ └──────────────────┘ └──────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ ↓ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ SLEEP STAGES │ │
│ │ │ │
│ │ Wake → N1 → N2 → N3 (SWS) → N2 → REM → N2 → N3 → ... │ │
│ │ │ │
│ │ N1: Transition (5 min) N2: Light sleep (20 min) │ │
│ │ N3: Deep/SWS (30 min) REM: Dreaming (20 min) │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ ↓ │
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │
│ │ SLOW WAVES │ │ SLEEP SPINDLES │ │ REM SLEEP │ │
│ │ (N3/SWS) │ │ (N2) │ │ │ │
│ │ │ │ │ │ • Theta waves │ │
│ │ • Delta 0.5-4Hz │ │ • Sigma 12-16Hz │ │ • Eye movement │ │
│ │ • Up/down states│ │ • K-complexes │ │ • Muscle atonia│ │
│ │ • Consolidation │ │ • Memory xfer │ │ • Dreams │ │
│ └──────────────────┘ └──────────────────┘ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘
Sleep Stages
use SleepStage;
let stage = N3; // Deep sleep
// Stage properties
println!;
println!;
println!;
// All stages
for stage in
// Output:
// Wake: 0 min, 0% consolidation
// N1: 5 min, 10% consolidation
// N2: 20 min, 30% consolidation
// N3: 30 min, 100% consolidation
// REM: 20 min, 70% consolidation
Slow Wave Sleep (SWS)
Deep sleep with memory consolidation:
use ;
let mut sws = new;
// Progress through slow waves
for step in 0..1000
Sleep Spindles
Thalamocortical oscillations during N2:
use ;
let mut gen = new;
// Generate spindles during N2 sleep
for minute in 0..20
// Sigma power indicates spindle activity
println!;
// K-complexes (large deflections)
let spontaneous_kc = generate;
let evoked_kc = generate;
println!;
println!;
Circadian Rhythm
24-hour biological clock:
use ;
let mut rhythm = new;
// Set time of day
rhythm.set_time; // 8:00 AM
println!;
println!;
println!;
println!;
println!;
// At 3 AM
rhythm.set_time;
println!;
println!;
println!;
println!;
// Light exposure suppresses melatonin
rhythm.set_light; // Bright light (lux)
println!;
println!; // Suppressed
Memory Consolidation
use ;
let mut consolidator = new;
// Add memories from wake period
consolidator.add_memory; // High importance
consolidator.add_memory; // Low importance
// Consolidation during N3 (SWS)
let sws_events = consolidator.consolidate_sws?;
for event in sws_events
// Consolidation during REM
let rem_events = consolidator.consolidate_rem?;
for event in rem_events
REM Sleep
Rapid eye movement sleep with dreams:
use ;
let mut rem = new;
// Enter REM
rem.enter?;
// Progress through REM episode
for step in 0..1000
// REM is characterized by muscle atonia
println!; // Very low
Configuration
use SleepConfig;
let config = SleepConfig ;
let controller = new;
Use Cases
1. Cognitive System Maintenance
// After extended operation, system needs sleep
if controller.sleep_pressure > 0.8
2. Memory Prioritization
// Important memories get replayed more during SWS
let memories_by_importance: = memories
.iter
.sorted_by
.collect;
during_sws;
3. Circadian-Aware Scheduling
// Schedule demanding tasks when alertness is high
let current_time = get_time;
rhythm.set_time;
if rhythm.current_alertness > 0.7 else
Integration with Omega
omega-brain (Unified Integration)
└── omega-sleep (This crate)
├── Sleep stages
├── Slow wave sleep
├── REM sleep
├── Spindles
└── Circadian rhythm
Interacts with:
├── omega-hippocampus - Memory replay
├── omega-snn - Synaptic homeostasis
└── omega-consciousness - Reduced awareness
Related Crates
- omega-brain - Unified cognitive architecture
- omega-hippocampus - Memory for consolidation
- omega-snn - Neural substrate for homeostasis
- omega-consciousness - Awareness reduction
References
- Borbély, A. A. (1982). "A two process model of sleep regulation"
- Diekelmann, S., & Born, J. (2010). "The memory function of sleep"
- Tononi, G., & Cirelli, C. (2006). "Sleep function and synaptic homeostasis"
- Steriade, M. (2006). "Grouping of brain rhythms in corticothalamic systems"
- Stickgold, R. (2005). "Sleep-dependent memory consolidation"
License
Licensed under the MIT License. See LICENSE for details.