Expand description
§leave-optimizer
Leave strategy optimizer using the gap-merging algorithm.
Finds the best vacation strategies by bridging work gaps between rest blocks: “If I take N days off, what’s the longest continuous break I can get?”
§How it works
- Build daily status for each day from today to Dec 31 (shift + holidays + weekends)
- Identify “rest blocks” (consecutive off days) and “work gaps” between them
- For each work gap ≤ max_leave_days: bridge it → merge adjacent rest blocks
- Score each strategy: 50% efficiency + 25% length + 25% family overlap
- Deduplicate (same break range → keep fewest leave days) and sort by score
§Example
use shift_algorithm::cycle::default_config;
use leave_optimizer::find_best_leave_plans;
use chrono::NaiveDate;
let config = default_config();
let today = NaiveDate::from_ymd_opt(2026, 9, 1).unwrap();
let plans = find_best_leave_plans(today, 90, &config, 0, None, 5);
for (i, s) in plans.iter().take(3).enumerate() {
println!("{}: 请{}天 → 连休{}天 ({:.1}x) {} – {}",
i + 1, s.leave_days, s.total_break_days,
s.efficiency, s.break_start, s.break_end);
}Structs§
- Leave
Strategy - A single leave strategy.
Functions§
- find_
best_ leave_ plans - Find the best leave strategies using gap-merging.