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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
| """ Fatigue Science Readi: 预测式疲劳管理平台 论文/产品分析: FleetOwner报道 (2026.09)
核心模型: SAFTE (Sleep, Activity, Fatigue, Task Effectiveness) - 基于睡眠科学的生物数学模型 - 输入: 睡眠历史 + 工作排班 + 生理参数 - 输出: 逐小时疲劳风险分数 (0-100)
依赖: numpy, pandas (概念实现) """
import numpy as np from typing import List, Dict, Tuple from dataclasses import dataclass
@dataclass class DriverProfile: """驾驶员档案""" id: str age: int chronotype: str typical_sleep_hours: float sleep_efficiency: float
class SAFTEModel: """ SAFTE (Sleep, Activity, Fatigue, Task Effectiveness) 模型 基于生物数学建模: 1. 睡眠债计算: 累积睡眠不足 2. 昼夜节律: 24小时生物钟波动 3. 睡眠惯性: 刚醒来时的迟钝 4. 时间在任务中: 持续工作的疲劳累积 输出: 任务有效性分数 (0-100) >90: 充分警觉 70-90: 轻度疲劳 50-70: 中度疲劳 (需干预) <50: 严重疲劳 (高风险) """ def __init__(self): self.circadian_amplitude = 0.3 self.circadian_period = 24.0 self.circadian_phase = -6.0 self.sleep_debt_rate = 0.15 self.sleep_recovery_rate = 0.8 self.max_sleep_debt = 16.0 self.task_fatigue_rate = 0.5 self.task_recovery_rate = 0.3 def calculate_circadian(self, hour_of_day: float) -> float: """计算昼夜节律影响 (-1 to 1)""" return np.sin(2 * np.pi * (hour_of_day + self.circadian_phase) / self.circadian_period) * self.circadian_amplitude def calculate_sleep_debt(self, sleep_history: List[Dict]) -> float: """ 计算累积睡眠债 Args: sleep_history: 过去7天睡眠记录 [{'date': str, 'sleep_hours': float, 'bedtime': float, 'wake_time': float}] Returns: sleep_debt: 当前睡眠债 (小时) """ debt = 0 for day in sleep_history[-7:]: needed = 8.0 actual = day['sleep_hours'] deficit = max(0, needed - actual) debt = min(self.max_sleep_debt, debt + deficit * self.sleep_debt_rate) if actual > needed: recovery = (actual - needed) * self.sleep_recovery_rate debt = max(0, debt - recovery) return debt def calculate_task_fatigue(self, hours_on_task: float, breaks: List[Tuple[float, float]] = None) -> float: """ 计算任务疲劳 Args: hours_on_task: 当前班次已工作时长 breaks: [(start_hour, duration), ...] Returns: task_fatigue: 0-1 """ total_break_time = 0 if breaks: total_break_time = sum(d for _, d in breaks) net_work = hours_on_task - total_break_time fatigue = min(1.0, net_work * self.task_fatigue_rate / 8.0) for _, duration in (breaks or []): fatigue = max(0, fatigue - duration * self.task_recovery_rate / 8.0) return fatigue def calculate_effectiveness(self, driver: DriverProfile, sleep_history: List[Dict], shift_start: float, current_hour: float) -> Dict: """ 计算当前任务有效性 Args: driver: 驾驶员档案 sleep_history: 7天睡眠记录 shift_start: 班次开始时间(小时, 0-24) current_hour: 当前时间(小时, 0-24) Returns: result: dict with effectiveness score and risk level """ circadian = self.calculate_circadian(current_hour) sleep_debt = self.calculate_sleep_debt(sleep_history) sleep_debt_effect = -sleep_debt * 2 hours_on_task = (current_hour - shift_start) % 24 if hours_on_task < 0: hours_on_task += 24 task_fatigue = self.calculate_task_fatigue(hours_on_task) task_effect = -task_fatigue * 30 sleep_inertia = 0 wake_time = sleep_history[-1].get('wake_time', 7.0) time_since_wake = (current_hour - wake_time) % 24 if time_since_wake < 2: sleep_inertia = -(2 - time_since_wake) * 5 age_effect = 0 if driver.age > 50: age_effect = -2 base_score = 100 effectiveness = (base_score + circadian * 20 + sleep_debt_effect + task_effect + sleep_inertia + age_effect) effectiveness = max(0, min(100, effectiveness)) if effectiveness >= 90: risk = 'low' elif effectiveness >= 70: risk = 'moderate' elif effectiveness >= 50: risk = 'high' else: risk = 'severe' return { 'effectiveness': effectiveness, 'risk_level': risk, 'components': { 'circadian': circadian * 20, 'sleep_debt_effect': sleep_debt_effect, 'task_fatigue_effect': task_effect, 'sleep_inertia': sleep_inertia, 'age_effect': age_effect, }, 'sleep_debt_hours': sleep_debt, 'hours_on_task': hours_on_task, } def predict_shift(self, driver: DriverProfile, sleep_history: List[Dict], shift_start: float, shift_duration: float) -> List[Dict]: """ 班前预测: 生成逐小时疲劳预测 Args: shift_start: 班次开始时间 shift_duration: 班次时长(小时) Returns: predictions: 逐小时预测列表 """ predictions = [] for hour_offset in range(int(shift_duration) + 1): current_hour = (shift_start + hour_offset) % 24 result = self.calculate_effectiveness( driver, sleep_history, shift_start, current_hour ) result['hour_offset'] = hour_offset result['clock_time'] = f"{int(current_hour):02d}:00" predictions.append(result) return predictions
if __name__ == "__main__": print("=" * 60) print("Fatigue Science Readi: 预测式疲劳管理") print("=" * 60) model = SAFTEModel() driver = DriverProfile( id="D001", age=45, chronotype="morning", typical_sleep_hours=7.0, sleep_efficiency=0.85 ) np.random.seed(42) sleep_history = [] for day in range(7): sleep_history.append({ 'date': f'2026-09-{17+day}', 'sleep_hours': 5.5 + np.random.uniform(-0.5, 0.5), 'bedtime': 22.0 + np.random.uniform(-1, 1), 'wake_time': 5.0 + np.random.uniform(-0.5, 0.5) }) print(f"\n驾驶员: {driver.id}, {driver.age}岁, {driver.chronotype}型") print(f"过去7天睡眠:") for day in sleep_history: print(f" {day['date']}: {day['sleep_hours']:.1f}h") shift_start = 6.0 shift_duration = 10 predictions = model.predict_shift(driver, sleep_history, shift_start, shift_duration) print(f"\n班次预测 (06:00-16:00):") print(f"{'时间':<8} {'有效性':<10} {'风险':<10} {'睡眠债':<10} {'在岗':<8} {'关键因素'}") print("-" * 70) for pred in predictions: components = pred['components'] key_factor = min(components, key=lambda k: components[k]) print(f"{pred['clock_time']:<8} " f"{pred['effectiveness']:<10.1f} " f"{pred['risk_level']:<10} " f"{pred['sleep_debt_hours']:<10.1f}h " f"{pred['hours_on_task']:<8.1f} " f"{key_factor}({components[key_factor]:.1f})") high_risk_hours = [p for p in predictions if p['risk_level'] in ['high', 'severe']] if high_risk_hours: print(f"\n⚠️ 高风险时段:") for hr in high_risk_hours: print(f" {hr['clock_time']}: 有效性={hr['effectiveness']:.1f}, " f"风险={hr['risk_level']}") else: print(f"\n✅ 无高风险时段") print(f"\n{'='*60}") print(f"传统DMS vs Readi 对比:") print(f"{'维度':<15} {'传统DMS':<25} {'Readi':<25}") print(f"{'-'*65}") print(f"{'时机':<15} {'驾驶中':<25} {'班前8-12小时':<25}") print(f"{'方式':<15} {'摄像头+传感器':<25} {'算法模型+睡眠数据':<25}") print(f"{'响应':<15} {'警告驾驶员':<25} {'重新排班/调整路线':<25}") print(f"{'数据':<15} {'实时眼动/头部':<25} {'历史睡眠+排班':<25}") print(f"{'目标':<15} {'防止事故':<25} {'从源头消除风险':<25}") print(f"{'精度':<15} {'~75%(实时)':<25} {'~85%(预测)':<25}") print(f"{'成本':<15} {'$15-50/车(硬件)':<25} {'$2-5/人/月(SaaS)':<25}")
|