DiaDes  0.1
DIAgnosis of Discrete-Event System
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Diades::Automata::ComposableModel Class Reference

#include <ComposableModel.hh>

Public Types

typedef Diades::Utils::Exception< ComposableModelException
 
typedef Component::OutputEventTransitionIterator OutputEventTransitionIterator
 
typedef Component::InputEventTransitionIterator InputEventTransitionIterator
 
typedef Component::OutputTransitionIterator OutputTransitionIterator
 
typedef Component::InputTransitionIterator InputTransitionIterator
 
typedef unordered_set< Event >::const_iterator EventIterator
 
typedef Diades::Graph::NodeIterator StateIterator
 
typedef unordered_set< State >::const_iterator InitialStateIterator
 
typedef const ComposableModelConstPointer
 
typedef ComposableModelPointer
 

Public Member Functions

ConstPointer getPointer () const
 
Pointer getPointer ()
 
 ComposableModel (const Component &component, const SynchronisationRules &synchronisation)
 
bool valid () const
 
 ComposableModel (const vector< ConstPointer > &models, const SynchronisationRules &synchronisation, bool onTheFly)
 
 ComposableModel (const vector< ConstPointer > &models, const SynchronisationRules &synchronisation, bool onTheFly, Component *result)
 
 ~ComposableModel ()
 
const string & name () const
 
const SynchronisationRulessynchronisationLaw () const
 
EventIterator beginOfEvents () const
 
EventIterator endOfEvents () const
 
unsigned numberOfInitialStates () const
 
unsigned numberOfStates () const
 
unsigned numberOfTransitions () const
 
StateIterator stateBegin () const
 
StateIterator stateEnd () const
 
InitialStateIterator beginOfInitialStates () const
 
InitialStateIterator endOfInitialStates () const
 
const Componentcomponent () const
 
const vector< ConstPointer > & models () const
 
const vector< State > & vectorStateOf (State s) const
 
OutputTransitionIterator outputTransitionBegin (State s) const
 
OutputTransitionIterator outputTransitionEnd (State s) const
 
OutputEventTransitionIterator outputEventTransitionBegin (State s, const Event &e) const
 
OutputEventTransitionIterator outputEventTransitionEnd (State s, const Event &e) const
 
InputEventTransitionIterator inputEventTransitionBegin (State s, const Event &e) const
 
InputEventTransitionIterator inputEventTransitionEnd (State s, const Event &e) const
 
string log () const
 

Static Public Member Functions

static string typeName ()
 

Protected Member Functions

bool synchronise ()
 the underlying Component (if result from synchronisation) More...
 
void synchronise (State state, Event event) const
 
void synchronise (State state) const
 

Protected Attributes

stringstream _log
 
const Component_comp
 stream for logging internal messages More...
 
bool _embeddedResult
 the underlying Component (if associated to a component) More...
 
Component_result
 true if the composable model has to manage its own result component More...
 

Private Types

typedef vector< const ComposableModel * >::size_type SizeType
 
typedef unordered_map< Event, vector< SizeType > > SupportMap
 

Private Member Functions

bool computeSupport ()
 
bool computeInitialStates (list< State > &pendingStates)
 

Private Attributes

const unsigned _synchronisationLimit
 
const SynchronisationRules *const _sync
 synchronisation limit (number of states) More...
 
unordered_set< Event_usedEvents
 the synchronisation law of the ComposableModel More...
 
unordered_set< State_initialStates
 list of the events of the ComposableModel More...
 
vector< Event_componentEventOf
 list of initial states More...
 
SupportMap _support
 
ConstNodeMap< vector< State > > _vectorStateOf
 
const vector< ConstPointer_models
 
StateTable _stateOfVector
 
State _pendingGlobalState
 
vector< const Component * > _components
 
ConstNodeMap< set< Event > > _visited
 
bool _onTheFly
 

Detailed Description

This class implements the type of models that can be composed by applying a Synchronisation law. In order to compose two models, it is required that they have the same Synchronisation law. This class can be used in two different manners. Either the ComposableModel is not computed on the fly, it means that the composition is performed at construction time. If set to be on the fly, then the computation of the transitions are performed when calling the methods:

