leave-optimizer 0.1.1

Gap-merging leave strategy optimizer. Finds optimal vacation plans by bridging work gaps between rest blocks, accounting for Chinese holidays and weekends.
Documentation

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

  1. Build daily status for each day from today to Dec 31 (shift + holidays + weekends)
  2. Identify "rest blocks" (consecutive off days) and "work gaps" between them
  3. For each work gap ≤ max_leave_days: bridge it → merge adjacent rest blocks
  4. Score each strategy: 50% efficiency + 25% length + 25% family overlap
  5. 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);
}