Clear leveling#
Remove the delays and splits that Project::level wrote into a project, so every task goes back to its unleveled dates.
Leveling stores its result in two task fields: leveling_delay and pauses. Clearing leveling means setting leveling_delay to 0 and pauses to an empty list on every task that carries either, then rescheduling. For how leveling sets these fields, see Leveling resources.
Prerequisites#
- A solved
Projectthat carries leveling, either from alevelcall or from loaded data with a non-zeroleveling_delayor non-emptypauses. - The ids of the tasks that carry a delay or pauses. Take them from your own model, or from the
updatesof theLevelingResult.
Steps#
-
Build one
TaskUpdateper leveled task. Setleveling_delaytoPatch::Value(0.0)andpausestoPatch::Value(Vec::new()), and put all the updates into oneSchedulingChanges:use ;Leave the dates out of the update. With no date in the same update, the
leveling_delaychange moves the stored start back by the delay, and thepauseschange keeps the start and duration and recomputes the end. -
Apply the changes with
Project::applyand check theApplyReport:let report = project.apply?; if !report.rejected.is_empty -
Reschedule with
solve(None, ...)and writeresult.updatesback to your model:let result = project.solve?;The cleared dates become the accepted baseline. The resource contention that leveling resolved shows up again in
result.overallocations.
The full example below levels three 2-day tasks that share dev1, then clears the leveling. It uses the default calendar (Monday to Friday, 08:00-12:00 and 13:00-17:00) and starts on Monday, August 10, 2026:
use ;
Re-level from scratch instead#
To replace old leveling with a fresh run, skip the steps above and call level again. LevelingOptions.clear_first is true by default, so the run first sets leveling_delay: 0 and pauses: [] on every in-scope task that carries either, then levels the clean plan:
let result = project.level?;
The call diffs its updates against the state it started from. A task whose stale delay was cleared and not replaced still gets an update entry, so writing updates back to your model keeps it in sync.
With a scope, the run clears only in-scope tasks. Set clear_first: false to keep the existing delays and pauses and level on top of them.
Things to know#
Patch::Nullalso works: onleveling_delayit restores the default of 0, and onpausesit clears the list.- Only leveling produces pauses. Every pause counts as leveling-owned, whether or not its
byis set, so clearing removes all of them. - To see what clearing would do before you commit it, pass the same changes to
Project::preview. The project stays untouched. See Previewing changes. - In a live editor, set
changes.baseline_idto the baseline your model shows.applythen fails withProjectError::StaleBaselineif the project has moved on. See Error handling. - If
applyrejects an operation,report.needs_resyncistrue, andsolve(None)fails withProjectError::NeedsResyncuntil you send the full data withsolve(Some(data), ...).
Result#
The example prints B and C back on Monday, and the overallocation window on dev1 returns:
B: 2026-08-10 08:00 .. 2026-08-12 08:00
C: 2026-08-10 08:00 .. 2026-08-12 08:00
dev1: 2026-08-10 08:00 .. 2026-08-11 17:00, peak 3