Definition at line 35 of file ComposableModel.hh.

Member Typedef Documentation

◆ ConstPointer

Definition at line 48 of file ComposableModel.hh.

◆ EventIterator

typedef unordered_set<Event>::const_iterator Diades::Automata::ComposableModel::EventIterator

Definition at line 45 of file ComposableModel.hh.

◆ Exception

Definition at line 39 of file ComposableModel.hh.

◆ InitialStateIterator

typedef unordered_set<State>::const_iterator Diades::Automata::ComposableModel::InitialStateIterator

Definition at line 47 of file ComposableModel.hh.

◆ InputEventTransitionIterator

Definition at line 42 of file ComposableModel.hh.

◆ InputTransitionIterator

Definition at line 44 of file ComposableModel.hh.

◆ OutputEventTransitionIterator

Definition at line 41 of file ComposableModel.hh.

◆ OutputTransitionIterator

Definition at line 43 of file ComposableModel.hh.

◆ Pointer

Definition at line 49 of file ComposableModel.hh.

◆ SizeType

typedef vector<const ComposableModel *>::size_type Diades::Automata::ComposableModel::SizeType
private

Definition at line 53 of file ComposableModel.hh.

◆ StateIterator

Definition at line 46 of file ComposableModel.hh.

◆ SupportMap

typedef unordered_map<Event, vector<SizeType> > Diades::Automata::ComposableModel::SupportMap
private

Definition at line 54 of file ComposableModel.hh.

Constructor & Destructor Documentation

◆ ComposableModel() [1/3]

Diades::Automata::ComposableModel::ComposableModel ( const Component component,
const SynchronisationRules synchronisation 
)

Basic constructor

Parameters
componenta Component
synchronisationa SynchronisationRules law.

Create a ComposableModel from a Component. The behaviour of the ComposableModel relies on the behaviour of the Component from the initial states in component. The ComposableModel can be synchronised with any other ComposableModel that has the same Synchronisation law.

Referenced by getPointer(), and valid().

◆ ComposableModel() [2/3]

Diades::Automata::ComposableModel::ComposableModel ( const vector< ConstPointer > &  models,
const SynchronisationRules synchronisation,
bool  onTheFly 
)

Constructor by composition

Parameters
modelslist of ComposableModels
synchronisationa SynchronisationRules law.
onTheFlythe synchronisation is on the fly.

Create the ComposableModel resulting from the Synchronisation of the ComposableModel in 'models' The operation may fail. In this case, the ComposableModel is empty. Some details about the failure are provided in the log.

◆ ComposableModel() [3/3]

Diades::Automata::ComposableModel::ComposableModel ( const vector< ConstPointer > &  models,
const SynchronisationRules synchronisation,
bool  onTheFly,
Component result 
)

Constructor by composition

Parameters
modelslist of ComposableModels
synchronisationa SynchronisationRules law.
onTheFlythe synchronisation is on the fly.
resultthe Component that will be the result

Create the ComposableModel resulting from the Synchronisation of the ComposableModel in 'models' The operation may fail. In this case, the ComposableModel is empty. Some details about the failure are provided in the log.

◆ ~ComposableModel()

Diades::Automata::ComposableModel::~ComposableModel ( )

Destructor

Referenced by valid().

Member Function Documentation

◆ beginOfEvents()

EventIterator Diades::Automata::ComposableModel::beginOfEvents ( ) const
inline
Returns
an EventIterator on the Event of the ComposableModel (begin)

Definition at line 211 of file ComposableModel.hh.

◆ beginOfInitialStates()

InitialStateIterator Diades::Automata::ComposableModel::beginOfInitialStates ( ) const
inline
Returns
a StateIterator on the states for the ComposableModel (begin)

Definition at line 274 of file ComposableModel.hh.

Referenced by Diades::Automata::ComposableModelSearch< Algorithm >::initialize(), and Diades::Automata::randomSimulate().

