FSM Library - C++ version
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Fsm Class Reference
Inheritance diagram for Fsm:
Inheritance graph
[legend]

Public Member Functions

 Fsm (const std::string &fname, const std::string &fsmName, const int maxNodes, const int maxInput, const int maxOutput, const std::shared_ptr< FsmPresentationLayer > presentationLayer)
 
 Fsm (const std::string &fname, const std::shared_ptr< FsmPresentationLayer > presentationLayer, const std::string &fsmName)
 
 Fsm (const std::string &fsmName, const int maxInput, const int maxOutput, const std::vector< std::shared_ptr< FsmNode >> lst, const std::shared_ptr< FsmPresentationLayer > presentationLayer)
 
void dumpFsm (std::ofstream &outputFile) const
 
std::shared_ptr< FsmNodegetInitialState () const
 
std::string getName () const
 
virtual int getMaxNodes () const
 
int getMaxInput () const
 
int getMaxOutput () const
 
std::vector< std::shared_ptr< FsmNode > > getNodes () const
 
std::shared_ptr< FsmPresentationLayergetPresentationLayer () const
 
int getInitStateIdx () const
 
void resetColor ()
 
void toDot (const std::string &fname)
 
Fsm intersect (const Fsm &f)
 
std::shared_ptr< TreegetStateCover ()
 
std::shared_ptr< TreegetTransitionCover ()
 
OutputTree apply (const InputTrace &itrc)
 
Fsm transformToObservableFSM () const
 
bool isObservable () const
 
Minimal isMinimal () const
 
Fsm minimiseObservableFSM ()
 
Fsm minimise ()
 
bool isCharSet (const std::shared_ptr< Tree > w) const
 
void minimiseCharSet (const std::shared_ptr< Tree > w)
 
IOListContainer getCaracterisationSet ()
 
void calcStateIdentificationSets ()
 
void appendStateIdentificationSets (const std::shared_ptr< Tree > Wp2) const
 
IOListContainer wpMethod (const int m)
 
TestSuite createTestSuite (const IOListContainer &testCases)
 
bool isCompletelyDefined () const
 
bool isDeterministic () const
 
void setPresentationLayer (const std::shared_ptr< FsmPresentationLayer > ppresentationLayer)
 

Protected Member Functions

 Fsm (const std::shared_ptr< FsmPresentationLayer > presentationLayer)
 
std::shared_ptr< FsmNodenewNode (const int id, const std::shared_ptr< std::pair< std::shared_ptr< FsmNode >, std::shared_ptr< FsmNode >>> p)
 
bool contains (const std::vector< std::shared_ptr< std::pair< std::shared_ptr< FsmNode >, std::shared_ptr< FsmNode >>>> &lst, const std::shared_ptr< std::pair< std::shared_ptr< FsmNode >, std::shared_ptr< FsmNode >>> p)
 
bool contains (const std::vector< std::shared_ptr< FsmNode >> &lst, const std::shared_ptr< FsmNode > n)
 
std::shared_ptr< FsmNodefindp (const std::vector< std::shared_ptr< FsmNode >> &lst, const std::shared_ptr< std::pair< std::shared_ptr< FsmNode >, std::shared_ptr< FsmNode >>> p)
 
void parseLine (const std::string &line)
 
void readFsm (const std::string &fname)
 
void parseLineInitial (const std::string &line)
 
void readFsmInitial (const std::string &fname)
 
std::string labelString (std::unordered_set< std::shared_ptr< FsmNode >> &lbl) const
 

Protected Attributes

std::string name
 
std::vector< std::shared_ptr< FsmNode > > nodes
 
std::shared_ptr< FsmNodecurrentParsedNode
 
int maxInput
 
int maxOutput
 
int maxState
 
int initStateIdx
 
std::vector< std::shared_ptr< OFSMTable > > ofsmTableLst
 
std::shared_ptr< TreecharacterisationSet
 
std::vector< std::shared_ptr< Tree > > stateIdentificationSets
 
std::shared_ptr< FsmPresentationLayerpresentationLayer
 
Minimal minimal
 

Friends

std::ostream & operator<< (std::ostream &out, const Fsm &fsm)
 

Constructor & Destructor Documentation

Fsm::Fsm ( const std::shared_ptr< FsmPresentationLayer presentationLayer)
protected

default constructor without effect - needed by sub-classes

Here is the caller graph for this function:

Fsm::Fsm ( const std::string &  fname,
const std::string &  fsmName,
const int  maxNodes,
const int  maxInput,
const int  maxOutput,
const std::shared_ptr< FsmPresentationLayer presentationLayer 
)

Constructor creating an FSM from file - used only internally

