Skip to main content

DynamicModelBackend

Trait DynamicModelBackend 

Source
pub trait DynamicModelBackend:
    Clone
    + Send
    + Sync
    + 'static {
    type Score: Score;

    // Required methods
    fn entity_count(&self, entity: EntityClassId) -> usize;
    fn get_scalar(
        &self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
    ) -> Option<usize>;
    fn set_scalar(
        &mut self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
        value: Option<usize>,
    );
    fn list_len(
        &self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
    ) -> usize;
    fn list_get(
        &self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
        pos: usize,
    ) -> Option<usize>;
    fn list_insert(
        &mut self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
        pos: usize,
        value: usize,
    );
    fn list_remove(
        &mut self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
        pos: usize,
    ) -> Option<usize>;
    fn candidate_values(
        &self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
    ) -> &[usize];
    fn scalar_value_is_legal(
        &self,
        entity: EntityClassId,
        row: usize,
        variable: VariableId,
        value: usize,
    ) -> bool;

    // Provided methods
    fn list_element_count(
        &self,
        _entity: EntityClassId,
        _variable: VariableId,
    ) -> usize { ... }
    fn list_element(
        &self,
        _entity: EntityClassId,
        _variable: VariableId,
        element_index: usize,
    ) -> Option<usize> { ... }
    fn list_assigned_elements(
        &self,
        _entity: EntityClassId,
        _variable: VariableId,
    ) -> Vec<usize> { ... }
}
Expand description

Rust-owned dynamic planning model backend.

Binding crates implement this trait on their concrete dynamic solution state. The trait is expressed in logical entity and variable IDs rather than Rust TypeIds.

Required Associated Types§

Source

type Score: Score

Score type produced for this model.

Required Methods§

Source

fn entity_count(&self, entity: EntityClassId) -> usize

Number of rows (entities) of class entity.

Source

fn get_scalar( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> Option<usize>

Value of a scalar variable on one row; None means unassigned.

Source

fn set_scalar( &mut self, entity: EntityClassId, row: usize, variable: VariableId, value: Option<usize>, )

Assigns (Some) or unassigns (None) a scalar variable on one row.

Source

fn list_len( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> usize

Length of a list variable on one row.

Source

fn list_get( &self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, ) -> Option<usize>

Element at pos in a row’s list; None when pos is out of range.

Source

fn list_insert( &mut self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, value: usize, )

Inserts value at pos in a row’s list.

Source

fn list_remove( &mut self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, ) -> Option<usize>

Removes and returns the element at pos in a row’s list; None when pos is out of range.

Source

fn candidate_values( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> &[usize]

Candidate values for a scalar variable on one row.

Returns true when value is a legal assignment for a scalar variable on one row.

Provided Methods§

Source

fn list_element_count( &self, _entity: EntityClassId, _variable: VariableId, ) -> usize

Number of declared elements a list variable distributes; defaults to 0.

Source

fn list_element( &self, _entity: EntityClassId, _variable: VariableId, element_index: usize, ) -> Option<usize>

Element value at declared source index element_index; None when the element is missing. Defaults to the index itself.

Source

fn list_assigned_elements( &self, _entity: EntityClassId, _variable: VariableId, ) -> Vec<usize>

Elements currently placed in any row’s list; defaults to none.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§