DiaDes
0.1
DIAgnosis of Discrete-Event System
|
#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 > ¤tTriggerableConstrainedEvents, 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 |
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).
Definition in file ModelGenerator.cc.
#define MAXDELAY 600 |
Definition at line 80 of file ModelGenerator.cc.
Referenced by main().
string appendInfo | ( | const string & | label, |
vector< ObservableComponent *>::size_type | index | ||
) |
Definition at line 791 of file ModelGenerator.cc.
Referenced by generateComponent(), generateLatexTopology(), generateModel(), and writeComponent().
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().
int computeTreeWidth | ( | const Graph & | topology | ) |
Definition at line 2539 of file ModelGenerator.cc.
Referenced by generateLatexTopology().
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 | ||
) |
Definition at line 1486 of file ModelGenerator.cc.
References appendInfo(), assertion, ensure, generateRandomValue(), generateTransitionSystem(), and require.
Referenced by generateModel().
void generateLatexComponents | ( | const vector< ObservableComponent *> & | setOfComponents, |
ofstream & | latexfile | ||
) |
Definition at line 2383 of file ModelGenerator.cc.
Referenced by generateLatexFile().
void generateLatexEpilog | ( | ofstream & | latexfile | ) |
Definition at line 2525 of file ModelGenerator.cc.
Referenced by 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 | ||
) |
Definition at line 2229 of file ModelGenerator.cc.
References generateLatexComponents(), generateLatexEpilog(), generateLatexPreamble(), and generateLatexTopology().
Referenced by main().
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().
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().
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().
long generateRandomValue | ( | long | lower, |
long | upper | ||
) |
Generation of a random integer in [lower,upper]
Definition at line 234 of file ModelGenerator.cc.
Referenced by completeObservableComponent(), generateComponent(), generateFaults(), generateSharedEvents(), generateTopology(), generateTopology2(), generateTransitionSystem(), generateTriggerableEvents(), main(), Diades::Utils::GFS< TIncidentEdges, TOpposite, TContainer, TAccumulator, TMark, TSolution, TPathCut >::next(), Diades::Utils::GFS< TIncidentEdges, TOpposite, TContainer, TAccumulator, TMark, TSolution, TPathCut >::pickup(), Diades::Automata::randomSimulateState(), Diades::Utils::selectRandomElement(), and Diades::Automata::timeStamp().
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().
void generateStates | ( | ObservableComponent * | newObservableComponent, |
unsigned | numberOfStates, | ||
set< Node > & | unreachedStates, | ||
vector< Node > & | indexState | ||
) |
Definition at line 874 of file ModelGenerator.cc.
Referenced by generateTransitionSystem().
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().
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().
void generateTransitionSystem | ( | ObservableComponent * | newObservableComponent, |
const ObservableComponent * | localInteraction, | ||
unsigned | numberOfStates, | ||
const vector< Event > & | events, | ||
unsigned | nbEvents | ||
) |
Definition at line 1171 of file ModelGenerator.cc.
References assertion, completeObservableComponent(), ensure, generateRandomValue(), generateStates(), and generateTriggerableEvents().
Referenced by generateComponent().
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().
void initialiseRandomGenerator | ( | ) |
Definition at line 248 of file ModelGenerator.cc.
Referenced by generateFaults(), generateSharedEvents(), generateTopology(), main(), and Diades::Automata::simulate().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 1972 of file ModelGenerator.cc.
References generateLatexFile(), generateModel(), MAXDELAY, printError(), printUsage(), and setTimeOut().
void printError | ( | string | parameter, |
string | message | ||
) |
Definition at line 258 of file ModelGenerator.cc.
References printUsage().
Referenced by main(), readParameters(), and readScenario().
void printUsage | ( | ) |
Definition at line 199 of file ModelGenerator.cc.
Referenced by main(), and printError().
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().
void setTimeOut | ( | long | delay | ) |
Definition at line 126 of file ModelGenerator.cc.
References sa, timer, and timer_handler().
Referenced by main().
void timer_handler | ( | int | signum | ) |
Definition at line 117 of file ModelGenerator.cc.
Referenced by setTimeOut().
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().
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().
NodeMap<BAN::Node> nodeOf |
Definition at line 2533 of file ModelGenerator.cc.
Referenced by computeTreeWidth().
struct sigaction sa |
Definition at line 81 of file ModelGenerator.cc.
Referenced by setTimeOut().
struct itimerval timer |
Definition at line 82 of file ModelGenerator.cc.
Referenced by setTimeOut().
BAN::Graph topo |
Definition at line 2532 of file ModelGenerator.cc.
Referenced by computeTreeWidth().