[Canonical page](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# 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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#new>) or `Project::default()`, then load data with [`solve`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#solve>).

For a one-shot run over a snapshot, use [`schedule`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/schedule.md>) instead.

## Declaration

```rust
#[derive(Clone, Debug)]
pub struct Project { /* private fields */ }

impl Default for Project
```

`Project` has no public fields. It needs no explicit release and is dropped normally.

Mutating calls ([`solve`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#solve>), [`apply`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#apply>), [`level`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#level>)) take `&mut self`. Every other call takes `&self` and never changes the project. All calls are synchronous and CPU-only.

## Constructors

### new

```rust
pub fn new(options: ProjectOptions) -> Project
```

Creates an empty, unsolved project.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `options` | [`ProjectOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project-options.md>) | Project-wide settings, such as the validation mode |

**Returns** an empty `Project` with no baseline.

### default

```rust
fn default() -> Project
```

Same as `Project::new(ProjectOptions::default())`.

## Methods

### solve

```rust
pub fn solve(
    &mut self,
    data: Option<ProjectData>,
    options: &SolveOptions,
) -> Result<Arc<ScheduleResult>, Error>
```

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.
- `None` schedules the current state when it has unsolved edits. When the project is already solved with equal `options`, it returns the cached result without scheduling again. The cache key is the whole `SolveOptions` value.

Tasks touched by successful [`apply`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/project-data.md>)`>` | Replacement data, or `None` to schedule the current state |
| `options` | `&`[`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/solve-options.md>) | Subtree, analytics and reporting switches |

**Returns** the [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/schedule-result.md>) behind an `Arc`, shared with the project's cache.

**Errors**

| Error | When |
|---|---|
| [`Error::Input`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/errors/error.md>) | `Some(data)` fails validation. The previous state and cached result are kept. |
| [`Error::Project(ProjectError::NeedsResync)`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/errors/project-error.md>) | `None` after an `apply` rejected an operation and no `solve(Some(data))` followed |

How `data` is validated or repaired depends on [`ProjectOptions::validation`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project-options.md>).

### preview

```rust
pub fn preview(
    &self,
    changes: &SchedulingChanges,
    options: &PreviewOptions,
) -> Result<ScheduleResult, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/scheduling-changes.md>) | The edits to try |
| `options` | `&`[`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/preview-options.md>) | Subtree, analytics, reasons, baseline check and an optional load profile |

**Returns** a [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/schedule-result.md>) 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

```rust
pub fn analyze(
    &self,
    data: Option<&ProjectData>,
    options: &AnalyzeOptions,
) -> Result<ScheduleResult, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/project-data.md>)`>` | Dates to analyze, or `None` for the project's current dates |
| `options` | `&`[`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/analyze-options.md>) | Which analytics to compute |

**Returns** a [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/schedule-result.md>) with `cycles`, `notes`, `analytics` and `overallocations`.

**Errors**

| Error | When |
|---|---|
| `Error::Input` | Supplied `data` fails validation |

### apply

```rust
pub fn apply(&mut self, changes: &SchedulingChanges) -> Result<ApplyReport, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#preview>), [`load_profile`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#load_profile>), [`evaluate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#evaluate>), [`suggest_assignments`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#suggest_assignments>) and [`roster`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/scheduling-changes.md>) | The edits to commit |

**Returns** an [`ApplyReport`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/apply-report.md>) 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 |

:::note
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

```rust
pub fn level(&mut self, options: &LevelingOptions) -> Result<LevelingResult, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#clone>).

**Parameters**

| Name | Type | Description |
|---|---|---|
| `options` | `&`[`LevelingOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/leveling-options.md>) | Scope, order, basis and how leveling may move tasks |

**Returns** a [`LevelingResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/leveling-result.md>).

**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

```rust
pub fn load_profile(&self, options: &LoadProfileOptions) -> Result<LoadProfile, Error>
```

Reads per-bucket load and capacity of resources on the solved baseline. Read-only.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `options` | `&`[`LoadProfileOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/load-profile-options.md>) | Range, resources, basis, task lists and an optional baseline check. A [`ProfileQuery`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/profile-query.md>) converts into it with `.into()`. |

