DiaDes  0.1
DIAgnosis of Discrete-Event System
Macros | Functions | Variables
ModelGenerator.cc File Reference
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <list>
#include <cmath>
#include <algorithm>
#include <set>
#include <Utils/Assertion.hh>
#include <Graph/Graph.hh>
#include <Graph/NodeMap.hh>
#include <Graph/EdgeMap.hh>
#include <AutModel/ObservableComponent.hh>
#include <h/Graph.h>

Go to the source code of this file.

Macros

#define MAXDELAY   600
 

Functions

void generateLatexFile (int nbComp, int connectivity, int nbStateMin, int nbStateMax, int nbFaultMin, int nbFaultMax, int nbSharedMax, int nbSharedMaxComp, int nbObsMin, int nbObsMax, int nbNormalMin, int nbNormalMax, const Graph &topology, const NodeMap< string > &compName, const EdgeMap< set< long > > &sharedEvnt, const vector< ObservableComponent *> &setOfComponents)
 
void generateLatexComponents (const vector< ObservableComponent *> &setOfComponents, ofstream &latexfile)
 
void generateLatexTopology (const Graph &topology, const NodeMap< string > &compName, const EdgeMap< set< long > > &sharedEvnt, ofstream &latexfile)
 
void generateLatexEpilog (ofstream &latexfile)
 
void generateLatexPreamble (const string &name, int nbComp, int connectivity, int nbStateMin, int nbStateMax, int nbFaultMin, int nbFaultMax, int nbSharedMax, int nbSharedMaxComp, int nbObsMin, int nbObsMax, int nbNormalMin, int nbNormalMax, ofstream &latexfile)
 
int computeTreeWidth (const Graph &topology)
 
void timer_handler (int signum)
 
void setTimeOut (long delay)
 
void visuDot (const Graph &topology, const NodeMap< long > &compIds, const EdgeMap< set< long > > &sharedEvnt, long numberOfSharedEvents)
 
void printUsage ()
 
long generateRandomValue (long lower, long upper)
 
void initialiseRandomGenerator ()
 
void printError (string parameter, string message)
 
void generateTopology (unsigned nbComp, unsigned connectivity, unsigned nbSharedMax, Graph &topology, NodeMap< unsigned > &compIds)
 
void generateTopology2 (unsigned nbComp, unsigned connectivity, unsigned nbSharedMax, Graph &topology, NodeMap< unsigned > &compIds)
 
unsigned generateSharedEvents (Graph &topology, EdgeMap< set< unsigned > > &sharedEvnt, unsigned nbSharedMax, unsigned nbSharedMaxComp)
 
string appendInfo (const string &label, vector< ObservableComponent *>::size_type index)
 
void writeComponent (const string &name, const Graph &behav, const EdgeMap< string > &transEvent, const set< string > &faultEvents, const set< string > &normalEvents, const set< string > &observableEvents, const set< string > &sharedEvents)
 
void generateStates (ObservableComponent *newObservableComponent, unsigned numberOfStates, set< Node > &unreachedStates, vector< Node > &indexState)
 
void generateTriggerableEvents (unsigned numberOfUnusedEventPerState, unsigned numberOfTrans, const vector< Event > &events, unsigned nbEvents, const set< Event > &constrainedEvents, const set< Event > &currentTriggerableConstrainedEvents, set< Event > &newSelection, set< Event > &unusedEvents)
 
void propagateInteractingStates (ObservableComponent *newObservableComponent, const ObservableComponent *localInteraction, State state, State correspondingState, NodeMap< set< State > > &stateMapping)
 
void completeObservableComponent (ObservableComponent *newObservableComponent, const ObservableComponent *localInteraction, EdgeMap< int > &triggeredTransition, NodeMap< set< State > > &stateMapping, set< Event > &unusedEvents)
 
void generateTransitionSystem (ObservableComponent *newObservableComponent, const ObservableComponent *localInteraction, unsigned numberOfStates, const vector< Event > &events, unsigned nbEvents)
 