Fsm::Fsm ( const std::string &  fname,
const std::shared_ptr< FsmPresentationLayer presentationLayer,
const std::string &  fsmName 
)

Constructor creating an FSM specified in a file.

Parameters
fnameFilename of a text file (typically with extension *.fsm), where each row is formatted as pre-state input output post-state pre-state is a number in range 0..(number of states -1) specifying the FSM pre-state input is a number in range 0..maxInput specifying the input applied to the pre-state output is a number in range 0..maxOutput specifying the output produced by the FSM when transiting to post-state on 'input' post-state is a number in range 0..(number of states -1) The initial state is expected to be the pre-state of the first row. The parameters 'number of states', maxInput, and maxOutput are determined when parsing the input file fname.
presentationLayerPointer to instance of a presentation layer which associates each input number in range 0..maxInput with an input name, each output number in range 0..maxOutput with an output name, and each state number in range 0..(number of states -1) with a state name.
fsmNamename of the FSM
Fsm::Fsm ( const std::string &  fsmName,
const int  maxInput,
const int  maxOutput,
const std::vector< std::shared_ptr< FsmNode >>  lst,
const std::shared_ptr< FsmPresentationLayer presentationLayer 
)

Constructor for creating an FSM from a list of FsmNodes that have been created beforehand, together with the outgoing transitions of each FsmNode/.

Parameters
fnameFilename where FSM specification resides in
fsmNamename of the FSM (appears in every node)
maxInputmaximal value of the (integer) input alphabet - admissible values are 0..maxInput
maxOutputmaximal value of (integer) output alphabet - admissible values are 0..maxOutput

Member Function Documentation

void Fsm::calcStateIdentificationSets ( )

Calculate the state identification sets. The sets are stored in list stateIdentificationSets, ordered by the FSM state numbers.

Precondition
The FSM must be observable and minimal, and the characterisation set must have been previously calculated using operation getCharacterisationSet().

Here is the call graph for this function:

Here is the caller graph for this function:

void Fsm::dumpFsm ( std::ofstream &  outputFile) const

Write FSM to text file using the standard format in each line which is also used for instantiating an FSM from file: pre-state input output post-state pre-state is a number in range 0..(number of states -1) specifying the FSM pre-state input is a number in range 0..maxInput specifying the input applied to the pre-state output is a number in range 0..maxOutput specifying the output produced by the FSM when transiting to post-state on 'input' post-state is a number in range 0..(number of states -1)

Here is the call graph for this function:

Here is the caller graph for this function:

IOListContainer Fsm::getCaracterisationSet ( )

Calculate the characterisation set W of a (possibly nondeterministic) FSM. In addition, calculate the state identification sets W_i containing prefixes of input traces of W, such that W_i distinguishes FSM state number i from every other FSM state.

Precondition
The FSM must be observable and minimised
Returns
The characterisation set W, represented by an instance of IOListContainer
Note
As a side effect, the state identification sets W_i are stored in the list stateIdentificationSets.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Fsm::getName ( ) const

This is the getter for the name of the FSM

Returns
Name of the FSM

Here is the caller graph for this function:

Fsm Fsm::intersect ( const Fsm f)

Create a new FSM that represents the intersection of this and the other FSM

Parameters
fthe other FSM
Returns
a new FSM which equals the intersection of this and f

Here is the call graph for this function:

bool Fsm::isDeterministic ( ) const

Check if FSM is deterministic

Returns
true if FSM is deterministic
bool Fsm::isObservable ( ) const

Check this FSM with respect to observability

Returns
true if and only if the FSM is observable

Here is the caller graph for this function:

Fsm Fsm::minimise ( )

Create the minimal observable FSM which is equivalent to this FSM. If this FSM is not observable, an observable equivalent is created first. The observable FSM is then minimised.

Returns
minimal observable FSM which is equivalent to this FSM

Here is the call graph for this function:

Here is the caller graph for this function:

Fsm Fsm::minimiseObservableFSM ( )

Create the minimal observable FSM which is equivalent to this FSM.

Precondition
This method can only be applied to an observable OFSM
Returns
minimal observable FSM which is equivalent to this FSM

Here is the caller graph for this function:

IOListContainer Fsm::wpMethod ( const int  m)

Perform test generation by means of the Wp Method. The algorithm we have implemented is applicable to both nondeterministic and deterministic FSMs. It relies, however, on the existence of OFSM tables which we only calculate for nondeterministic FSMs. Therefore we need a wrapper method for DFSMs which first calculates OFSM tables (by means of a call to minimiseObervableFSM()) and then calls the wpMethod() operation of the super class Fsm.

Parameters
mMaximum number of states
Returns
A test suite

Here is the call graph for this function:

Here is the caller graph for this function:


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