**Returns** a [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/load-profile.md>).

**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

```rust
pub fn evaluate(
    &self,
    candidates: &[Candidate],
    options: &EvaluateOptions,
) -> Result<EvaluateResult, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/candidate.md>)`]` | The change sets to score |
| `options` | `&`[`EvaluateOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/evaluate-options.md>) | Baseline check, leveling stage, focus tasks and `clear_first` |

**Returns** an [`EvaluateResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/evaluate-result.md>) 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

```rust
#[cfg(not(target_family = "wasm"))]
pub fn evaluate_with(
    &self,
    candidates: &[Candidate],
    options: &EvaluateOptions,
    execution: Execution,
) -> Result<EvaluateResult, Error>
```

Same as [`evaluate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/candidate.md>)`]` | The change sets to score |
| `options` | `&`[`EvaluateOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/evaluate-options.md>) | Same as for `evaluate` |
| `execution` | [`Execution`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/execution.md>) | Sequential or parallel |

**Returns** an [`EvaluateResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/evaluate/evaluate-result.md>).

**Errors** are the same as for [`evaluate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#evaluate>).

:::note
`evaluate_with` isn't compiled for wasm targets. Use `evaluate` there.
:::

### suggest_assignments

```rust
pub fn suggest_assignments(
    &self,
    slots: &[Slot],
    options: &SuggestOptions,
) -> Result<SuggestResult, Error>
```

Proposes resources for requirement slots: it fills empty slots, repairs broken ones and rebalances valid ones, scoring each step like [`evaluate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#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`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/slots.md>).

**Parameters**

| Name | Type | Description |
|---|---|---|
| `slots` | `&[`[`Slot`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/slot.md>)`]` | The slots to fill or rebalance |
| `options` | `&`[`SuggestOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-options.md>) | Targets, fixed assignments, penalty, passes and leveling stage |

**Returns** a [`SuggestResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-result.md>) 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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-options.md>) and [`Slot`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/slot.md>) pages.

### roster

```rust
pub fn roster(&self) -> Result<Roster, Error>
```

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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/roster.md>).

**Errors**

| Error | When |
|---|---|
| `Error::Project(ProjectError::NoBaseline)` | The project is unsolved or has unsolved edits |

### clone

```rust
fn clone(&self) -> Project
```

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.

```rust
use plen_core::{
    DateTime, Patch, Project, ProjectData, ProjectOptions, SchedulingChanges, SolveOptions,
    TaskData, TaskUpdate,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let monday = DateTime::from_ymd_hm(2026, 8, 10, 8, 0).ok_or("invalid date")?;

    let mut task = TaskData::new(1);
    task.start_date = Some(monday);
    task.duration = Some(2.0);
    let data = ProjectData {
        tasks: vec![task],
        ..Default::default()
    };

    let mut project = Project::new(ProjectOptions::default());
    project.solve(Some(data.clone()), &SolveOptions::default())?;

    let mut update = TaskUpdate::new(1);
    update.duration = Patch::Value(3.0);
    let mut changes = SchedulingChanges::default();
    changes.tasks.update.push(update);

    let report = project.apply(&changes)?;
    let result = if report.needs_resync {
        project.solve(Some(data), &SolveOptions::default())?
    } else {
        project.solve(None, &SolveOptions::default())?
    };

    for update in &result.updates {
        println!("task {}: {:?} -> {:?}", update.id, update.start_date, update.end_date);
    }
    Ok(())
}
```

## Related

- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/solve-options.md>) - options of `solve`; each other method's options type is in its parameter table
- [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/schedule-result.md>) - the result of `solve`, `preview` and `analyze`
- [Scheduling a Project](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/scheduling-a-project.md#solving-a-project>) - loading and solving a project
- [Data Updates](<https://docs.dhtmlx.com/planning-engine/rust/live-projects/editing-a-project.md>) - committing edits with `apply` and solving them
- [Previewing Changes](<https://docs.dhtmlx.com/planning-engine/rust/live-projects/previewing-changes.md>) - trying edits with `preview` and `clone` before committing
