Project#

A stateful project. It holds one accepted baseline (the last solved dates), takes incremental edits and answers read-only questions about them: previews, analytics, load, candidate scoring and assignment proposals. Create it with new Project(), then load data with Solve.

For a one-shot run over a snapshot, use Engine.Schedule instead.

Declaration#

namespace Plen;

public sealed class Project

Project has no public properties. It isn't IDisposable and needs no explicit release; the garbage collector reclaims it.

Solve, Apply and Level change the project. Every other method leaves it unchanged. All methods are synchronous and CPU-only, and each one throws ArgumentNullException for a null argument that isn't declared nullable.

A Project isn't thread-safe, and that includes the read-only methods. To work from several threads, create one Clone() per thread on a single thread first, or score candidates with EvaluateWith and Execution.Parallel().

Constructors#

Project#

public Project(ProjectOptions? options = null)

Creates an empty, unsolved project. The constructor copies options, so later changes to the caller's object don't reach the project.

Parameters

Name Type Description
options ProjectOptions? Project-wide settings, such as the validation mode. Optional; null uses the defaults (strict validation).

Returns an empty Project with no baseline.

Methods#

Each method below except Clone and ToString has its own page with the full contract.

Solve#

public ScheduleResult Solve(ProjectData? data, SolveOptions options)

Schedules the project and accepts the scheduled dates as the baseline. A ProjectData replaces the project's data; null reschedules the current state after Apply, or returns the cached result when nothing changed since a solve with equal options.

Returns a ScheduleResult that the project keeps as its baseline.

Errors: InputException for invalid data, ProjectException NeedsResync for null after a rejected Apply. See Project.Solve.

Preview#

public ScheduleResult Preview(SchedulingChanges changes, PreviewOptions options)

Schedules hypothetical changes on a copy of the solved baseline. The project isn't modified.

Returns a ScheduleResult for the previewed state.

Errors: ProjectException NoBaseline / StaleBaseline, InputException for a rejected operation. See Project.Preview.

Analyze#

public ScheduleResult Analyze(ProjectData? data, AnalyzeOptions options)

Computes analytics, cycles and overallocations over supplied dates, or over the current dates when data is null. It doesn't schedule and never installs data.

Returns a ScheduleResult with no updates.

Errors: InputException for invalid supplied data. See Project.Analyze.

Apply#

public ApplyReport Apply(SchedulingChanges changes)

Commits edits to the accepted state and marks it unsolved. Rejected operations go into the report, not into an exception, and leave the project needing a full Solve(data, …).

Returns an ApplyReport.

Errors: ProjectException NeedsResync / StaleBaseline. See Project.Apply.

Level#

public LevelingResult Level(LevelingOptions options)

Solves the current state, resolves resource overallocation with persistent LevelingDelay / Pauses edits and accepts the leveled state as the baseline. To see leveling without committing it, call Level on a Clone().

Returns a LevelingResult.

Errors: InputException for invalid options, ProjectException NeedsResync. See Project.Level.

LoadProfile#

public LoadProfile LoadProfile(LoadProfileOptions options)

Reads per-bucket load and capacity of resources on the solved baseline. A ProfileQuery converts implicitly to LoadProfileOptions.

Returns a LoadProfile.

Errors: ProjectException NoBaseline / StaleBaseline, InputException for an invalid range or resource. See Project.LoadProfile.

Evaluate#

public EvaluateResult Evaluate(IReadOnlyList<Candidate> candidates, EvaluateOptions options)

Scores alternative change sets against the solved baseline, each on a disposable copy. The project is never modified. A failure inside one candidate goes into that candidate's result.

Returns an EvaluateResult.

Errors: ProjectException NoBaseline / StaleBaseline, InputException for invalid options. See Project.Evaluate.

EvaluateWith#

public EvaluateResult EvaluateWith(
    IReadOnlyList<Candidate> candidates,
    EvaluateOptions options,
    Execution execution)

Evaluate with a choice of Execution. Execution.Parallel(...) scores candidates on worker threads and blocks until all finish. Results are identical to Evaluate and keep input order.

Returns an EvaluateResult.

Errors: same as Evaluate. See Project.Evaluate.

SuggestAssignments#

public SuggestResult SuggestAssignments(IReadOnlyList<Slot> slots, SuggestOptions options)

Proposes resources for requirement slots and returns the proposal as a change set. The project is never modified; commit the proposal with Apply(result.Changes).

Returns a SuggestResult.

Errors: ProjectException NoBaseline / StaleBaseline, InputException for invalid options or slots. See Project.SuggestAssignments.

Roster#

public Roster Roster()

Reads the accepted state without skills: scheduled leaf tasks, resources and active assignments, in model order.

Returns a Roster.

Errors: ProjectException NoBaseline when the project is unsolved or has unsolved edits. See Project.Roster.

Clone#

public Project Clone()

Returns an independent copy. Both projects share their state, including the cached solve result, until one of them changes it, so cloning is cheap. Edits to one copy never affect the other.

Shared results are the same objects in both projects. Treat them as read-only, or call DeepClone() on one before modifying it.

Returns a new Project with the same state, baseline and validation mode.

ToString#

public override string ToString()

Returns a debug dump of the whole project state. Two dumps are equal exactly when the states are equal.

Returns a string.

Example#

Load a project, commit an edit and reschedule it, falling back to a full reload when the edit is rejected.

using Plen;

var monday = Moment.FromYmdHm(2026, 8, 10, 8, 0) ?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
    Tasks = [new TaskData(1) { StartDate = monday, Duration = 2.0 }],
};

var options = new SolveOptions();
var project = new Project();
project.Solve(data, options);

var changes = new SchedulingChanges();
changes.Tasks.Update.Add(new TaskUpdate(1) { Duration = 3.0 });

var report = project.Apply(changes);
var result = report.NeedsResync
    ? project.Solve(data, options)
    : project.Solve(null, options);

foreach (var update in result.Updates)
    Console.WriteLine($"task {update.Id}: {update.StartDate} .. {update.EndDate}");