◆ component()

const Component& Diades::Automata::ComposableModel::component ( ) const
inline

◆ computeInitialStates()

bool Diades::Automata::ComposableModel::computeInitialStates ( list< State > &  pendingStates)
private

◆ computeSupport()

bool Diades::Automata::ComposableModel::computeSupport ( )
private
Returns
true is the support computation is a success
Postcondition
if the computation is sucessful then '_support' contains all the synchronised events issued from '_models' and the law and for any Event, '_support' associates the indexes of the ComposableModel objects in '_models' that contains the Event. If the computation has failed, some detailed are provided in the log.

◆ endOfEvents()

EventIterator Diades::Automata::ComposableModel::endOfEvents ( ) const
inline
Returns
an EventIterator on the Event of the ComposableModel (end)

Definition at line 221 of file ComposableModel.hh.

◆ endOfInitialStates()

InitialStateIterator Diades::Automata::ComposableModel::endOfInitialStates ( ) const
inline
Returns
a StateIterator on the states for the ComposableModel (end)

Definition at line 283 of file ComposableModel.hh.

Referenced by Diades::Automata::ComposableModelSearch< Algorithm >::initialize(), and Diades::Automata::randomSimulate().

◆ getPointer() [1/2]

ConstPointer Diades::Automata::ComposableModel::getPointer ( ) const
inline

Definition at line 131 of file ComposableModel.hh.

◆ getPointer() [2/2]

Pointer Diades::Automata::ComposableModel::getPointer ( )
inline

Definition at line 132 of file ComposableModel.hh.

References component(), and ComposableModel().

◆ inputEventTransitionBegin()

InputEventTransitionIterator Diades::Automata::ComposableModel::inputEventTransitionBegin ( State  s,
const Event e 
) const
inline

◆ inputEventTransitionEnd()

InputEventTransitionIterator Diades::Automata::ComposableModel::inputEventTransitionEnd ( State  s,
const Event e 
) const
inline

◆ log()

string Diades::Automata::ComposableModel::log ( ) const
inline

Definition at line 434 of file ComposableModel.hh.

◆ models()

const vector<ConstPointer>& Diades::Automata::ComposableModel::models ( ) const
inline
Returns
the local models

Definition at line 309 of file ComposableModel.hh.

References _models.

Referenced by Diades::Automata::ComposableModelSearch< Algorithm >::diagnosis(), and valid().

◆ name()

const string& Diades::Automata::ComposableModel::name ( ) const
inline
Returns
the name of the ComposableModel

Definition at line 197 of file ComposableModel.hh.

References component(), and Diades::Automata::Component::name().

◆ numberOfInitialStates()

unsigned Diades::Automata::ComposableModel::numberOfInitialStates ( ) const
inline
Returns
the number of initial states in the current ComposableModel

Definition at line 230 of file ComposableModel.hh.

Referenced by Diades::Automata::randomSimulate().

◆ numberOfStates()

unsigned Diades::Automata::ComposableModel::numberOfStates ( ) const
inline
Returns
the number of states in the current ComposableModel

Definition at line 238 of file ComposableModel.hh.

References component(), and Diades::Automata::Component::numberOfStates().

◆ numberOfTransitions()

unsigned Diades::Automata::ComposableModel::numberOfTransitions ( ) const
inline
Returns
the number of transitions in the current ComposableModel

Definition at line 246 of file ComposableModel.hh.

References component(), and Diades::Automata::Component::numberOfTransitions().

◆ outputEventTransitionBegin()

OutputEventTransitionIterator Diades::Automata::ComposableModel::outputEventTransitionBegin ( State  s,
const Event e 
) const
inline
Parameters
ssource state
eevent to trigger from state s. Event e is a synchronised event from the Synchronization law
Returns
an iterator on the first output transition of state 's' labelled with 'e' Note that the computation of the set of output transitions might be effectively done at this stage

Definition at line 379 of file ComposableModel.hh.