ObservableComponent * generateComponent (vector< ObservableComponent *>::size_type componentIndex, ObservableComponent *newObservableComponent, ObservableComponent *interaction, set< Event > &faultEvents, set< Event > &normalEvents, set< Event > &observableEvents, set< Event > &sharedEvents, const set< string > &labelOfSharedEvents, map< string, set< vector< ObservableComponent *>::size_type > > &unknownScope, unsigned nbStateMin, unsigned nbStateMax, unsigned nbFaultMin, unsigned nbFaultMax, unsigned nbObsMin, unsigned nbObsMax, unsigned nbNormalMin, unsigned nbNormalMax)
 
void generateModel (unsigned nbComp, unsigned connectivity, unsigned nbStateMin, unsigned nbStateMax, unsigned nbFaultMin, unsigned nbFaultMax, unsigned nbSharedMax, unsigned nbSharedMaxComp, unsigned nbObsMin, unsigned nbObsMax, unsigned nbNormalMin, unsigned nbNormalMax, Graph &topology, NodeMap< string > &compName, EdgeMap< set< unsigned > > &sharedEvnt, vector< ObservableComponent *> &setOfComponents)
 
int main (int argc, char *argv[])
 

Variables

struct sigaction sa
 
struct itimerval timer
 
BAN::Graph topo
 
NodeMap< BAN::Node > nodeOf
 

Detailed Description

This file is the main file of the command ModelGenerator

