DiaDes
0.1
DIAgnosis of Discrete-Event System
|
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <list>
#include <cmath>
#include <diades/utils/Random.hh>
#include <diades/utils/Verbose.hh>
#include <diades/utils/Log.hh>
#include <diades/utils/Selection.hh>
#include <diades/graph/ConstNodeMap.hh>
#include <diades/automata/Event.hh>
#include <diades/automata/Topology.hh>
#include <diades/automata/TopologyMap.hh>
#include <diades/automata/ObservableComponent.hh>
#include <diades/automata/SynchronisationRules.hh>
#include <diades/automata/ComposableModel.hh>
#include <diades/automata/SyncRulesLoad.hh>
#include "CmdInterface.hh"
Go to the source code of this file.
Typedefs | |
typedef Diades::Graph::ConstNodeMap< Event > | ConnectionMap |
global variable to globally index the generated events More... | |
typedef Diades::Graph::ConstNodeMap< ObservableComponent * > | ComponentNodeMap |
typedef Diades::Graph::ConstNodeMap< map< Topology::Connection, Event > > | SharedEventNodeMap |
Functions | |
vector< string > | fileExtensions (numberOfFileExtensions) |
vector< string > | options (numberOfOptions) |
vector< bool > | isSet (numberOfOptions, false) |
void | initialiseOptions () |
void | makeComponentComplete (unsigned outputDegreeMax, Selection< Event > &eventSelection, ObservableComponent &result) |
Transition | getTransitionFromInteractiveCurrentState (const ObservableComponent &interaction, State currentInteractingState, const Event &eventCurrentNode, map< Event, Topology::Connection > &mappingCurrentSideToInteraction, map< Topology::Connection, Event > &mappingConnectionToInteraction, const set< Event > &constrainedEvents) |
void | generateTransitionSystem (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, const ObservableComponent &interaction, set< Node >::const_iterator first, set< Node >::const_iterator last, unsigned numberOfStates, unsigned outputDegreeMax, ObservableComponent &result) |
void | defineObservableMask (unsigned obsMin, unsigned obsMax, unsigned obsInteractionMin, unsigned obsInteractionMax, const set< Event > &interactiveEvents, const set< Event > &nonInteractiveEvents, ObservableComponent &result) |
void | generateNonInteractiveEvents (const Topology &topology, Topology::Node node, unsigned evtMin, unsigned evtMax, unsigned obsMin, unsigned obsInteractionMax, ObservableComponent &result, set< Event > &nonInteractiveEvents) |
void | generateRandomComponent (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, const ObservableComponent &interaction, set< Node >::const_iterator first, set< Node >::const_iterator last, unsigned stateMin, unsigned stateMax, unsigned obsMin, unsigned obsMax, unsigned evtMin, unsigned evtMax, unsigned obsInteractionMin, unsigned obsInteractionMax, unsigned outputDegreeMax, ObservableComponent *result) |
void | initialiseSynchronisationRules (const Topology &topology, set< Node >::const_iterator first, set< Node >::const_iterator last, SharedEventNodeMap &sharedEventOfNode, const Diades::Graph::ConstNodeMap< pair< string, ObservableComponent *> > &projection, ParametrizedSynchronisation &synchronisation) |
ObservableComponent * | getSynchronisedInteraction (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, const Diades::Graph::ConstNodeMap< pair< string, ObservableComponent *> > &projection, set< Node >::const_iterator first, set< Node >::const_iterator last) |
void | getOutputProjection (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, const ObservableComponent &component, const set< Node > &nonGeneratedNeighbours, pair< string, ObservableComponent *> &result) |
void | propagateConstrainedInteractions (const Topology &topology, Topology::Node node, Diades::Graph::ConstNodeMap< int > &visitedNodes, set< Topology::Node > &generatedNeighbours, set< Topology::Node > &nonGeneratedNeighbours, list< Topology::Node > &nodesToVisit) |
void | writeComponent (const ObservableComponent &component, const string &dirName) |
bool | checkEventConsistency (const Topology &topology, unsigned evtMax, unsigned obsInteractionMin) |
void | generateSharedEvents (const Topology &topology, ComponentNodeMap &componentOfNode, SharedEventNodeMap &sharedEventOfNode, Topology::Node fixedTopoNode) |
void | generateBehaviour (const Topology &topology, unsigned stateMin, unsigned stateMax, unsigned evtMin, unsigned evtMax, unsigned obsMin, unsigned obsMax, unsigned obsInteractionMin, unsigned obsInteractionMax, ComponentNodeMap &componentOfNode, SharedEventNodeMap &sharedEventOfNode, string dirName, Node fixedTopoNode, unsigned outputDegreeMax) |
void | generateLatexComponents (const Topology &topology, SharedEventNodeMap &sharedEventOfNode, const ComponentNodeMap &componentOfNode, ofstream &latexfile) |
void | generateLatexEventIndex (const Topology &topology, SharedEventNodeMap &sharedEventOfNode, const ComponentNodeMap &componentOfNode, ofstream &latexfile) |
void | generateLatexEpilog (ofstream &latexfile) |
void | generateLatexTopology (const Topology &topology, SharedEventNodeMap &sharedEventOfNode, ofstream &latexfile) |
void | generateLatexPreamble (const Topology &topology, unsigned stateMin, unsigned stateMax, unsigned evtMin, unsigned evtMax, unsigned obsMin, unsigned obsMax, unsigned obsInteractionMin, unsigned obsInteractionMax, unsigned seed, unsigned outputDegreeMax, const string &fixedNode, const string &behaviourFileName, map< string, string > &assignedConnections, const ComponentNodeMap &componentOfNode, SharedEventNodeMap &sharedEventOfNode, const string &filename, ofstream &latexfile) |
void | generateLatexFile (const Topology &topology, unsigned stateMin, unsigned stateMax, unsigned evtMin, unsigned evtMax, unsigned obsMin, unsigned obsMax, unsigned obsInteractionMin, unsigned obsInteractionMax, unsigned seed, unsigned outputDegreeMax, const string &fixedNode, const string &behaviourFileName, map< string, string > &assignedConnections, const ComponentNodeMap &componentOfNode, SharedEventNodeMap &sharedEventOfNode, const string &filename) |
void | exportTopologyMap (const Topology &topology, SharedEventNodeMap &sharedEventOfNode, const ComponentNodeMap &componentOfNode, const string &mapTopoFileNameDest) |
void | generateStates (ObservableComponent &result, unsigned numberOfStates, vector< Node > &indexState) |
void | generateTriggerableEvents (unsigned numberOfUnusedEventPerState, unsigned numberOfTrans, Component::EventIterator first, Component::EventIterator last, unsigned nbEvents, set< Event > &newSelection, set< Event > &unusedEvents) |
void | makeComponentFullyConsistent (ObservableComponent &result, const Node &node, SharedEventNodeMap &sharedEventOfNode, const ObservableComponent &interaction, map< Event, Topology::Connection > &mappingInteractionToCurrentSide, map< Event, Topology::Connection > &mappingCurrentSideToInteraction, EdgeMap< int > &triggeredTransition, NodeMap< set< State > > &stateMapping, unsigned outputDegreeMax, Selection< Event > &eventSelection) |
void | propagateInteractingStates (ObservableComponent &result, const Node &node, SharedEventNodeMap &sharedEventOfNode, map< Event, Topology::Connection > &mappingInteractionToCurrentSide, const ObservableComponent &interaction, State state, State correspondingState, NodeMap< set< State > > &stateMapping) |
void | printDebugStartVisit (const Topology &topology, Topology::Node node) |
void | printDebugProjectionOnGeneratedNeighbours (const set< Topology::Node > &generatedNeighbours, const Diades::Graph::NodeMap< pair< string, ObservableComponent *> > &projection) |
void | printDebugLaw (const ParametrizedSynchronisation &synchronisation) |
int | main (int argc, char **argv) |
void | logDetailsBeforeCallingGenerateTransitionSystem (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, const ObservableComponent &interaction, set< Node >::const_iterator first, set< Node >::const_iterator last, unsigned numberOfStates, unsigned outputDegreeMax, ObservableComponent &result) |
void | initConstrainedConnectionMappings (const Topology &topology, const Node &node, SharedEventNodeMap &sharedEventOfNode, set< Node >::const_iterator first, set< Node >::const_iterator last, map< Event, Topology::Connection > &mappingInteractionToCurrentSide, map< Topology::Connection, Event > &mappingConnectionToInteraction, map< Event, Topology::Connection > &mappingCurrentSideToInteraction, set< Event > &constrainedEvents) |
unsigned | getNumberOfTransitions (const Selection< Event > &eventSelection, const set< Event > &constrainedEvents, const set< Event > &constrainedTriggerableEvents, unsigned numberOfAdmissibleEvents, unsigned numberOfStatesToVisit, unsigned outputDegreeMax, bool &mustUseNewEvent) |
void | generateTriggerableEvents (unsigned nbTransitions, Selection< Event > &eventSelection, const vector< unsigned > &admissibleEventIndexes, unsigned numberOfNonPreviouslySelectedButAdmissibleEvents, bool mustUseNewEvent, set< Event > &selectedEvents) |
void | getSelectedEvents (const ObservableComponent &interaction, State currentInteractingState, map< Event, Topology::Connection > &mappingInteractionToCurrentSide, map< Event, Topology::Connection > &mappingCurrentSideToInteraction, map< Topology::Connection, Event > &mappingConnectionToInteraction, Selection< Event > &eventSelection, const set< Event > &constrainedEvents, const set< Topology::Connection > &constrainedConnections, unsigned numberOfVisitedStates, ObservableComponent &result, unsigned outputDegreeMax, set< Event > &selectedEvents) |
bool | makeMinimalRequirement (unsigned outputDegreeMax, Selection< Event > &eventSelection, vector< State > &candidates, ObservableComponent &result) |
Variables | |
unsigned | numberOfOptions = 16 |
unsigned | numberOfFileExtensions = 0 |
string | description = "Usage: dd-generate\n\t --help |\n\t [--topo topologyFileName.topo]\n\t [--seed randomSeed]\n\t [--evtMin nbEvtMin]\n\t [--evtMax nbEvtMax]\n\t [--obsMin nbObsMin]\n\t [--obsMax nbObsMax]\n\t [--stateMin nbStateMin]\n\t [--stateMax nbStateMax]\n\t [--latex latexFileName]\n\t [--outputdir dirName]\n\t [--obsInteractionMin nbObsIntMin]\n\t [--obsInteractionMax nbObsIntMax]\n\t [--nodeBehaviour node=file.descomp ci=ej ck=el ...]]\n\t [--outputDegreeMax outDeg]\n\t [--petrinet]\n\n\n Generate a distributed discrete-event system that has the topology\n defined in the file topologyFileName.topo. The generator uses\n a random generator of number that can be initialised with the\n seed 'randomSeed'. If not provided, the seed is the starting time\n of each run of the program. As far as the behaviour of a component\n is concerned, the number of generated states is between nbStateMin\n and nbStateMax. The number of event is between nbEvtMin and nbEvtMax\n as long as it is compatible with the topology. The number of\n observable events is between nbObsMin and nbObsMax. The generated model\n consists of a set of files written in the directory 'dirName'. The\n model generator also generates a document in latex format for documentation\n purposes (if the option is set). The parameters --obsInteractionMin\n and --obsInteractionMax states the possible numbers of observable interactions.\n The --nodeBehaviour parameters states that one (and only one) of the node\n called 'node' has the predefined behaviour described in 'file.descomp'. \nConstraints like 'ci=sj' assert that the component 'node' implements the\n connection 'ci' of the topology with the iteractive event 'sj'.\n The option '--outputDegreeMax' rules the maximal number of transitions\n (i.e. events) that are the output of one state. If the --petrinet option is set, the distributed system is generated as a 1-bounded petri net. " |
unsigned | eventNumber = 0 |
This file is the main file of the command des_generate
Usage: des_generate --help | [--topo topologyFileName.topo] [--seed randomSeed] [--evtMin nbEvtMin] [--evtMax nbEvtMax] [--obsMin nbObsMin] [--obsMax nbObsMax] [--stateMin nbStateMin] [--stateMax nbStateMax] [--latex latexFileName] [--outputdir dirName] [--obsInteractionMin nbObsIntMin] [--obsInteractionMax nbObsIntMax] [--nodeBehaviour node=file.descomp ci=ej ck=el ...] [--outputDegreeMax outDeg] [--petrinet] Generate a distributed discrete-event system that has the topology defined in the file topologyFileName.topo. The generator uses a random generator of number that can be initialised with the seed 'randomSeed'. If not provided, the seed is the starting time of each run of the program. As far as the behaviour of a component is concerned, the number of generated states is between nbStateMin and nbStateMax. The number of event is between nbEvtMin and nbEvtMax as long as it is compatible with the topology. The number of observable events is between nbObsMin and nbObsMax. The generated model consists of a set of files written in the directory 'dirName'. The model generator also generates a document in latex format for documentation purposes (if the option is set). The parameters --obsInteractionMin and --obsInteractionMax states the possible numbers of observable interactions. The --nodeBehaviour parameters states that one (and only one) of the node called 'node' has the predefined behaviour described in 'file.descomp'. Constraints like 'ci=sj' assert that the component 'node' implements the connection 'ci' of the topology with the iteractive event 'sj'. The option '--outputDegreeMax' rules the maximal number of transitions (i.e. events) that are the output of one state. If the --petrinet option is set, the distributed system is generated as a 1-bounded petri net.
Definition in file DesGenerate.cc.
Definition at line 125 of file DesGenerate.cc.
global variable to globally index the generated events
Definition at line 124 of file DesGenerate.cc.
typedef Diades::Graph::ConstNodeMap< map<Topology::Connection, Event> > SharedEventNodeMap |
Definition at line 126 of file DesGenerate.cc.
enum Option |
Definition at line 81 of file DesGenerate.cc.
bool checkEventConsistency | ( | const Topology & | topology, |
unsigned | evtMax, | ||
unsigned | nbObsIntMin | ||
) |
Check whether the maximum number of Event allowed for this generation is at least greater that the number of shared events that are required to implement at least the topology.
topology | the Topology |
evtMax | the maximum number of events allowed for this generation* |
nbObsIntMin | the minimum number of observable interactions allowed for this generation |
Definition at line 1150 of file DesGenerate.cc.
References Diades::Automata::Topology::connectivity(), Diades::Automata::Topology::nodeBegin(), and Diades::Automata::Topology::nodeEnd().
Referenced by main().
void defineObservableMask | ( | unsigned | obsMin, |
unsigned | obsMax, | ||
unsigned | obsInteractionMin, | ||
unsigned | obsInteractionMax, | ||
const set< Event > & | interactiveEvents, | ||
const set< Event > & | nonInteractiveEvents, | ||
ObservableComponent & | result | ||
) |
Defintion of the observable mask of a component to generate
obsMin | the minimal number of generated observations |
obsMax | the maximal number of generated observations |
obsInteractionMin | the minimal number of generated observable interactions |
obsInteractionMax | the maximal number of generated observable interactions |
interactiveEvents | the set of interactive events of the component |
nonInteractiveEvents | the set of non-interactive events of the component |
result | the generated result |
Definition of the observable mask of a component to generate
obsMin | the minimal number of generated observations |
obsMax | the maximal number of generated observations |
obsInteractionMin | the minimal number of generated observable interactions |
obsInteractionMax | the maximal number of generated observable interactions |
interactiveEvents | the set of interactive events of the component |
nonInteractiveEvents | the set of non-interactive events of the component |
result | the generated result |
Definition at line 3160 of file DesGenerate.cc.
Referenced by generateRandomComponent().
void exportTopologyMap | ( | const Topology & | topology, |
SharedEventNodeMap & | sharedEventOfNode, | ||
const ComponentNodeMap & | componentOfNode, | ||
const string & | mapTopoFileNameDest | ||
) |
Export the topology mapping that has been generated
topology | the current Topology |
sharedEventOfNode | the current shared event mapping |
componentOfNode | the current node mapping |
mapTopoFileNameDest | the name of the file to write |
Definition at line 2894 of file DesGenerate.cc.
Referenced by main().
vector<string> fileExtensions | ( | numberOfFileExtensions | ) |
Referenced by main().
void generateBehaviour | ( | const Topology & | topology, |
unsigned | stateMin, | ||
unsigned | stateMax, | ||
unsigned | evtMin, | ||
unsigned | evtMax, | ||
unsigned | obsMin, | ||
unsigned | obsMax, | ||
unsigned | obsInteractionMin, | ||
unsigned | obsInteractionMax, | ||
ComponentNodeMap & | componentOfNode, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
string | dirName, | ||
Node | fixedTopoNode, | ||
unsigned | outputDegreeMax | ||
) |
Generation of the behaviour associated to a given Topology
topology | the given Topology |
stateMin | the minimum number of states to generate per Component |
stateMax | the maximum number of states to generate per Component |
evtMin | the minimum number of events to generate per Component |
evtMax | the maximum number of events to generate per Component |
obsMin | the minimum number of observable events to generate per Component |
obsMax | the maximum number of observable events to generate per Component |
obsInteractionMin | the minimum number of observable interactions to generate per Component |
obsInteractionMax | the maximum number of observable interactions to generate per Component |
componentOfNode | the returned association between topology nodes and generated components |
sharedEventOfNode | the returned association between topology connections and generated events |
dirName | the name of the output directory for writing the components ("des_comp" + "dot" formats) |
fixedTopoNode | a Node that contains a predefined behaviour if it exists, an invalid node otherwise |
outputDegreeMax | the maximal number of output transitions from a given state |
Selection of one Node 'node0' of the Topology for every Node 'node' in BFS('node0') do 'inputs' = neighbours of 'n' already generated 'outputs' = neighbours of 'n' not generated 'interaction' = interaction language coming from the nodes of 'inputs' via the table 'projection' generation of node 'n' consistent with 'interaction' 'projection[node]' = interaction language that must be consistent with the nodes of 'outputs' endfor
Definition at line 1282 of file DesGenerate.cc.
References debug, generateRandomComponent(), getOutputProjection(), getSynchronisedInteraction(), Diades::Automata::Topology::graph(), Diades::Automata::Topology::nodeBegin(), Diades::Automata::Topology::nodeEnd(), printDebugProjectionOnGeneratedNeighbours(), printDebugStartVisit(), propagateConstrainedInteractions(), Diades::Graph::Node::valid(), and writeComponent().
Referenced by main().
void generateLatexComponents | ( | const Topology & | topology, |
SharedEventNodeMap & | sharedEventOfNode, | ||
const ComponentNodeMap & | componentOfNode, | ||
ofstream & | latexfile | ||
) |
Write the description of the generated components in to the LaTex file
topology | the current Topology |
sharedEventOfNode | the current shared event mapping |
componentOfNode | the current node mapping |
latexfile | the LaTeX file stream |
Definition at line 2750 of file DesGenerate.cc.
References states.
void generateLatexEpilog | ( | ofstream & | latexfile | ) |
Write the end of the latex file
latexfile | LaTeX file stream |
Definition at line 2879 of file DesGenerate.cc.
void generateLatexEventIndex | ( | const Topology & | topology, |
SharedEventNodeMap & | sharedEventOfNode, | ||
const ComponentNodeMap & | componentOfNode, | ||
ofstream & | latexfile | ||
) |
Definition at line 3452 of file DesGenerate.cc.
void generateLatexFile | ( | const Topology & | topology, |
unsigned | stateMin, | ||
unsigned | stateMax, | ||
unsigned | evtMin, | ||
unsigned | evtMax, | ||
unsigned | obsMin, | ||
unsigned | obsMax, | ||
unsigned | obsInteractionMin, | ||
unsigned | obsInteractionMax, | ||
unsigned | seed, | ||
unsigned | outputDegreeMax, | ||
const string & | fixedNode, | ||
const string & | behaviourFileName, | ||
map< string, string > & | assignedConnections, | ||
const ComponentNodeMap & | componentOfNode, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const string & | filename | ||
) |
Write the LaTeX file
topology | the current Topology |
stateMin | the minimal number of generated states |
stateMax | the maximal number of generated states |
evtMin | the minimal number of generated events |
evtMax | the maximal number of generated events |
obsMin | the minimal number of generated observations |
obsMax | the maximal number of generated observations |
obsInteractionMin | the minimal number of generated observable interactions |
obsInteractionMax | the maximal number of generated observable interactions |
componentOfNode | the current component-node mapping |
sharedEventOfNode | the current shared event mapping |
filename | the name of the LaTeX file to write |
Definition at line 2562 of file DesGenerate.cc.
Referenced by main().
void generateLatexPreamble | ( | const Topology & | topology, |
unsigned | stateMin, | ||
unsigned | stateMax, | ||
unsigned | evtMin, | ||
unsigned | evtMax, | ||
unsigned | obsMin, | ||
unsigned | obsMax, | ||
unsigned | obsInteractionMin, | ||
unsigned | obsInteractionMax, | ||
unsigned | seed, | ||
unsigned | outputDegreeMax, | ||
const string & | fixedNode, | ||
const string & | behaviourFileName, | ||
map< string, string > & | assignedConnections, | ||
const ComponentNodeMap & | componentOfNode, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const string & | filename, | ||
ofstream & | latexfile | ||
) |
Write the preamble + introduction of the LaTeX file
topology | the current Topology |
stateMin | the minimal number of generated states |
stateMax | the maximal number of generated states |
evtMin | the minimal number of generated events |
evtMax | the maximal number of generated events |
obsMin | the minimal number of generated observations |
obsMax | the maximal number of generated observations |
obsInteractionMin | the minimal number of generated observable interactions |
obsInteractionMax | the maximal number of generated observable interactions |
componentOfNode | the current component-node mapping |
sharedEventOfNode | the current shared event mapping |
filename | the name of the LaTeX file to write |
latexfile | the resulting LaTeX file stream |
Definition at line 2620 of file DesGenerate.cc.
References states.
void generateLatexTopology | ( | const Topology & | topology, |
SharedEventNodeMap & | sharedEventOfNode, | ||
ofstream & | latexfile | ||
) |
Write the description of the current Topology in the LaTeX file
topology | the current Topology |
sharedEventOfNode | the current shared event mapping |
latexfile | the LaTeX file stream |
Definition at line 2707 of file DesGenerate.cc.
void generateNonInteractiveEvents | ( | const Topology & | topology, |
Topology::Node | node, | ||
unsigned | evtMin, | ||
unsigned | evtMax, | ||
unsigned | obsMin, | ||
unsigned | obsInteractionMax, | ||
ObservableComponent & | result, | ||
set< Event > & | nonInteractiveEvents | ||
) |
Generation of the non interactive events of a component to generate
topology | the current Topology |
node | the node to generate |
evtMin | the minimal number of generated events |
evtMax | the maximal number of generated events |
obsMin | the minimal number of generated observations |
obsInteractionMax | the maximal number of generated observable interactions |
result | the generated result |
nonInteractiveEvents | the generated set of non interactive events |
Here the component result already contains result->numberOfEvents() interactive events (including 0 events) . so we need to generate non interactive events such that the whole number of events is between [evtMin, evtMax]. Note also that there must be at least obsMin - obsInteractionMin non interactive events, as in the case only obsInteractionMin interactive events are set to be observable, obsMin - obsInteractionMin non interactive events must then be available to be set observable as well.
Definition at line 3091 of file DesGenerate.cc.
Referenced by generateRandomComponent().
void generateRandomComponent | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const ObservableComponent & | interaction, | ||
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last, | ||
unsigned | stateMin, | ||
unsigned | stateMax, | ||
unsigned | obsMin, | ||
unsigned | obsMax, | ||
unsigned | evtMin, | ||
unsigned | evtMax, | ||
unsigned | obsInteractionMin, | ||
unsigned | obsInteractionMax, | ||
unsigned | outputDegreeMax, | ||
ObservableComponent * | result | ||
) |
Generation of a component randomly
topology | the current Topology |
node | the Node to generate |
sharedEventOfNode | the current shared event mapping |
interaction | the interactive beheaviour that must be consistent with the generated result |
first | the iterator on the first neighbour (if it exists) of the current Node that is already generated |
last | the iterator on the item after the last neighbour of the current Node that is already generated |
stateMin | the minimal number of generated states |
stateMax | the maximal number of generated states |
obsMin | the minimal number of generated observations |
obsMax | the maximal number of generated observations |
evtMin | the minimal number of generated events |
evtMax | the maximal number of generated events |
obsInteractionMin | the minimal number of generated observable interactions |
obsInteractionMax | the maximal number of generated observable interactions |
outputDegreeMax | the maximal number of output transitions from a given state |
result | the generated result |
Definition at line 1640 of file DesGenerate.cc.
References always_require, defineObservableMask(), Diades::Automata::Component::eventBegin(), Diades::Automata::Component::eventEnd(), and generateNonInteractiveEvents().
Referenced by generateBehaviour().
void generateSharedEvents | ( | const Topology & | topology, |
ComponentNodeMap & | componentOfNode, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
Topology::Node | fixedTopoNode | ||
) |
Generation of the shared events
topology | the given topology |
componentOfNode | the (empty) components associated the nodes of the Topology |
sharedEventOfNode | the result of the generation. For each node, an Event is created for each Connection involved by the Node |
fixedTopoNode | the topology Node that is already fixed if it exists |
Definition at line 1193 of file DesGenerate.cc.
References always_assertion, eventNumber, Diades::Automata::Event::getEvent(), Diades::Automata::Topology::getNodeName(), Diades::Automata::Event::isValid(), Diades::Automata::Topology::nodeBegin(), Diades::Automata::Topology::nodeConnectionBegin(), Diades::Automata::Topology::nodeConnectionEnd(), Diades::Automata::Topology::nodeEnd(), and Diades::Automata::Event::setNickname().
Referenced by main().
void generateStates | ( | ObservableComponent & | result, |
unsigned | numberOfStates, | ||
vector< Node > & | indexState | ||
) |
Generator of states
result | the generated result |
numberOfStates | number of states to generate |
indexState | association between each generated state and an index. |
Definition at line 1697 of file DesGenerate.cc.
void generateTransitionSystem | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const ObservableComponent & | interaction, | ||
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last, | ||
unsigned | numberOfStates, | ||
unsigned | outputDegreeMax, | ||
ObservableComponent & | result | ||
) |
Random generation of a transition system
topology | the current Topology |
node | the node to generate |
sharedEventOfNode | the current shared event mapping |
interaction | the interaction model the node must comply with |
first | iterator on the first neighbour of 'node' already generated |
last | iterator on the item after the last neighbour of 'node' already generated |
numberOfStates | the number of states to generate in 'node' (generated by generateStates) |
outputDegreeMax | the maximal number of output transitions from a given state |
result | the result of the generation |
Definition at line 2092 of file DesGenerate.cc.
void generateTriggerableEvents | ( | unsigned | numberOfUnusedEventPerState, |
unsigned | numberOfTrans, | ||
Component::EventIterator | first, | ||
Component::EventIterator | last, | ||
unsigned | nbEvents, | ||
set< Event > & | newSelection, | ||
set< Event > & | unusedEvents | ||
) |
void generateTriggerableEvents | ( | unsigned | nbTransitions, |
Selection< Event > & | eventSelection, | ||
const vector< unsigned > & | admissibleEventIndexes, | ||
unsigned | numberOfNonPreviouslySelectedButAdmissibleEvents, | ||
bool | mustUseNewEvent, | ||
set< Event > & | selectedEvents | ||
) |
Generation of the set of triggerable events for the current generated stage
nbTransitions | number of transitions to trigger |
eventSelection | the set of available events (already selected in previous step or not) |
admissibleEventIndexes | The set of admissible event (indexes) as triggers in the current state |
numberOfNonPreviouslySelectedButAdmissibleEvents | no comment |
mustUseNewEvent | Is the use of non previoulsy selected events necessary. |
selectedEvents | the result as a set of events |
Definition at line 1880 of file DesGenerate.cc.
unsigned getNumberOfTransitions | ( | const Selection< Event > & | eventSelection, |
const set< Event > & | constrainedEvents, | ||
const set< Event > & | constrainedTriggerableEvents, | ||
unsigned | numberOfAdmissibleEvents, | ||
unsigned | numberOfStatesToVisit, | ||
unsigned | outputDegreeMax, | ||
bool & | mustUseNewEvent | ||
) |
Compute the number of transitions to generate for the current generated state
eventSelection | the set of available events (already selected in previous step or not) |
constrainedEvents | the set of events involved with an event in the interaction model |
constrainedTriggerableEvents | the set of events that are constrained but can be triggered in the current state |
numberOfAdmissibleEvents | The number of admissible event as triggers in the current state |
numberOfStatesToVisit | The number of states that are still required to generate |
outputDegreeMax | The maximal output degree of the current state |
mustUseNewEvent | set to be true if a new event (not selected before) must be selected at this stage. |
Definition at line 1827 of file DesGenerate.cc.
void getOutputProjection | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const ObservableComponent & | component, | ||
const set< Node > & | nonGeneratedNeighbours, | ||
pair< string, ObservableComponent *> & | result | ||
) |
topology | the current Topology |
node | the current Node of the Topology |
sharedEventOfNode | the current shared event mapping |
component | the generated component associated to the Node node |
nonGeneratedNeighbours | the set of nodes that are not generated yet and that are the neighbour of the Node 'node' |
result | a ObservableComponent whose behaviour is the interactive behaviour of the generated component with respect to the event of the neighbours contained in nonGeneratedNeighbours |
Definition at line 1439 of file DesGenerate.cc.
References always_ensure, always_require, Diades::Automata::Topology::cliqueBegin(), Diades::Automata::Topology::cliqueEnd(), Diades::Automata::Topology::getNodeName(), Diades::Automata::Topology::nodeConnectionBegin(), Diades::Automata::Topology::nodeConnectionEnd(), Diades::Utils::Identifier::str(), and toStream().
Referenced by generateBehaviour().
void getSelectedEvents | ( | const ObservableComponent & | interaction, |
State | currentInteractingState, | ||
map< Event, Topology::Connection > & | mappingInteractionToCurrentSide, | ||
map< Event, Topology::Connection > & | mappingCurrentSideToInteraction, | ||
map< Topology::Connection, Event > & | mappingConnectionToInteraction, | ||
Selection< Event > & | eventSelection, | ||
const set< Event > & | constrainedEvents, | ||
const set< Topology::Connection > & | constrainedConnections, | ||
unsigned | numberOfVisitedStates, | ||
ObservableComponent & | result, | ||
unsigned | outputDegreeMax, | ||
set< Event > & | selectedEvents | ||
) |
interaction | the interaction model the node must comply with |
currentInteractingState | the state in the interaction model associated to the current generated state |
mappingInteractionToCurrentSide | the mapping interactiveModel.event -> connection |
mappingCurrentSideToInteraction | the mapping generatedModel.event -> connection |
mappingConnectionToInteraction,the | mapping connection-> interactiveModel.event |
eventSelection | events already selected or not |
constrainedEvents | the set of events that are constrained due to the presence of an interaction model |
constrainedConnections | the set of Connections involved in out transitions of currentInteractingState |
numberOfVisitedStates | the number of states already visited in a previous step |
result | the node that is being generated |
outputDegreeMax | the maximal output degree |
selectedEvents | the resulting selection of events. |
Definition at line 1956 of file DesGenerate.cc.
ObservableComponent * getSynchronisedInteraction | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const Diades::Graph::ConstNodeMap< pair< string, ObservableComponent *> > & | projection, | ||
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last | ||
) |
topology | the Topology |
node | the Node about to be generated |
sharedEventOfNode | the Topology/Event mapping |
projection | the current generated projections on interactive events |
first | the iterator on the first neighbour (if it exists) of the current Node that is already generated |
last | the iterator on the item after the last neighbour of the current Node that is already generated |
topology | the Topology |
node | the Node about to be generated |
sharedEventOfNode | the Topology/Event mapping |
projection | the current generated projections on interactive events |
first | the iterator on the first neighbour (if it exists) of the current Node that is already generated |
last | the iterator on the item after the last neighbour of the current Node that is already generated |
Definition at line 1518 of file DesGenerate.cc.
References Diades::Automata::Topology::cliqueBegin(), Diades::Automata::Topology::cliqueEnd(), debug, Diades::Automata::Topology::getNodeName(), initialiseSynchronisationRules(), Diades::Automata::Component::newState(), Diades::Automata::Topology::nodeConnectionBegin(), Diades::Automata::Topology::nodeConnectionEnd(), Diades::Automata::Component::numberOfTransitions(), printDebugLaw(), Diades::Automata::ObservableComponent::project(), Diades::Automata::Component::setInitial(), and Diades::Utils::Identifier::str().
Referenced by generateBehaviour().
Transition getTransitionFromInteractiveCurrentState | ( | const ObservableComponent & | interaction, |
State | currentInteractingState, | ||
const Event & | eventCurrentNode, | ||
map< Event, Topology::Connection > & | mappingCurrentSideToInteraction, | ||
map< Topology::Connection, Event > & | mappingConnectionToInteraction, | ||
const set< Event > & | constrainedEvents | ||
) |
interaction | the interaction model the node must comply with |
currentInteractingState | the interacting state source of the transition to be looked for |
eventCurrentNode | the event (current node side) whose corresponding event in the interaction model is the event of the transition to be looked for |
mappingCurrentSideToInteraction | the mapping generatedModel.event -> connection |
mappingConnectionToInteraction | the mapping connection -> interactiveModel.event |
Definition at line 3302 of file DesGenerate.cc.
void initConstrainedConnectionMappings | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last, | ||
map< Event, Topology::Connection > & | mappingInteractionToCurrentSide, | ||
map< Topology::Connection, Event > & | mappingConnectionToInteraction, | ||
map< Event, Topology::Connection > & | mappingCurrentSideToInteraction, | ||
set< Event > & | constrainedEvents | ||
) |
Initialisation of the connection mappings for a given node in a given topology
topology | the current Topology |
node | the node to generate |
sharedEventOfNode | the current shared event mapping |
first | iterator on the first neighbour of 'node' already generated |
last | iterator on the item after the last neighbour of 'node' already generated |
mappingInteractionToCurrentSide | the mapping interactiveModel.event -> connection |
mappingConnectionToInteraction | the mapping connection -> interactiveModel.event |
mappingCurrentSideToInteraction | the mapping generatedModel.event -> connection |
constrainedEvents | the set of events that are constrained due to the presence of an interaction model |
Definition at line 1772 of file DesGenerate.cc.
void initialiseOptions | ( | ) |
Definition at line 99 of file DesGenerate.cc.
References DIRNAME, EVTMAX, EVTMIN, HELP, LATEXFILENAME, NODEBEHAVIOUR, OBSINTERACTIONMAX, OBSINTERACTIONMIN, OBSMAX, OBSMIN, options(), OUTPUTDEGREEMAX, SEED, STATEMAX, STATEMIN, and TOPOLOGYFILENAME.
Referenced by main().
void initialiseSynchronisationRules | ( | const Topology & | topology, |
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const Diades::Graph::ConstNodeMap< pair< string, ObservableComponent *> > & | projection, | ||
ParametrizedSynchronisation & | synchronisation | ||
) |
Create the synchronisation law that synchronises the interactive projections of [first,last(
topology | the Topology |
first | the iterator on the first neighbour (if it exists) of the current Node that is already generated |
last | the iterator on the item after the last neighbour of the current Node that is already generated |
sharedEventOfNode | the Topology/Event mapping |
projection | the current generated projections on interactive events |
synchronisation | the resulting synchronisation |
Definition at line 3032 of file DesGenerate.cc.
Referenced by getSynchronisedInteraction().
vector<bool> isSet | ( | numberOfOptions | , |
false | |||
) |
Referenced by main().
void logDetailsBeforeCallingGenerateTransitionSystem | ( | const Topology & | topology, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const ObservableComponent & | interaction, | ||
set< Node >::const_iterator | first, | ||
set< Node >::const_iterator | last, | ||
unsigned | numberOfStates, | ||
unsigned | outputDegreeMax, | ||
ObservableComponent & | result | ||
) |
Log some details before calling generateTransitionSystem (debug only)
topology | the current Topology |
node | the node to generate |
sharedEventOfNode | the current shared event mapping |
interaction | the interaction model the node must comply with |
first | iterator on the first neighbour of 'node' already generated |
last | iterator on the item after the last neighbour of 'node' already generated |
numberOfStates | the number of states to generate in 'node' (generated by generateStates) |
outputDegreeMax | the maximal number of output transitions from a given state |
result | the result of the generation |
Definition at line 1726 of file DesGenerate.cc.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function of the program des_generate
Basically, this function analyses the parameters to initiate the generation Then it calls the generator of shared events, then the generator of behaviours Write the results in output files.
argc | the number of parameters |
argv | the list of parameters |
Definition at line 524 of file DesGenerate.cc.
References Diades::Automata::ObservableMask::addMask(), Diades::Automata::Topology::addNode(), always_assertion, checkEventConsistency(), Diades::Automata::Topology::cliqueBegin(), Diades::Automata::Topology::cliqueEnd(), Diades::Automata::Topology::connectionBegin(), Diades::Automata::Topology::connectionEnd(), Diades::Automata::Topology::connectivity(), current, debug, description, DIRNAME, EVTMAX, EVTMIN, exportTopologyMap(), fileExtensions(), generateBehaviour(), generateLatexFile(), generateSharedEvents(), Diades::Automata::Topology::getConnectionLabel(), Diades::Automata::Event::getEvent(), Diades::Automata::Topology::getNodeName(), Diades::Automata::Topology::graph(), HELP, Diades::Automata::Topology::import(), initialiseOptions(), initialiseRandomGenerator(), Diades::Utils::initialiseSeed(), Diades::Automata::ObservableMask::isIdentifiable(), isSet(), LATEXFILENAME, Diades::Automata::Event::nickname(), Diades::Automata::Topology::nodeBegin(), NODEBEHAVIOUR, Diades::Automata::Topology::nodeConnectionBegin(), Diades::Automata::Topology::nodeConnectionEnd(), Diades::Automata::Topology::nodeEnd(), OBSINTERACTIONMAX, OBSINTERACTIONMIN, OBSMAX, OBSMIN, options(), OUTPUTDEGREEMAX, PETRINET, Diades::CmdInterface::printCommandLineError(), printUsage(), Diades::Automata::Topology::save(), Diades::Utils::saveAllLogs(), SEED, Diades::Utils::selectNValues(), Diades::Automata::Event::setNickname(), setVerboseLevel(), STATEMAX, STATEMIN, Diades::Utils::Identifier::str(), TOPOLOGYFILENAME, Diades::Utils::VbDebug, and Diades::Utils::VbOutput.
void makeComponentComplete | ( | unsigned | outputDegreeMax, |
Selection< Event > & | eventSelection, | ||
ObservableComponent & | result | ||
) |
Make the component compatible with in the case that not all the events were utilized during the classical generation of the component. To complete the model, some transitions are added randomly with the missing events
outputDegreeMax | the maximal number of output transitions from a given state |
eventSelection | events already selected or not |
result | the node that is being generated |
Definition at line 3409 of file DesGenerate.cc.
void makeComponentFullyConsistent | ( | ObservableComponent & | result, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
const ObservableComponent & | interaction, | ||
map< Event, Topology::Connection > & | mappingInteractionToCurrentSide, | ||
map< Event, Topology::Connection > & | mappingCurrentSideToInteraction, | ||
EdgeMap< int > & | triggeredTransition, | ||
NodeMap< set< State > > & | stateMapping, | ||
unsigned | outputDegreeMax, | ||
Selection< Event > & | eventSelection | ||
) |
Complete the generation of component in order to make it fully consistent with the interaction model
result | the result of the generation |
node | the node to generate |
sharedEventOfNode | the current shared event mapping |
interaction | the interaction model the node must comply with |
mappingInteractionToCurrentSide | association between an interactive event (neighbour side) and the underlying connection |
mappingCurrentSideToInteraction | association between an interactive event (node side) and the underlying connection |
triggeredTransition | transition mapping of interaction model that states whether a given transition of the interaction has been taken into account for the generation of the behaviour of the current node. |
stateMapping | mapping between the state of the generated model and some corresponding states in the interaction model. |
eventSelection | used to guarantee that any event type will be used at least once. |
bof mode
Definition at line 2327 of file DesGenerate.cc.
bool makeMinimalRequirement | ( | unsigned | outputDegreeMax, |
Selection< Event > & | eventSelection, | ||
vector< State > & | candidates, | ||
ObservableComponent & | result | ||
) |
Make the component compatible with in the case that not all the events were utilized during the classical generation of the component. To complete the model, some transitions are added randomly with the missing events. The modification are the minimal ones
outputDegreeMax | the maximal number of output transitions from a given state |
eventSelection | events already selected or not |
result | the node that is being generated |
Definition at line 3349 of file DesGenerate.cc.
vector<string> options | ( | numberOfOptions | ) |
Referenced by initialiseOptions(), and main().
void printDebugLaw | ( | const ParametrizedSynchronisation & | synchronisation | ) |
Definition at line 3071 of file DesGenerate.cc.
Referenced by getSynchronisedInteraction().
void printDebugProjectionOnGeneratedNeighbours | ( | const set< Topology::Node > & | generatedNeighbours, |
const Diades::Graph::NodeMap< pair< string, ObservableComponent *> > & | projection | ||
) |
Definition at line 3006 of file DesGenerate.cc.
Referenced by generateBehaviour().
void printDebugStartVisit | ( | const Topology & | topology, |
Topology::Node | node | ||
) |
FUNCTIONS FOR DEBUG ONLY
Definition at line 2997 of file DesGenerate.cc.
Referenced by generateBehaviour().
void propagateConstrainedInteractions | ( | const Topology & | topology, |
Topology::Node | node, | ||
Diades::Graph::ConstNodeMap< int > & | visitedNodes, | ||
set< Topology::Node > & | generatedNeighbours, | ||
set< Topology::Node > & | nonGeneratedNeighbours, | ||
list< Topology::Node > & | nodesToVisit | ||
) |
Determine in the neighbourhood of 'node' which node is already generated and not generated. In case some nodes are not in the pool of node to visit, insert them in the pool.
topology | the Topology |
node | the current node to generate |
visitedNodes | the status of the nodes in the topology updated if some neighbours has not been visited yet |
generatedNeighbours | the resulting neighbours that are generated |
nonGeneratedNeighbours | the resulting neighbours that are not generated |
nodesToVisit | the pool of nodes to visit, updated with unvisited neighbours. |
Definition at line 2950 of file DesGenerate.cc.
Referenced by generateBehaviour().
void propagateInteractingStates | ( | ObservableComponent & | result, |
const Node & | node, | ||
SharedEventNodeMap & | sharedEventOfNode, | ||
map< Event, Topology::Connection > & | mappingInteractionToCurrentSide, | ||
const ObservableComponent & | interaction, | ||
State | state, | ||
State | correspondingState, | ||
NodeMap< set< State > > & | stateMapping | ||
) |
result | the result of the generation |
node | the node to generate |
sharedEventOfNode | the current shared event mapping |
mappingInteractionToCurrentSide | association between an interactive event (neighbour side) and the underlying connection |
interaction | the interaction model the node must comply with |
state | the state target of the interactive transition just added by makeComponentFullyConsistent |
correspondingState | the state of the interaction model, target of the added interactive transition just taken into account by makeComponentFullyConsistent |
stateMapping | mapping between the state of the generated model and some corresponding states in the interaction model. |
Definition at line 2492 of file DesGenerate.cc.
void writeComponent | ( | const ObservableComponent & | component, |
const string & | dirName | ||
) |
Write the component into a file in a given directory
component | the component |
direNam | the directory name |
Definition at line 2925 of file DesGenerate.cc.
Referenced by generateBehaviour().
string description = "Usage: dd-generate\n\t --help |\n\t [--topo topologyFileName.topo]\n\t [--seed randomSeed]\n\t [--evtMin nbEvtMin]\n\t [--evtMax nbEvtMax]\n\t [--obsMin nbObsMin]\n\t [--obsMax nbObsMax]\n\t [--stateMin nbStateMin]\n\t [--stateMax nbStateMax]\n\t [--latex latexFileName]\n\t [--outputdir dirName]\n\t [--obsInteractionMin nbObsIntMin]\n\t [--obsInteractionMax nbObsIntMax]\n\t [--nodeBehaviour node=file.descomp ci=ej ck=el ...]]\n\t [--outputDegreeMax outDeg]\n\t [--petrinet]\n\n\n Generate a distributed discrete-event system that has the topology\n defined in the file topologyFileName.topo. The generator uses\n a random generator of number that can be initialised with the\n seed 'randomSeed'. If not provided, the seed is the starting time\n of each run of the program. As far as the behaviour of a component\n is concerned, the number of generated states is between nbStateMin\n and nbStateMax. The number of event is between nbEvtMin and nbEvtMax\n as long as it is compatible with the topology. The number of\n observable events is between nbObsMin and nbObsMax. The generated model\n consists of a set of files written in the directory 'dirName'. The\n model generator also generates a document in latex format for documentation\n purposes (if the option is set). The parameters --obsInteractionMin\n and --obsInteractionMax states the possible numbers of observable interactions.\n The --nodeBehaviour parameters states that one (and only one) of the node\n called 'node' has the predefined behaviour described in 'file.descomp'. \nConstraints like 'ci=sj' assert that the component 'node' implements the\n connection 'ci' of the topology with the iteractive event 'sj'.\n The option '--outputDegreeMax' rules the maximal number of transitions\n (i.e. events) that are the output of one state. If the --petrinet option is set, the distributed system is generated as a 1-bounded petri net. " |
Definition at line 97 of file DesGenerate.cc.
Referenced by main().
unsigned eventNumber = 0 |
Definition at line 120 of file DesGenerate.cc.
Referenced by generateSharedEvents().
unsigned numberOfFileExtensions = 0 |
Definition at line 89 of file DesGenerate.cc.
unsigned numberOfOptions = 16 |
Definition at line 88 of file DesGenerate.cc.