LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::lal::Agent Class Reference

A finite-state agent with active, weighted passive and immediate transitions (handle semantics). More...

#include <line/lang/lal/builder.h>

Public Member Functions

 Agent (const std::string &name, const std::vector< std::string > &states, const std::string &initial)
const std::string & name () const
const std::vector< std::string > & states () const
const std::string & initial () const
const std::vector< Transition > & transitions () const
const std::optional< std::vector< double > > & initial_distribution () const
const std::optional< QueueInfo > & queue_info () const
bool unbounded_queue () const
bool has_vars () const
bool same (const Agent &o) const
Agent & active (const std::string &source, const std::string &action, double rate, const std::string &target, const std::optional< std::string > &label=std::nullopt, int priority=0)
 Add a timed action at rate.
Agent & active (const std::string &source, const std::string &action, ValueFn rate, const std::string &target, const std::optional< std::string > &label=std::nullopt, int priority=0)
 A timed action whose rate is a function of the joint state.
Agent & passive (const std::string &source, const std::string &action, const std::string &target, double weight=1.0)
 Add a passive reaction, chosen in proportion to weight among the enabled ones.
Agent & passive (const std::string &source, const std::string &action, const std::string &target, ValueFn weight)
Agent & immediate (const std::string &source, const std::string &action, const std::string &target, double weight=1.0, int priority=0, const std::optional< std::string > &label=std::nullopt)
 Add a zero-time action.
Agent & immediate (const std::string &source, const std::string &action, const std::string &target, ValueFn weight, int priority=0, const std::optional< std::string > &label=std::nullopt)
ActionRef action (const std::string &name) const
 Reference an existing action (a transition or a command) for synchronisation.
Agent & set_initial_distribution (const std::vector< double > &p)
 Start the agent from a law over its states, a vector in state order.
Agent & set_initial_distribution (const std::map< std::string, double > &p)
 Start the agent from a law over its states, by state name (missing states have probability 0).
Agent & setInitialDistribution (const std::vector< double > &p)
Agent & setInitialDistribution (const std::map< std::string, double > &p)
Agent & command (const std::string &action, const CommandOptions &o)
 Add a guarded command to a typed-variable agent (command).
Agent & command (const std::string &action, const CommandValue &value, std::function< bool(const Vars &)> guard, std::function< Vars(const Vars &)> update, Role role=Role::Active, int priority=0, const std::string &label=std::string())
 command(action, rate, guard, update[, role, priority, label]); for a non-active role value is the weight.
AgentRecord record () const
 The immutable record (_record); a typed-variable agent is expanded from its initial valuation.

Static Public Member Functions

static Agent with_vars (const std::string &name, const std::vector< std::pair< std::string, std::vector< long > > > &vars, const Vars &initial)
 A typed-variable agent (Agent(name, vars={...}, initial={...})): vars maps each variable, in order, to its finite domain of distinct values; initial gives every variable a value in its domain.
static std::vector< Agent > array (const Agent &prototype, long n)
 n copies of prototype named <name>_0 ... <name>_{n-1}, labels suffixed [i] (Agent.array).
static Agent from_record (const AgentRecord &value)
 Rebuild a builder agent from a parsed record (as Composition.from_string does).

Friends

class Composition

Detailed Description

A finite-state agent with active, weighted passive and immediate transitions (handle semantics).

Declare its states by name (Agent(name, states, initial)) and add transitions with active/passive/immediate, or declare typed variables (Agent::with_vars) and add guarded commands; the local state is then the tuple of variable values, enumerated from the initial valuation.

Definition at line 286 of file builder.h.

Constructor & Destructor Documentation

◆ Agent()

line::lal::Agent::Agent ( const std::string & name,
const std::vector< std::string > & states,
const std::string & initial )
inline

Member Function Documentation

◆ action()

ActionRef line::lal::Agent::action ( const std::string & name) const
inline

Reference an existing action (a transition or a command) for synchronisation.

Definition at line 614 of file builder.h.

References line::lal::Transition::action, name(), and line::lal::value_error().

Referenced by active(), active(), command(), command(), immediate(), immediate(), passive(), passive(), and line::lal::solve_reduced().

◆ active() [1/2]

Agent & line::lal::Agent::active ( const std::string & source,
const std::string & action,
double rate,
const std::string & target,
const std::optional< std::string > & label = std::nullopt,
int priority = 0 )
inline

Add a timed action at rate.

priority orders the timed actions of this agent: an action is disabled while one of the same agent with a higher priority is enabled. label (nonempty) aliases the event label.

Definition at line 346 of file builder.h.

References action(), line::lal::Active, and Agent().

Referenced by line::lal::markov_chain_agent(), and line::lal::markov_process_agent().

◆ active() [2/2]

Agent & line::lal::Agent::active ( const std::string & source,
const std::string & action,
ValueFn rate,
const std::string & target,
const std::optional< std::string > & label = std::nullopt,
int priority = 0 )
inline

A timed action whose rate is a function of the joint state.

Definition at line 351 of file builder.h.

References action(), line::lal::Active, and Agent().

◆ array()

std::vector< Agent > line::lal::Agent::array ( const Agent & prototype,
long n )
inlinestatic

n copies of prototype named <name>_0 ... <name>_{n-1}, labels suffixed [i] (Agent.array).

Definition at line 450 of file builder.h.

References Agent(), line::lal::Transition::label, name(), and line::lal::value_error().

◆ command() [1/2]

Agent & line::lal::Agent::command ( const std::string & action,
const CommandOptions & o )
inline

