pub struct MultilinearInfo { /* private fields */ }Expand description
Represents the information for a multilinear system.
Implementations§
Source§impl MultilinearInfo
impl MultilinearInfo
Sourcepub fn new() -> Self
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}Sourcepub fn add_aspect(&mut self) -> Aspect
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}Sourcepub fn add_event(&mut self) -> EventEdit<'_>
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}Sourcepub fn edit_event(&mut self, Event: Event) -> Option<EventEdit<'_>>
pub fn edit_event(&mut self, Event: Event) -> Option<EventEdit<'_>>
Returns an editalbe event info if the event exists.
Sourcepub unsafe fn edit_event_unchecked(&mut self, Event: Event) -> EventEdit<'_>
pub unsafe fn edit_event_unchecked(&mut self, Event: Event) -> EventEdit<'_>
Trait Implementations§
Source§impl Clone for MultilinearInfo
impl Clone for MultilinearInfo
Source§fn clone(&self) -> MultilinearInfo
fn clone(&self) -> MultilinearInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for MultilinearInfo
impl Default for MultilinearInfo
Source§fn default() -> MultilinearInfo
fn default() -> MultilinearInfo
Returns the “default value” for a type. Read more
Source§impl SimulationInfo for MultilinearInfo
impl SimulationInfo for MultilinearInfo
Source§type StateLoadingError = Infallible
type StateLoadingError = Infallible
The error type returned when loading the simulation state fails.
Source§type State = MultilinearState
type State = MultilinearState
The type of the simulation state.
Source§type AccessData = [usize]
type AccessData = [usize]
The type used to access the current state.
Source§type EventContainer<'a> = EventContainer<'a>
where
Self: 'a
type EventContainer<'a> = EventContainer<'a> where Self: 'a
The type of container used to access the available events.
Source§fn default_state(&self) -> MultilinearState
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>
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
unsafe fn clone_state(&self, state: &MultilinearState) -> MultilinearState
Source§unsafe fn data<'a>(&self, state: &'a MultilinearState) -> &'a [usize]
unsafe fn data<'a>(&self, state: &'a MultilinearState) -> &'a [usize]
Returns a reference to the data which repsesents the
state. Read moreSource§fn callables(state: &MultilinearState) -> EventContainer<'_> ⓘ
fn callables(state: &MultilinearState) -> EventContainer<'_> ⓘ
Returns the events that can be called for the provided
state.Source§fn callable(state: &MultilinearState, event: Event) -> bool
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)
unsafe fn call(&self, state: &mut MultilinearState, event: Event)
Source§fn revertables(state: &MultilinearState) -> EventContainer<'_> ⓘ
fn revertables(state: &MultilinearState) -> EventContainer<'_> ⓘ
Returns the events that can be reverted for the provided
state.Source§fn revertable(state: &MultilinearState, event: Event) -> bool
fn revertable(state: &MultilinearState, event: Event) -> bool
Checks if the provided
event can be reverted for the given state.Auto Trait Implementations§
impl Freeze for MultilinearInfo
impl RefUnwindSafe for MultilinearInfo
impl Send for MultilinearInfo
impl Sync for MultilinearInfo
impl Unpin for MultilinearInfo
impl UnwindSafe for MultilinearInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more