References Diades::Automata::Component::behaviour(), component(), Diades::Automata::Event::id(), Diades::Automata::Event::isValid(), Diades::Automata::Component::outputEventTransitionBegin(), require, and synchronise().

◆ outputEventTransitionEnd()

OutputEventTransitionIterator Diades::Automata::ComposableModel::outputEventTransitionEnd ( State  s,
const Event e 
) const
inline
Parameters
ssource state
eevent to trigger from state s Event e is a synchronised event from the Synchronization law
Returns
an iterator after the last output transition of state 's' labelled with 'e' Note that the computation of the set of output transitions might be effectively done at this stage

Definition at line 400 of file ComposableModel.hh.

References Diades::Automata::Component::behaviour(), component(), Diades::Automata::Event::id(), Diades::Automata::Event::isValid(), Diades::Automata::Component::outputEventTransitionEnd(), require, and synchronise().

◆ outputTransitionBegin()

OutputTransitionIterator Diades::Automata::ComposableModel::outputTransitionBegin ( State  s) const
inline
Parameters
ssource state
Returns
an iterator on the first output transition of state 's' Note that the computation of the set of output transitions might be effectively done at this stage

Definition at line 339 of file ComposableModel.hh.

References Diades::Automata::Component::behaviour(), component(), Diades::Automata::Component::outputTransitionBegin(), require, and synchronise().

Referenced by Diades::Automata::NextTransitions::begin(), Diades::Automata::interactiveSimulation(), and Diades::Automata::randomSimulateState().

◆ outputTransitionEnd()

OutputTransitionIterator Diades::Automata::ComposableModel::outputTransitionEnd ( State  s) const
inline
Parameters
ssource state
Returns
an iterator after the last output transition of state 's' Note that the computation of the set of output transitions might be effectively done at this stage

Definition at line 360 of file ComposableModel.hh.

References Diades::Automata::Component::behaviour(), component(), Diades::Automata::Component::outputTransitionEnd(), require, and synchronise().

Referenced by Diades::Automata::NextTransitions::begin(), Diades::Automata::NextTransitions::end(), Diades::Automata::interactiveSimulation(), and Diades::Automata::randomSimulateState().

◆ stateBegin()

StateIterator Diades::Automata::ComposableModel::stateBegin ( ) const
inline
Returns
a StateIterator on the states for the ComposableModel (begin)

Definition at line 255 of file ComposableModel.hh.

References component(), and Diades::Automata::Component::stateBegin().

◆ stateEnd()

StateIterator Diades::Automata::ComposableModel::stateEnd ( ) const
inline
Returns
a StateIterator on the states for the ComposableModel (end)

Definition at line 264 of file ComposableModel.hh.

References component(), and Diades::Automata::Component::stateEnd().

◆ synchronisationLaw()

const SynchronisationRules& Diades::Automata::ComposableModel::synchronisationLaw ( ) const
inline
Returns
the synchronisation law of the ComposableModel

Definition at line 203 of file ComposableModel.hh.

References _sync.

◆ synchronise() [1/3]

bool Diades::Automata::ComposableModel::synchronise ( )
protected

the underlying Component (if result from synchronisation)

This method implements the effective and enumerative composition of ComposableModel objects. The method may fail if the requested operation requires too much computational resources. In case, it fails, the current composable model is invalid. A detailed description about why the composition has failed is given in the log.

Referenced by outputEventTransitionBegin(), outputEventTransitionEnd(), outputTransitionBegin(), and outputTransitionEnd().

◆ synchronise() [2/3]

void Diades::Automata::ComposableModel::synchronise ( State  state,
Event  event 
) const
protected

On-the-fly synchronisation

Parameters
statea State
eventan Event
Precondition
the State 'state' must not have been visited with the Event 'event'

◆ synchronise() [3/3]

void Diades::Automata::ComposableModel::synchronise ( State  state) const
protected

On-the-fly synchronisation

Parameters
statea State
Precondition
the State 'state' must not have been visited

◆ typeName()

static string Diades::Automata::ComposableModel::typeName ( )
inlinestatic

