Reschedule a branch#
Reschedule one task and the work that depends on it, and leave the rest of the project where it is.
The scope is the task you name, its summary ancestors and descendants, and its successors through links. With Inclusive on, the default, the scope also follows incoming links, so it takes in the task's predecessors and their branches too. Tasks outside the scope keep their dates.
Steps#
-
Create a
Subtreefor the task the branch starts from and set it onSolveOptions.new Subtree(id)setsInclusive = true, so the scope also takes in the task's predecessors:var options = new SolveOptions { Subtree = new Subtree("design") };To reschedule only the task and the work downstream of it, set
Inclusive = false. The task itself stays in the scope either way:var subtree = new Subtree("design") { Inclusive = false }; -
Pass the options to
Project.Solve. Pass yourProjectDataon the first load, ornullto reschedule the current state:var result = project.Solve(null, options); -
Write the entries of
result.Updatesback to your model. EachMutationis a task in the scope that moved. The scoped dates become the accepted baseline.
The full example below has two independent chains, backend → api and design → ui. Both successors start too early. The scoped solve fixes only the design branch:
using Plen;
var jan1 = Moment.FromYmdHm(2026, 1, 1, 0, 0) ?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Tasks =
[
new TaskData("backend") { StartDate = jan1, Duration = 2.0 },
new TaskData("api") { StartDate = jan1, Duration = 1.0 },
new TaskData("design") { StartDate = jan1, Duration = 3.0 },
new TaskData("ui") { StartDate = jan1, Duration = 1.0 },
],
Links =
[
new LinkData { Id = "l1", Source = "backend", Target = "api" },
new LinkData { Id = "l2", Source = "design", Target = "ui" },
],
};
// 24/7 time keeps the example dates easy to check.
data.Config.UseCalendars = false;
var options = new SolveOptions { Subtree = new Subtree("design") };
var project = new Project();
var result = project.Solve(data, options);
foreach (var m in result.Updates)
{
Console.WriteLine($"{m.Id} {m.StartDate}..{m.EndDate}");
}
Preview a branch#
To see what rescheduling a branch would do without changing the project, set the same Subtree on PreviewOptions and call Project.Preview:
var preview = project.Preview(
new SchedulingChanges(),
new PreviewOptions { Subtree = new Subtree("backend") });
The preview scope applies to that call only. It doesn't touch the baseline or the cached solve result. A preview scope can also name a task that the same changes add.
Things to know#
- Tasks outside the scope don't move until you solve them. In the example, the next
project.Solve(null, new SolveOptions())moves onlyapi, becauseuiis already accepted. - The result cache uses the whole
SolveOptionsas its key, compared by value. A differentSubtreereplans from the accepted dates. Solving again with the sameSubtreereturns the same cached result object. - With
IncludeUnchanged, a scoped solve reports every task in the scope, plus the out-of-scope tasks a sparse scoped solve would report. - On a project with a dependency cycle, nothing is scheduled, scoped or not. Check
result.Cycles. - An unknown or unscheduled task in
Subtree.TaskthrowsInputExceptionwithPathsubtree.taskand the messageunknown or unscheduled scope task. The project keeps its previous state and cached result. See Error handling.
Result#
The example prints one line. Only ui moves, to start after design ends. api still overlaps backend:
ui 2026-01-04 00:00..2026-01-05 00:00
Without Subtree, the same solve also moves api to 2026-01-03 00:00.