Struct Model

Source
pub struct Model<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> { /* private fields */ }
Expand description

A complete model.

Implementations§

Source§

impl<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

Source

pub fn with_validator( size: usize, last_agent_type: Rc<dyn AgentType<StateId, Payload>>, validator: <Self as MetaModel>::Validator, ) -> Self

Create a new model, without computing anything yet, with a validation function.

Source

pub fn new( size: usize, last_agent_type: Rc<dyn AgentType<StateId, Payload>>, ) -> Self

Create a new model, without a validation function.

This allows querying the model for the agent_index of all the agents to use the results as a target for messages.

Source§

impl<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

Source

pub fn add_condition( &mut self, name: &'static str, condition: <Self as MetaModel>::Condition, help: &'static str, )

Add a named condition for defining paths through the configuration space.

Source

pub fn agents_count(&self) -> usize

Return the total number of agents.

Source

pub fn agent_label_index(&self, agent_label: &str) -> Option<usize>

Return the index of the agent with the specified label.

Source

pub fn agent_instance(&self, agent_index: usize) -> usize

Return the index of the agent instance within its type.

Source

pub fn agent_label(&self, agent_index: usize) -> &str

Return the label (short name) of an agent.

Source

pub fn is_valid(&self) -> bool

Return whether all the reachable configurations are valid.

Source

pub fn get_configuration( &self, configuration_id: ConfigurationId, ) -> <Self as MetaModel>::Configuration

Access a configuration by its identifier.

Source

pub fn get_message(&self, message_id: MessageId) -> <Self as MetaModel>::Message

Access a message by its identifier.

Source§

impl<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

Source

pub fn display_message_id(&self, message_id: MessageId) -> &str

Display a message by its identifier.

Source

pub fn display_message(&self, message: &<Self as MetaModel>::Message) -> String

Display a message.

Source

pub fn display_configuration_id( &self, configuration_id: ConfigurationId, ) -> String

Display a configuration by its identifier.

Trait Implementations§

Source§

impl<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> ClapModel for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

Source§

fn do_compute(&mut self, arg_matches: &ArgMatches<'_>)

Compute the model.
Source§

fn do_clap_agents( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the agents clap subcommand, if requested to. Read more
Source§

fn do_clap_conditions( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the conditions clap subcommand, if requested to. Read more
Source§

fn do_clap_compute( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Only compute the model (no output).
Source§

fn do_clap_configurations( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the configurations clap subcommand, if requested to. Read more
Source§

fn do_clap_transitions( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the transitions clap subcommand, if requested to. Read more
Source§

fn do_clap_path( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the path clap subcommand, if requested to.
Source§

fn do_clap_sequence( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the sequence clap subcommand, if requested to.
Source§

fn do_clap_states( &mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write, ) -> bool

Execute the states clap subcommand, if requested to.
Source§

fn do_clap(&mut self, arg_matches: &ArgMatches<'_>, stdout: &mut dyn Write)

Execute the chosen clap subcommand. Read more
Source§

impl<StateId: IndexLike, MessageId: IndexLike, InvalidId: IndexLike, ConfigurationId: IndexLike, Payload: DataLike, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> MetaModel for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

Source§

const MAX_AGENTS: usize = MAX_AGENTS

The maximal number of agents.
Source§

const MAX_MESSAGES: usize = MAX_MESSAGES

The maximal number of in-flight messages.
Source§

type StateId = StateId

The type of state identifiers.
Source§

type MessageId = MessageId

The type of message identifiers.
Source§

type InvalidId = InvalidId

The type of invalid condition identifiers.
Source§

type ConfigurationId = ConfigurationId

The type of configuration identifiers.
Source§

type Payload = Payload

The type of message payloads.
Source§

type AgentTypeRc = Rc<dyn AgentType<StateId, Payload>>

The type of boxed agent type.
Source§

type Message = Message<Payload>

The type of in-flight messages.
Source§

type Reaction = Reaction<StateId, Payload>

The type of a event handling by an agent.
Source§

type Action = Action<StateId, Payload>

The type of an action from an agent.
Source§

type Emit = Emit<Payload>

The type of an emitted messages.
Source§

type Invalid = Invalid<MessageId>

The type of invalid conditions.
Source§

type Configuration = Configuration<StateId, MessageId, InvalidId, MAX_AGENTS, MAX_MESSAGES>

The type of the included configurations.
Source§

type ConfigurationHashEntry = (Configuration<StateId, MessageId, InvalidId, MAX_AGENTS, MAX_MESSAGES>, ConfigurationId)

The type of a hash table entry for the configurations (should be cache-friendly).
Source§

type Validator = fn(&Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>, &Configuration<StateId, MessageId, InvalidId, MAX_AGENTS, MAX_MESSAGES>) -> Option<&'static str>

The type of a configuration validation function.
Source§

type Condition = fn(&Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>, &Configuration<StateId, MessageId, InvalidId, MAX_AGENTS, MAX_MESSAGES>) -> bool

A condition on model configurations.

Auto Trait Implementations§

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> !Freeze for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> !RefUnwindSafe for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> !Send for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> !Sync for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> Unpin for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>
where MessageId: Unpin, ConfigurationId: Unpin, InvalidId: Unpin, Payload: Unpin, StateId: Unpin,

§

impl<StateId, MessageId, InvalidId, ConfigurationId, Payload, const MAX_AGENTS: usize, const MAX_MESSAGES: usize> !UnwindSafe for Model<StateId, MessageId, InvalidId, ConfigurationId, Payload, MAX_AGENTS, MAX_MESSAGES>

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> 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, 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.