Definition at line 38 of file ComposableModel.hh.

◆ valid()

bool Diades::Automata::ComposableModel::valid ( ) const
inline
Returns
true if the ComposableModel is valid

Definition at line 154 of file ComposableModel.hh.

References ComposableModel(), Diades::Automata::Component::isValid(), models(), and ~ComposableModel().

◆ vectorStateOf()

const vector<State>& Diades::Automata::ComposableModel::vectorStateOf ( State  s) const
inline

return the vector of local states asociated to the global state

Parameters
sthe global state
Returns
the vector of local states asociated to the global state

Definition at line 319 of file ComposableModel.hh.

Referenced by Diades::Automata::ComposableModelSearch< Algorithm >::diagnosis().

Member Data Documentation

◆ _comp

const Component* Diades::Automata::ComposableModel::_comp
protected

stream for logging internal messages

Definition at line 93 of file ComposableModel.hh.

Referenced by component().

◆ _componentEventOf

vector<Event> Diades::Automata::ComposableModel::_componentEventOf
mutableprivate

list of initial states

Definition at line 59 of file ComposableModel.hh.

◆ _components

vector<const Component *> Diades::Automata::ComposableModel::_components
private

Definition at line 72 of file ComposableModel.hh.

◆ _embeddedResult

bool Diades::Automata::ComposableModel::_embeddedResult
protected

the underlying Component (if associated to a component)

Definition at line 94 of file ComposableModel.hh.

◆ _initialStates

unordered_set<State> Diades::Automata::ComposableModel::_initialStates
mutableprivate

list of the events of the ComposableModel

Definition at line 58 of file ComposableModel.hh.

◆ _log

stringstream Diades::Automata::ComposableModel::_log
protected

Definition at line 92 of file ComposableModel.hh.

◆ _models

const vector<ConstPointer> Diades::Automata::ComposableModel::_models
private

Definition at line 69 of file ComposableModel.hh.

Referenced by models().

◆ _onTheFly

bool Diades::Automata::ComposableModel::_onTheFly
private

Definition at line 74 of file ComposableModel.hh.

◆ _pendingGlobalState

State Diades::Automata::ComposableModel::_pendingGlobalState
mutableprivate

Definition at line 71 of file ComposableModel.hh.

◆ _result

Component* Diades::Automata::ComposableModel::_result
protected

true if the composable model has to manage its own result component

Definition at line 95 of file ComposableModel.hh.

Referenced by component().

◆ _stateOfVector

StateTable Diades::Automata::ComposableModel::_stateOfVector
mutableprivate

Definition at line 70 of file ComposableModel.hh.

◆ _support

SupportMap Diades::Automata::ComposableModel::_support
mutableprivate

mapping between a synchronised event and a component event if the composable Model is a single component then _componentEventOf[se.id()] == e (i.e. se is a synchronisedEvent and e is the event that correspond to the event e in the component) if the composable Model is a synchronised set of components then _componentEventOf[se.id()] == se where se is a synchronisedEvent rom the synchronisation law

Definition at line 67 of file ComposableModel.hh.

◆ _sync

const SynchronisationRules* const Diades::Automata::ComposableModel::_sync
private

synchronisation limit (number of states)

Definition at line 56 of file ComposableModel.hh.

Referenced by synchronisationLaw().

◆ _synchronisationLimit

const unsigned Diades::Automata::ComposableModel::_synchronisationLimit
private

Definition at line 55 of file ComposableModel.hh.

◆ _usedEvents

unordered_set<Event> Diades::Automata::ComposableModel::_usedEvents
mutableprivate

the synchronisation law of the ComposableModel

Definition at line 57 of file ComposableModel.hh.

◆ _vectorStateOf

ConstNodeMap< vector<State> > Diades::Automata::ComposableModel::_vectorStateOf
mutableprivate

Definition at line 68 of file ComposableModel.hh.

◆ _visited

ConstNodeMap< set<Event> > Diades::Automata::ComposableModel::_visited
mutableprivate

Definition at line 73 of file ComposableModel.hh.


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