AssignTarget#

A category of slot that Project::suggest_assignments acts on. Each slot falls into exactly one category, judged from its current resource in the accepted state. List the categories to act on in SuggestOptions::targets, in any combination, each at most once.

Declaration#

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AssignTarget {
    Empty,
    Broken,
    Valid,
}

Variants#

Variant Description
Empty The slot has no assignment. Targeting it fills the slot in pass 0.
Broken The slot's resource isn't in the slot's allowed list. Targeting it repairs the slot in pass 0 with the cheapest candidate, whatever keeping the current resource would cost.
Valid The slot's resource is in allowed. Targeting it rebalances the slot in passes 1..=passes. The resource changes only on a strict improvement.

For the default and the report-only setting, see SuggestOptions::targets. For how the passes run, see Suggesting assignments.

Example#

use plen_core::{AssignTarget, SuggestOptions};

fn main() {
    // Fill empty slots, repair broken ones, and rebalance the rest.
    let options = SuggestOptions {
        targets: vec![AssignTarget::Empty, AssignTarget::Broken, AssignTarget::Valid],
        ..Default::default()
    };
    assert_eq!(options.targets.len(), 3);

    // Report only: no assignment changes.
    let check = SuggestOptions {
        targets: vec![],
        ..Default::default()
    };
    assert!(check.targets.is_empty());
}
  • SuggestOptions - holds the list of targeted categories in targets
  • Slot - the input whose state decides its category
  • SuggestResult - reports which targeted slots stayed unfilled or invalid
  • Suggesting assignments - shows filling, rebalancing and repairing with each target