File size: 2,791 Bytes
9f53c11
 
 
 
 
 
 
 
 
 
0033d19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a525678
0033d19
 
 
 
 
 
 
 
 
 
a525678
0033d19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a525678
0033d19
a525678
0033d19
a525678
0033d19
a525678
0033d19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
title: RL Study Scheduler
emoji: πŸ“š
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: "4.0.0"
app_file: inference.py
pinned: false
---
# RL-Based Adaptive Study Scheduler

> Q-learning agent vs heuristic baseline for cognitive-aware study planning.

## Demo Output

![Results](comparison_results.png)

---

## Overview

This project models study planning as a sequential decision-making problem under cognitive and temporal constraints. Instead of static prioritization rules, a **Reinforcement Learning (RL) agent** learns to optimize task scheduling dynamically.

**Core insight**: Adaptive scheduling under stress is not a sorting problem β€” it's a **learning problem**.

---

## Results: RL vs Heuristic Baseline

| Metric | RL Agent | Baseline | Winner |
|--------|----------|----------|--------|
| Avg Reward | Higher | Lower | RL βœ… |
| Tasks Completed | More | Less | RL βœ… |
| Missed Deadlines | Fewer | More | RL βœ… |
| Avg Stress | Lower | Higher | RL βœ… |
| Efficiency Score | Higher | Lower | RL βœ… |

**Key finding**: RL outperforms heuristic scheduling under high stress and tight deadlines.

---

## Live Demo

πŸ€— **[Try it on Hugging Face Spaces](https://huggingface.co/spaces/dee2004/rl-study-scheduler)**

---

## MDP Formulation

### State Space
```
energy (0-100), stress (0-100), focus (0-100),
pending tasks, min deadline, max difficulty
```

### Action Space
```
DO_TASK | BREAK | SKIP | SWITCH
```

### Reward Function

| Event | Reward |
|-------|--------|
| Task completion | +10 |
| Difficult task (difficulty > 7) | +5 |
| Urgent task completed (deadline < 2) | +4 |
| Missed deadline | -8 |
| Burnout (energy < 20) | -10 |
| High stress (> 80) | -5 |
| Context switching | -2 |
| Self-care break | +2 |

---

## How to Run

```bash
pip install -r requirements.txt
python compare.py      # Train + compare
python plot.py         # Generate chart
python inference.py    # Launch Gradio UI locally
```

---

## Project Structure

```
rl-study-scheduler/
β”œβ”€β”€ env.py          # RL environment (MDP)
β”œβ”€β”€ agent_q.py      # Q-learning agent
β”œβ”€β”€ baseline.py     # Heuristic policy
β”œβ”€β”€ reward.py       # Reward function
β”œβ”€β”€ compare.py      # Training + comparison
β”œβ”€β”€ eval.py         # Metrics
β”œβ”€β”€ plot.py         # Visualization
β”œβ”€β”€ llm_grader.py   # LLM qualitative evaluation
β”œβ”€β”€ inference.py    # Gradio app
└── requirements.txt
```

---

## Why RL?

| Requirement | Rule-based | RL |
|---|---|---|
| Sequential decisions | ❌ | βœ… |
| Delayed rewards (rest now β†’ no burnout later) | ❌ | βœ… |
| Adapts to energy/stress state | ❌ | βœ… |
| Learns from experience | ❌ | βœ… |

---

## Tech Stack

- Python 3.8+ Β· NumPy Β· Matplotlib Β· Gradio Β· Anthropic API

## License

MIT