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


# AssignTotal

The cost and the number of resources in use for the reference state of a [`Project::suggest_assignments`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#suggest_assignments>) call. You read it from [`SuggestResult::baseline`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-result.md>). Compare it with [`SuggestResult::proposed`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-proposal.md>) to see what the proposal gains.

For which state is the reference, see [`SuggestOptions::clear_first`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-options.md#clear_first>).

## Declaration

```rust
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct AssignTotal {
    pub cost: f64,
    pub resources: u32,
}
```

With the `serde` feature, `AssignTotal` also implements `Serialize` and `Deserialize`, with camelCase field names.

## Fields

| Field | Type | Description |
|---|---|---|
| `cost` | `f64` | Cost of the reference state on the scoring stage, which [`SuggestOptions::level`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-options.md>) selects. With `level`, the reference state is leveled as is before it's scored. |
| `resources` | `u32` | Resources of the counted pool that have at least one active assignment in the reference state. The counted pool is every resource listed in some slot's `allowed`, plus the current resources of filled slots. |

For how the state cost and the new-resource penalty are computed, see [Suggesting assignments](<https://docs.dhtmlx.com/planning-engine/rust/resources-and-assignment/suggesting-assignments.md>).

## Example

```rust
use plen_core::SuggestResult;

// Compare the reference state with the proposal.
fn print_totals(result: &SuggestResult) {
    let before = result.baseline;
    let after = &result.proposed;
    println!("cost: {} -> {}", before.cost, after.cost);
    println!("people in use: {} -> {}", before.resources, after.resources);
}
```

## Related

- [`SuggestResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-result.md>) - carries this value in its `baseline` field
- [`SuggestProposal`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/suggest-proposal.md>) - the matching score of the final state to compare against
- [`StepCost`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/suggest/step-cost.md>) - the first step starts from this cost
- [Suggesting assignments](<https://docs.dhtmlx.com/planning-engine/rust/resources-and-assignment/suggesting-assignments.md#reading-the-proposal>) - shows how to compare the reference state with the proposal