Add a guarded command to a typed-variable agent (command).

guard(v) and update(v) take the agent's variables; update returns the variables it changes. A command is disabled where its guard is false or its update leaves a domain.

Definition at line 413 of file builder.h.

References action(), line::lal::Active, Agent(), line::lal::CommandValue::CommandValue(), line::lal::CommandOptions::guard, line::lal::CommandOptions::label, line::lal::CommandOptions::priority, line::lal::CommandOptions::rate, line::lal::CommandOptions::role, line::lal::CommandOptions::update, line::lal::value_error(), and line::lal::CommandOptions::weight.

Referenced by command().

◆ command() [2/2]

Agent & line::lal::Agent::command ( const std::string & action,
const CommandValue & value,
std::function< bool(const Vars &)> guard,
std::function< Vars(const Vars &)> update,
Role role = Role::Active,
int priority = 0,
const std::string & label = std::string() )
inline

◆ from_record()

Agent line::lal::Agent::from_record ( const AgentRecord & value)
inlinestatic

◆ has_vars()

bool line::lal::Agent::has_vars ( ) const
inline

Definition at line 338 of file builder.h.

◆ immediate() [1/2]

Agent & line::lal::Agent::immediate ( const std::string & source,
const std::string & action,
const std::string & target,
double weight = 1.0,
int priority = 0,
const std::optional< std::string > & label = std::nullopt )
inline

Add a zero-time action.

Immediate actions have maximal progress: in a state where any is enabled, only those of the highest priority fire, chosen in proportion to weight, and timed actions wait. The vanishing states this creates are eliminated by the solvers.

Definition at line 369 of file builder.h.

References action(), Agent(), and line::lal::Immediate.

◆ immediate() [2/2]

Agent & line::lal::Agent::immediate ( const std::string & source,
const std::string & action,
const std::string & target,
ValueFn weight,
int priority = 0,
const std::optional< std::string > & label = std::nullopt )
inline

Definition at line 373 of file builder.h.

References action(), Agent(), and line::lal::Immediate.

◆ initial()

const std::string & line::lal::Agent::initial ( ) const
inline

Definition at line 333 of file builder.h.

Referenced by Agent(), and with_vars().

◆ initial_distribution()

const std::optional< std::vector< double > > & line::lal::Agent::initial_distribution ( ) const
inline

Definition at line 335 of file builder.h.

◆ name()

◆ passive() [1/2]

Agent & line::lal::Agent::passive ( const std::string & source,
const std::string & action,
const std::string & target,
double weight = 1.0 )
inline

Add a passive reaction, chosen in proportion to weight among the enabled ones.

Definition at line 356 of file builder.h.

References action(), Agent(), and line::lal::Passive.

◆ passive() [2/2]

Agent & line::lal::Agent::passive ( const std::string & source,
const std::string & action,
const std::string & target,
ValueFn weight )
inline

Definition at line 360 of file builder.h.

References action(), Agent(), and line::lal::Passive.

◆ queue_info()

const std::optional< QueueInfo > & line::lal::Agent::queue_info ( ) const
inline

Definition at line 336 of file builder.h.

◆ record()

◆ same()

bool line::lal::Agent::same ( const Agent & o) const
inline

Definition at line 339 of file builder.h.

References Agent().

◆ set_initial_distribution() [1/2]

Agent & line::lal::Agent::set_initial_distribution ( const std::map< std::string, double > & p)
inline

Start the agent from a law over its states, by state name (missing states have probability 0).

Definition at line 392 of file builder.h.

References Agent(), set_initial_distribution(), and line::lal::value_error().

◆ set_initial_distribution() [2/2]

Agent & line::lal::Agent::set_initial_distribution ( const std::vector< double > & p)
inline

Start the agent from a law over its states, a vector in state order.

Definition at line 382 of file builder.h.

References Agent(), and line::lal::value_error().

Referenced by set_initial_distribution(), setInitialDistribution(), and setInitialDistribution().

◆ setInitialDistribution() [1/2]

Agent & line::lal::Agent::setInitialDistribution ( const std::map< std::string, double > & p)
inline

Definition at line 405 of file builder.h.

References Agent(), and set_initial_distribution().

◆ setInitialDistribution() [2/2]

Agent & line::lal::Agent::setInitialDistribution ( const std::vector< double > & p)
inline

Definition at line 404 of file builder.h.

References Agent(), and set_initial_distribution().

◆ states()

const std::vector< std::string > & line::lal::Agent::states ( ) const
inline

Definition at line 332 of file builder.h.

Referenced by Agent().

◆ transitions()

const std::vector< Transition > & line::lal::Agent::transitions ( ) const
inline

Definition at line 334 of file builder.h.

◆ unbounded_queue()

bool line::lal::Agent::unbounded_queue ( ) const
inline

Definition at line 337 of file builder.h.

Referenced by line::lal::solve_reduced().

◆ with_vars()

Agent line::lal::Agent::with_vars ( const std::string & name,
const std::vector< std::pair< std::string, std::vector< long > > > & vars,
const Vars & initial )
inlinestatic

A typed-variable agent (Agent(name, vars={...}, initial={...})): vars maps each variable, in order, to its finite domain of distinct values; initial gives every variable a value in its domain.

Definition at line 304 of file builder.h.

References Agent(), initial(), name(), and line::lal::value_error().

◆ Composition

friend class Composition
friend

Definition at line 495 of file builder.h.

References Composition.

Referenced by Composition.


The documentation for this class was generated from the following file: