Skip to main content

MultilinearInfo

Struct MultilinearInfo 

Source
pub struct MultilinearInfo { /* private fields */ }
Expand description

Represents the information for a multilinear system.

Implementations§

Source§

impl MultilinearInfo

Source

pub fn iter(&self) -> impl Iterator<Item = (Event, &EventNode)>

Returns an iterator over the events and the event nodes containing the changes.

Source§

impl MultilinearInfo

Source

pub fn new() -> Self

Creates a new instance of MultilinearInfo.

Examples found in repository?
examples/example.rs (line 5)
4fn main() {
5    let mut story = MultilinearInfo::new();
6
7    // Create aspects
8    let place = story.add_aspect();
9    let clothes = story.add_aspect();
10
11    // Define event: Move from bedroom to living room
12    let event_move = story
13        .add_event()
14        .with_change(&[Change::transition(place, 0, 1)])
15        .unwrap()
16        .event();
17
18    // Define event: Change clothes in bedroom
19    let event_clothes = story
20        .add_event()
21        .with_change(&[
22            Change::condition(place, 0),
23            Change::transition(clothes, 1, 0),
24        ])
25        .unwrap()
26        .event();
27
28    let mut simulation = MultilinearSimulation::new(story);
29    simulation.try_call(event_clothes);
30    simulation.try_call(event_move);
31    simulation.try_revert(event_move);
32}
Source

pub fn add_aspect(&mut self) -> Aspect

Adds a new aspect to the multilinear system.

Examples found in repository?
examples/example.rs (line 8)
4fn main() {
5    let mut story = MultilinearInfo::new();
6
7    // Create aspects
8    let place = story.add_aspect();
9    let clothes = story.add_aspect();
10
11    // Define event: Move from bedroom to living room
12    let event_move = story
13        .add_event()
14        .with_change(&[Change::transition(place, 0, 1)])
15        .unwrap()
16        .event();
17
18    // Define event: Change clothes in bedroom
19    let event_clothes = story
20        .add_event()
21        .with_change(&[
22            Change::condition(place, 0),
23            Change::transition(clothes, 1, 0),
24        ])
25        .unwrap()
26        .event();
27
28    let mut simulation = MultilinearSimulation::new(story);
29    simulation.try_call(event_clothes);
30    simulation.try_call(event_move);
31    simulation.try_revert(event_move);
32}
Source

pub fn add_event(&mut self) -> EventEdit<'_>

Adds a new event to the multilinear system and returns an editalbe event info.

Examples found in repository?
examples/example.rs (line 13)
4fn main() {
5    let mut story = MultilinearInfo::new();
6
7    // Create aspects
8    let place = story.add_aspect();
9    let clothes = story.add_aspect();
10
11    // Define event: Move from bedroom to living room
12    let event_move = story
13        .add_event()
14        .with_change(&[Change::transition(place, 0, 1)])
15        .unwrap()
16        .event();
17
18    // Define event: Change clothes in bedroom
19    let event_clothes = story
20        .add_event()
21        .with_change(&[
22            Change::condition(place, 0),
23            Change::transition(clothes, 1, 0),
24        ])
25        .unwrap()
26        .event();
27
28    let mut simulation = MultilinearSimulation::new(story);
29    simulation.try_call(event_clothes);
30    simulation.try_call(event_move);
31    simulation.try_revert(event_move);
32}
Source

pub fn edit_event(&mut self, Event: Event) -> Option<EventEdit<'_>>

Returns an editalbe event info if the event exists.

Source

pub unsafe fn edit_event_unchecked(&mut self, Event: Event) -> EventEdit<'_>

Returns an editalbe event info.

§Safety

Ensure that this event exists

Trait Implementations§

Source§

impl Clone for MultilinearInfo

Source§

fn clone(&self) -> MultilinearInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MultilinearInfo

Source§

fn default() -> MultilinearInfo

Returns the “default value” for a type. Read more
Source§

impl SimulationInfo for MultilinearInfo

Source§

type StateLoadingError = Infallible

The error type returned when loading the simulation state fails.
Source§

type State = MultilinearState

The type of the simulation state.
Source§

type AccessData = [usize]

The type used to access the current state.
Source§

type LoadData = Vec<usize>

The type of data used to load the simulation state.
Source§

type Event = Event

The type of events that can be called or reverted in the simulation.
Source§

type EventContainer<'a> = EventContainer<'a> where Self: 'a

The type of container used to access the available events.
Source§

fn default_state(&self) -> MultilinearState

Creates a new default state compatible with this SimulationInfo instance.
Source§

fn load_state(&self, data: Vec<usize>) -> Result<MultilinearState, Infallible>

Loads a state from the provided data, returning a Result with the loaded state or an error.
Source§

unsafe fn clone_state(&self, state: &MultilinearState) -> MultilinearState

Clones the provided state, assuming it is compatible with this SimulationInfo instance. Read more
Source§

unsafe fn data<'a>(&self, state: &'a MultilinearState) -> &'a [usize]

Returns a reference to the data which repsesents the state. Read more
Source§

fn callables(state: &MultilinearState) -> EventContainer<'_>

Returns the events that can be called for the provided state.
Source§

fn callable(state: &MultilinearState, event: Event) -> bool

Checks if the provided event can be called for the given state.
Source§

unsafe fn call(&self, state: &mut MultilinearState, event: Event)

Calls the provided event on the given mutable state. Read more
Source§

fn revertables(state: &MultilinearState) -> EventContainer<'_>

Returns the events that can be reverted for the provided state.
Source§

fn revertable(state: &MultilinearState, event: Event) -> bool

Checks if the provided event can be reverted for the given state.
Source§

unsafe fn revert(&self, state: &mut MultilinearState, event: Event)

Reverts the provided event on the given mutable state. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.