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 Project::new or Project::default(), then load data with solve.
For a one-shot run over a snapshot, use schedule instead.
Declaration#
Project has no public fields. It needs no explicit release and is dropped normally.
Mutating calls (solve, apply, level) take &mut self. Every other call takes &self and never changes the project. All calls are synchronous and CPU-only.
Constructors#
new#
Creates an empty, unsolved project.
Parameters
| Name | Type | Description |
|---|---|---|
options |
ProjectOptions |
Project-wide settings, such as the validation mode |
Returns an empty Project with no baseline.
default#
Same as Project::new(ProjectOptions::default()).
Methods#
solve#
Schedules the project and accepts the scheduled dates as the baseline.
Some(data)validates the replacement data, installs it, schedules it and accepts the result. The previous data is discarded.Noneschedules the current state when it has unsolved edits. When the project is already solved with equaloptions, it returns the cached result without scheduling again. The cache key is the wholeSolveOptionsvalue.
Tasks touched by successful apply calls since the last solve appear in updates as direct updates, even when the planner leaves them where the edit put them. A cyclic project returns unchanged dates and keeps those tasks pending.
The result's baseline_id names the accepted baseline. It changes only when the data or the dates change, so solving an unchanged state keeps it.
Parameters
| Name | Type | Description |
|---|---|---|
data |
Option<ProjectData> |
Replacement data, or None to schedule the current state |
options |
&SolveOptions |
Subtree, analytics and reporting switches |
Returns the ScheduleResult behind an Arc, shared with the project's cache.
Errors
| Error | When |
|---|---|
Error::Input |
Some(data) fails validation. The previous state and cached result are kept. |
Error::Project(ProjectError::NeedsResync) |
None after an apply rejected an operation and no solve(Some(data)) followed |
How data is validated or repaired depends on ProjectOptions::validation.
preview#
Applies hypothetical changes to a copy of the solved baseline and schedules the copy. The project isn't modified. updates are relative to the baseline, and the result's baseline_id is the baseline the preview read, so it's accepted by a following preview.
Parameters
| Name | Type | Description |
|---|---|---|
changes |
&SchedulingChanges |
The edits to try |
options |
&PreviewOptions |
Subtree, analytics, reasons, baseline check and an optional load profile |
Returns a ScheduleResult for the previewed state.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NoBaseline) |
The project is unsolved, including after apply |
Error::Project(ProjectError::StaleBaseline) |
options.baseline_id or changes.baseline_id doesn't name the current baseline |
Error::Input |
An operation in changes is rejected (the error reports the first one), or the profile query is invalid |
analyze#
Computes analytics over dates without scheduling. Some(data) analyzes the supplied dates. None uses the project's current dates, including unsolved edits. It never installs data and never changes the solved status.
The result has no updates and no conflicts. Its baseline_id is set only for None on a solved project with no unsolved edits.
Parameters
| Name | Type | Description |
|---|---|---|
data |
Option<&ProjectData> |
Dates to analyze, or None for the project's current dates |
options |
&AnalyzeOptions |
Which analytics to compute |
Returns a ScheduleResult with cycles, notes, analytics and overallocations.
Errors
| Error | When |
|---|---|
Error::Input |
Supplied data fails validation |
apply#
Applies edits to the accepted state and marks it unsolved. Operations are ordered and partially accepted: a rejected operation goes into ApplyReport::rejected, not into an Err. Any rejection sets needs_resync. After that, solve(None), apply and level fail until a full solve(Some(data)).
Because the state is unsolved afterwards, preview, load_profile, evaluate, suggest_assignments and roster need a solve first. Tasks added or updated by successful operations are reported by the next acyclic solve(None) or level.
Parameters
| Name | Type | Description |
|---|---|---|
changes |
&SchedulingChanges |
The edits to commit |
Returns an ApplyReport with the applied and rejected operations and their side effects.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NeedsResync) |
An earlier apply was rejected and no solve(Some(data)) followed (checked first) |
Error::Project(ProjectError::StaleBaseline) |
changes.baseline_id doesn't name the current baseline |
A start date that falls on non-working time is kept unsnapped when the task has no predecessor. The end is computed forward from it on the working calendar. The same applies to preview.
level#
Runs solve(None) with default options first, then resolves resource overallocation by writing persistent leveling_delay and pauses edits, and accepts the leveled state as the baseline. Forward scheduling only. On a cyclic project it returns the initial solve's result with rounds: 0.
To see leveling without committing it, call level on a clone.
Parameters
| Name | Type | Description |
|---|---|---|
options |
&LevelingOptions |
Scope, order, basis and how leveling may move tasks |
Returns a LevelingResult.
Errors
| Error | When |
|---|---|
Error::Input |
An unknown id in options.scope.resources or options.scope.tasks (path scope.resources / scope.tasks); the project has config.schedule_from_end: true (path config.schedule_from_end) |
Error::Project(ProjectError::NeedsResync) |
Returned by the initial solve |
load_profile#
Reads per-bucket load and capacity of resources on the solved baseline. Read-only.
Parameters
| Name | Type | Description |
|---|---|---|
options |
&LoadProfileOptions |
Range, resources, basis, task lists and an optional baseline check. A ProfileQuery converts into it with .into(). |
Returns a LoadProfile.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NoBaseline) |
The project is unsolved, including after apply |
Error::Project(ProjectError::StaleBaseline) |
options.baseline_id doesn't name the current baseline |
Error::Input |
to <= from, or more than 100 000 buckets per resource (path to); an unknown resource (path resources) |
evaluate#
Scores alternative change sets against the solved baseline. Each candidate runs on a disposable copy: apply, solve(None), then level when options.level is set. The project is never modified. A failure inside one candidate goes into that candidate's error and doesn't fail the call.
Parameters
| Name | Type | Description |
|---|---|---|
candidates |
&[Candidate] |
The change sets to score |
options |
&EvaluateOptions |
Baseline check, leveling stage, focus tasks and clear_first |
Returns an EvaluateResult with the baseline metrics and one result per candidate, in input order.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NoBaseline) |
The project is unsolved, including after apply |
Error::Project(ProjectError::StaleBaseline) |
options.baseline_id or any candidate's changes.baseline_id doesn't name the current baseline |
Error::Input |
An unknown task in focus (path focus[i]); options.level is invalid for the baseline |
evaluate_with#
Same as evaluate, with a choice of execution. Execution::Parallel runs candidates on scoped worker threads. The results are identical to evaluate and keep input order. A call-level error is the first one in input order.
Parameters
| Name | Type | Description |
|---|---|---|
candidates |
&[Candidate] |
The change sets to score |
options |
&EvaluateOptions |
Same as for evaluate |
execution |
Execution |
Sequential or parallel |
Returns an EvaluateResult.
Errors are the same as for evaluate.
evaluate_with isn't compiled for wasm targets. Use evaluate there.
suggest_assignments#
Proposes resources for requirement slots: it fills empty slots, repairs broken ones and rebalances valid ones, scoring each step like evaluate. The project is never modified. Commit the proposal with apply(&result.changes), followed by level with the same leveling options when they were set.
To build slots from skills and requirements, use plen_assign::slots.
Parameters
| Name | Type | Description |
|---|---|---|
slots |
&[Slot] |
The slots to fill or rebalance |
options |
&SuggestOptions |
Targets, fixed assignments, penalty, passes and leveling stage |
Returns a SuggestResult with the proposed changes and a step log.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NoBaseline) |
The project is unsolved, including after apply |
Error::Project(ProjectError::StaleBaseline) |
options.baseline_id doesn't name the current baseline |
Error::Input |
Invalid options (new_resource_penalty, passes, targets[i], fixed[i], level); a cyclic accepted state (path: None); an invalid slot (paths under slots[i]) |
Options are checked before slots. The accepted values are on the SuggestOptions and Slot pages.
roster#
Reads the accepted state without skills: scheduled leaf tasks, resources and active assignments, in model order. Use it to build your own slots.
Returns a Roster.
Errors
| Error | When |
|---|---|
Error::Project(ProjectError::NoBaseline) |
The project is unsolved or has unsolved edits |
clone#
Returns an independent copy. The copies share their data until one of them is edited, so cloning is cheap. Edits to one copy never affect the other.
Example#
Load a project, commit an edit and reschedule.
use ;
Related#
SolveOptions- options ofsolve; each other method's options type is in its parameter tableScheduleResult- the result ofsolve,previewandanalyze- Scheduling a Project - loading and solving a project
- Data Updates - committing edits with
applyand solving them - Previewing Changes - trying edits with
previewandclonebefore committing