Usage: ModelGenerator  
       --components   nbComp 
       --connectivity nbConn
       --commonConnectionMax nbConn
       --cliqueSizeMax cliqueSize
       --stateMin  nbStateMin
       --stateMax  nbStateMax  
       --faultMin  nbFaultMin 
       --faultMax  nbFaultMax
       --obsMin nbObsMin
       --obsMax    nbObsMax
       --normalMin nbNormalMin
       --normalMax nbNormalMax
       --seed randomSeed
       --output modelFileName
       --latex  latexFileName


       Generate a distributed discrete-event system that is a cluster of
       'nbComp' components. The connectivity of each component is at most
       'nbConn', in other words, a component communicates with its
       neighbourhood with a set of events whose size is between 1 and 'nbConn'.
       A connection involves a set of components (that is then called a
       clique). 'cliqueSizeMax' sets the maximal size of a clique
       (default = 2). Two components may have several connections in common,
       'commonConnectionMax' sets the   maximal number of connections
       involving two components (default = 2). The generation is random and
       require a seed (default = depends on the time). Two runs with the same
       seed and parameters generate the same topology.

       As far as the behaviour of a component is concerned, its number of
       states is between nbStateMin and nbStateMax. It contains nbFault
       fault types, nbFault between nbFaultMin and nbFaultMax. It contains
       nbNormal normal events, nbNormal between nbNormalMin and nbNormalMax.
       The generated components are live (every state has at least an output
       transition) and globally consistent (for any local trajectory there exists
       a global trajectory. The generated model consists of a file named
       'modelFileName'. The model generator also generates a document in latex
       format for documentation purposes (if the option is set).
Author
Yannick Pencole - LAAS CNRS
Version
0.1

Definition in file ModelGenerator.cc.

Macro Definition Documentation

◆ MAXDELAY

#define MAXDELAY   600

Definition at line 80 of file ModelGenerator.cc.

Referenced by main().

Function Documentation

◆ appendInfo()

string appendInfo ( const string &  label,
vector< ObservableComponent *>::size_type  index 
)

◆ completeObservableComponent()

void completeObservableComponent ( ObservableComponent *  newObservableComponent,
const ObservableComponent *  localInteraction,
EdgeMap< int > &  triggeredTransition,
NodeMap< set< State > > &  stateMapping,
set< Event > &  unusedEvents 
)

Definition at line 1045 of file ModelGenerator.cc.

References generateRandomValue(), and propagateInteractingStates().

Referenced by generateTransitionSystem().

◆ computeTreeWidth()

int computeTreeWidth ( const Graph topology)

Definition at line 2539 of file ModelGenerator.cc.

References nodeOf, and topo.

Referenced by generateLatexTopology().

◆ generateComponent()

ObservableComponent* generateComponent ( vector< ObservableComponent *>::size_type  componentIndex,
ObservableComponent *  newObservableComponent,
ObservableComponent *  interaction,
set< Event > &  faultEvents,
set< Event > &  normalEvents,
set< Event > &  observableEvents,
set< Event > &  sharedEvents,
const set< string > &  labelOfSharedEvents,
map< string, set< vector< ObservableComponent *>::size_type > > &  unknownScope,
unsigned  nbStateMin,
unsigned  nbStateMax,
unsigned  nbFaultMin,
unsigned  nbFaultMax,
unsigned  nbObsMin,
unsigned  nbObsMax,
unsigned  nbNormalMin,
unsigned  nbNormalMax 
)
Todo:
generalise: some shared events may be observable

Definition at line 1486 of file ModelGenerator.cc.

References appendInfo(), assertion, ensure, generateRandomValue(), generateTransitionSystem(), and require.

Referenced by generateModel().

◆ generateLatexComponents()

void generateLatexComponents ( const vector< ObservableComponent *> &  setOfComponents,
ofstream &  latexfile 
)

Definition at line 2383 of file ModelGenerator.cc.

Referenced by generateLatexFile().

◆ generateLatexEpilog()

void generateLatexEpilog ( ofstream &  latexfile)

Definition at line 2525 of file ModelGenerator.cc.

Referenced by generateLatexFile().

◆ generateLatexFile()

void generateLatexFile ( int  nbComp,
int  connectivity,
int  nbStateMin,
int  nbStateMax,
int  nbFaultMin,
int  nbFaultMax,
int  nbSharedMax,
int  nbSharedMaxComp,
int  nbObsMin,
int  nbObsMax,
int  nbNormalMin,
int  nbNormalMax,
const Graph topology,
const NodeMap< string > &  compName,
const EdgeMap< set< long > > &  sharedEvnt,
const vector< ObservableComponent *> &  setOfComponents 
)

◆ generateLatexPreamble()

void generateLatexPreamble ( const string &  name,
int  nbComp,
int  connectivity,
int  nbStateMin,
int  nbStateMax,
int  nbFaultMin,
int  nbFaultMax,
int  nbSharedMax,
int  nbSharedMaxComp,
int  nbObsMin,
int  nbObsMax,
int  nbNormalMin,
int  nbNormalMax,
ofstream &  latexfile 
)

Definition at line 2260 of file ModelGenerator.cc.

Referenced by generateLatexFile().

◆ generateLatexTopology()

void generateLatexTopology ( const Graph topology,
const NodeMap< string > &  compName,
const EdgeMap< set< long > > &  sharedEvnt,
ofstream &  latexfile 
)

Definition at line 2318 of file ModelGenerator.cc.

References appendInfo(), and computeTreeWidth().

Referenced by generateLatexFile().

◆ generateModel()

void generateModel ( unsigned  nbComp,
unsigned  connectivity,
unsigned  nbStateMin,
unsigned  nbStateMax,
unsigned  nbFaultMin,
unsigned  nbFaultMax,
unsigned  nbSharedMax,
unsigned  nbSharedMaxComp,
unsigned  nbObsMin,
unsigned  nbObsMax,
unsigned  nbNormalMin,
unsigned  nbNormalMax,
Graph topology,
NodeMap< string > &  compName,
EdgeMap< set< unsigned > > &  sharedEvnt,
vector< ObservableComponent *> &  setOfComponents 
)

Definition at line 1833 of file ModelGenerator.cc.

References appendInfo(), generateComponent(), generateSharedEvents(), generateTopology2(), and visuDot().

Referenced by main().

◆ generateRandomValue()

long generateRandomValue ( long  lower,
long  upper 
)

◆ generateSharedEvents()

unsigned generateSharedEvents ( Graph topology,
EdgeMap< set< unsigned > > &  sharedEvnt,
unsigned  nbSharedMax,
unsigned  nbSharedMaxComp 
)

Definition at line 588 of file ModelGenerator.cc.

References assertion, generateRandomValue(), and initialiseRandomGenerator().

Referenced by generateModel().

◆ generateStates()

void generateStates ( ObservableComponent *  newObservableComponent,
unsigned  numberOfStates,
set< Node > &  unreachedStates,
vector< Node > &  indexState 
)

Definition at line 874 of file ModelGenerator.cc.

Referenced by generateTransitionSystem().

◆ generateTopology()

void generateTopology ( unsigned  nbComp,
unsigned  connectivity,
unsigned  nbSharedMax,
Graph topology,
NodeMap< unsigned > &  compIds 
)

Definition at line 281 of file ModelGenerator.cc.

References generateRandomValue(), and initialiseRandomGenerator().

Referenced by main().

◆ generateTopology2()

void generateTopology2 ( unsigned  nbComp,
unsigned  connectivity,
unsigned  nbSharedMax,
Graph topology,
NodeMap< unsigned > &  compIds 
)

Definition at line 399 of file ModelGenerator.cc.

References generateRandomValue().

Referenced by generateModel().

◆ generateTransitionSystem()

void generateTransitionSystem ( ObservableComponent *  newObservableComponent,
const ObservableComponent *  localInteraction,
unsigned  numberOfStates,
const vector< Event > &  events,
unsigned  nbEvents 
)

◆ generateTriggerableEvents()

void generateTriggerableEvents ( unsigned  numberOfUnusedEventPerState,
unsigned  numberOfTrans,
const vector< Event > &  events,
unsigned  nbEvents,
const set< Event > &  constrainedEvents,
const set< Event > &  currentTriggerableConstrainedEvents,
set< Event > &  newSelection,
set< Event > &  unusedEvents 
)

Definition at line 899 of file ModelGenerator.cc.

References assertion, ensure, generateRandomValue(), and require.

Referenced by generateTransitionSystem().

◆ initialiseRandomGenerator()

void initialiseRandomGenerator ( )

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ printError()

void printError ( string  parameter,
string  message 
)

Definition at line 258 of file ModelGenerator.cc.

References printUsage().

Referenced by main(), readParameters(), and readScenario().

◆ printUsage()

void printUsage ( )

Definition at line 199 of file ModelGenerator.cc.

Referenced by main(), and printError().

◆ propagateInteractingStates()

void propagateInteractingStates ( ObservableComponent *  newObservableComponent,
const ObservableComponent *  localInteraction,
State  state,
State  correspondingState,
NodeMap< set< State > > &  stateMapping 
)

Definition at line 983 of file ModelGenerator.cc.

Referenced by completeObservableComponent().

◆ setTimeOut()

void setTimeOut ( long  delay)

Definition at line 126 of file ModelGenerator.cc.

References sa, timer, and timer_handler().

Referenced by main().

◆ timer_handler()

void timer_handler ( int  signum)

Definition at line 117 of file ModelGenerator.cc.

Referenced by setTimeOut().

◆ visuDot()

void visuDot ( const Graph topology,
const NodeMap< long > &  compIds,
const EdgeMap< set< long > > &  sharedEvnt,
long  numberOfSharedEvents 
)

Definition at line 149 of file ModelGenerator.cc.

Referenced by generateModel().

◆ writeComponent()

void writeComponent ( const string &  name,
const Graph behav,
const EdgeMap< string > &  transEvent,
const set< string > &  faultEvents,
const set< string > &  normalEvents,
const set< string > &  observableEvents,
const set< string > &  sharedEvents 
)

Definition at line 805 of file ModelGenerator.cc.

References appendInfo().

Variable Documentation

◆ nodeOf

NodeMap<BAN::Node> nodeOf

Definition at line 2533 of file ModelGenerator.cc.

Referenced by computeTreeWidth().

◆ sa

struct sigaction sa

Definition at line 81 of file ModelGenerator.cc.

Referenced by setTimeOut().

◆ timer

struct itimerval timer

Definition at line 82 of file ModelGenerator.cc.

Referenced by setTimeOut().

◆ topo

BAN::Graph topo

Definition at line 2532 of file ModelGenerator.cc.

Referenced by computeTreeWidth().