SolveOptions#
Options for Project.Solve and Engine.Schedule. They set which part of the project is scheduled and which extra data the ScheduleResult carries. new SolveOptions() schedules the whole project and returns only the changed tasks.
Declaration#
public sealed class SolveOptions : IDeepCloneable<SolveOptions>, IEquatable<SolveOptions>
{
public Subtree? Subtree { get; set; }
public AnalyticsOptions Analytics { get; set; } = new();
public bool Reasons { get; set; }
public bool IncludeUnchanged { get; set; }
public SolveOptions DeepClone();
public bool Equals(SolveOptions? other);
}
Set the properties you need with an object initializer: new SolveOptions { Reasons = true }. Two instances are equal when all four properties are equal, compared by value. For how Project.Solve uses that equality to return its cached result, see Project.Solve.
Properties#
| Property | Type | Default | Description |
|---|---|---|---|
Subtree |
Subtree? |
null |
Schedules only one task's subtree and the tasks that depend on it. null schedules the whole project. |
Analytics |
AnalyticsOptions |
new() (no analytics) |
Requests critical path and slack. Fills ScheduleResult.Analytics. |
Reasons |
bool |
false |
Fills Mutation.Reason on each update with the Reason the task moved. |
IncludeUnchanged |
bool |
false |
Also reports unchanged tasks in ScheduleResult.Updates, so the result holds the full date list. |
Subtree#
public Subtree? Subtree { get; set; }
Limits scheduling to the scope the Subtree value describes. Build the value with new Subtree(id).
Analytics#
public AnalyticsOptions Analytics { get; set; } = new();
Turns on AnalyticsOptions.Slack and AnalyticsOptions.CriticalPath. With both flags false (the default), ScheduleResult.Analytics is null. With either flag set, it holds an Analytics value; check its Status before reading the data.
Reasons#
public bool Reasons { get; set; }
When true, each Mutation in Updates carries a Reason in its Reason property. When false, Reason is always null.
Mutation.Reason lists when it stays null.
IncludeUnchanged#
public bool IncludeUnchanged { get; set; }
When false, Updates holds only the tasks the solve changed or that edits touched. When true, Updates also holds every scheduled task that didn't change, each with StartDate, EndDate and Duration set. This gives the full normalized date list on initial load.
- Every scheduled task is reported: leaves, summaries and milestones. Unscheduled tasks are never reported.
- With
Subtree, every task in the subtree is reported, ancestors of subtree tasks included, plus the usual changed or touched updates outside the subtree. - On a project with cycles, every scheduled task is reported in model order (
Subtreeis ignored), with its stored dates and durations. LevelingDelayandPausesare never set in these entries.
The extra entries don't affect ScheduleResult.BaselineId, which follows real date changes only. Every other result property matches what the same solve returns with IncludeUnchanged = false.
Methods#
DeepClone#
public SolveOptions DeepClone()
Returns a copy that shares no nested object (Subtree, Analytics) with this one.
Example#
using Plen;
var monday = Moment.FromYmdHm(2026, 1, 5, 8, 0) ?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Tasks =
[
new TaskData("design") { StartDate = monday, Duration = 2.0 },
new TaskData("build") { StartDate = monday, Duration = 3.0 },
],
Links = [new LinkData { Id = "l1", Source = "design", Target = "build" }],
};
var options = new SolveOptions
{
Analytics = new AnalyticsOptions { CriticalPath = true },
Reasons = true,
IncludeUnchanged = true,
};
var project = new Project();
var result = project.Solve(data, options);
// Every scheduled task, changed or not.
foreach (var update in result.Updates)
Console.WriteLine($"{update.Id}: {update.StartDate} - {update.EndDate} ({update.Reason})");
Related#
Project.Solve- the call these options configure, and how equal options return the cached resultScheduleResult- the returned result- Scheduling a project - what each solve option changes
- Load all task dates - the full date list with
IncludeUnchanged - Reschedule a branch - scoped runs with
Subtree