25 latexfile <<
"\\documentclass[11pt]{article}" << endl;
26 latexfile <<
"\\usepackage{array}" << endl;
27 latexfile <<
"\\textwidth 17cm \\textheight 26cm \\voffset -3cm \\hoffset -1.6cm" << endl;
28 latexfile <<
"\\title{Report on the accuracy analysis}" << endl;
31 latexfile <<
"\\date{" << ctime( &rawtime ) <<
"}" << endl;
32 latexfile <<
"\\author{Diades::check\\_accuracy tool, CNRS-LAAS, 2006-2011}" << endl;
33 latexfile <<
"\\begin{document}" << endl;
34 latexfile <<
"\\maketitle" << endl;
41 latexfile <<
"\\end{document}" << endl;
48 verbose<VbOutput>(
"Usage: check_accuracy Component.Fault topology.topo topologymap.maptopo subconfiguration.subconf [--depth number | --verbose verbose_mode --no_observable_interactions]\n");
49 verbose<VbOutput>(
" - Component.Fault: label of an event. 'Component' corresponds to the name of a component and\n");
50 verbose<VbOutput>(
" and Fault corresponds to the label of the event as written in the corresponding des_comp file\n");
51 verbose<VbOutput>(
" - verbose_mode is ether 'on' (simple output) or 'debug' (more details)\n");
52 verbose<VbOutput>(
" - the depth number is to limit the search for recommendations to a given depth.\n");
53 verbose<VbOutput>(
" Without this option, there is no limit, with depth= 0 there is no limit. BE CAREFUL,\n");
54 verbose<VbOutput>(
" THE RECOMMENDATION ALGORITHM IS EXPONENTIAL TO DEPTH. It may happen that for a given\n");
55 verbose<VbOutput>(
" depth, the algorithm does not find a solution, in this case it will return the whole set\n");
56 verbose<VbOutput>(
" of events that are relaxed and present in the traces generating an accuracy problem.\n\n");
64 string & topologyFile,
string & topologyMapFile,
string & subconfigurationFile,
67 if((argc < 5) || (argc > 9))
75 topologyMapFile.clear();
76 subconfigurationFile.clear();
81 stream >> component >> point >> event;
84 cerr <<
"The interpretation of the fault event has failed, please check the format COMP.EVENT" << endl;
87 list<string> extensions;
88 extensions.push_back(
"topo");
89 extensions.push_back(
"subconf");
90 extensions.push_back(
"maptopo");
95 topologyFile = argv[2];
101 subconfigurationFile = argv[2];
107 topologyMapFile = argv[2];
118 if((ext2 ==
"topo") && (topologyFile.empty()))
120 topologyFile = argv[3];
124 if((ext2 ==
"subconf") && (subconfigurationFile.empty()))
126 subconfigurationFile = argv[3];
130 if((ext2 ==
"maptopo") && (topologyMapFile.empty()))
132 topologyMapFile = argv[3];
143 if((ext3 ==
"topo") && (topologyFile.empty()))
145 topologyFile = argv[4];
149 if((ext3 ==
"subconf") && (subconfigurationFile.empty()))
151 subconfigurationFile = argv[4];
155 if((ext3 ==
"maptopo") && (topologyMapFile.empty()))
157 topologyMapFile = argv[4];
170 string currentParameter = argv[index];
173 if((param ==
NOPARAMETER) && (currentParameter ==
"--depth")) { param =
DEPTH; }
183 currentParameter = argv[index];
184 if(currentParameter==
"debug")
190 if(currentParameter==
"on")
208 currentParameter = argv[index];
209 cout <<
"string = " << currentParameter << endl;
211 stream << currentParameter << endl;
213 cout << depth << endl;
229 int main(
int argc,
char ** argv)
231 ofstream latexFile(
"check_accuracy_report.tex");
233 latexFile <<
"\\section{General information about the analysed model}" << endl;
234 latexFile <<
"\\begin{itemize}" << endl;
237 verbose<VbOutput>(
"Accuracy checker\n");
238 verbose<VbOutput>(
"LAAS-CNRS, 2006-2011, 7 avenue du Colonel Roche, Toulouse, France\n");
239 verbose<VbOutput>(
"Contact: yannick.pencole@laas.fr\n");
240 vector<Diades::Automata::ObservableComponent *> components;
246 string subconfigurationFile;
247 string topologyMapFile;
249 getInterface(argc,argv,component,event,topologyFile,topologyMapFile,subconfigurationFile,depth,level);
250 latexFile <<
"\\item Fault event to be analysed: {\\tt " <<
event <<
"} from the component {\\tt " << component <<
"}." << endl;
254 topology.
import(topologyFile);
255 latexFile <<
"\\end{itemize}" << endl;
256 latexFile <<
"\\subsection{Topology}" << endl;
257 latexFile <<
"\\begin{itemize}" << endl;
259 double numberFreeProductStates = 1.0;
268 if(components.back()->importDesCompModel(topology.
getNodeName(*it).
str() +
".des_comp"))
271 latexFile <<
"\\item Node {\\tt " << topology.
getNodeName(*it).
str() <<
"}: " << components.back()->numberOfStates() <<
" states, " << components.back()->numberOfTransitions() <<
" transitions." << endl;
272 numberFreeProductStates = numberFreeProductStates * components.back()->numberOfStates();
273 latexFile <<
"\\item Events of Node {\\tt " << topology.
getNodeName(*it).
str() <<
"}: ";
275 eventIt != components.back()->eventEnd();
278 latexFile <<
"{\\tt " << eventIt->nickname() <<
"} ";
284 if(!components.back()->containsEvent(studiedEvent))
286 log<LgProcess>(
"The event %1% does not belong to the component %2%")
287 % studiedEvent.
label()
289 log<LgProcess>(
"Here are the events contained in this component: %1%")
290 %
toStream(components.back()->eventBegin(), components.back()->eventEnd());
301 latexFile <<
"\\item Number of free product states: \\verb|" << numberFreeProductStates <<
"|" << endl;
308 latexFile <<
"\\item Connection {\\tt " << topology.
getConnectionLabel(*connIt) <<
"} involves the events: " << endl;
314 latexFile <<
"{\\tt " << *eventIt <<
"} ";
321 ifstream file(subconfigurationFile.c_str());
325 latexFile <<
"\\end{itemize}" << endl;
326 latexFile <<
"\\subsection{Subconfiguration}" << endl;
327 latexFile <<
"\\begin{itemize}" << endl;
333 latexFile <<
"{\\tt " << topology.
getNodeName(*compIt).
str() <<
"} ";
340 latexFile <<
"\\item This subconfiguration is maximal, that there is no relaxed connections involving two components of the subconfiguration" << endl;
344 latexFile <<
"\\item This subconfiguration is not maximal, that there are some relaxed connections involving two components of the subconfiguration." << endl;
375 if(subconf.
root() != root)
377 latexFile<<
"\\item The root node of the subconfiguration is not the component where the fault takes place." << endl;
380 latexFile<<
"\\item The root node of the subconfiguration is {\\tt " << topology.
getNodeName(subconf.
root()).str()
381 <<
"} that is the component where the fault to analyse occurs." << endl;
383 latexFile <<
"\\item If there is an accuracy problem with this subconfiguration, it is due to the following shared events: " << endl;
384 latexFile <<
"\\begin{description}" << endl;
388 { latexFile <<
"\\item[External event] ";
394 latexFile <<
"{\\tt " << *eventIt <<
"} ";
401 { latexFile <<
"\\item[Relaxed event] ";
407 latexFile <<
"{\\tt " << *eventIt <<
"} ";
411 latexFile <<
"\\end{description}" << endl;
412 set<Diades::Automata::Event> events;
413 events.insert(studiedEvent);
415 set< set<Diades::Automata::Event> > minimalCombinations;
416 latexFile <<
"\\end{itemize}" << endl;
417 latexFile <<
"\\section{Accuracy analysis}" << endl;
418 latexFile <<
"\\begin{itemize}" << endl;
422 verbose<VbOutput>(
"ACCURATE\n");
423 verbose<VbProcess>(
"Here are some details:\n %1% \n") % information;
427 verbose<VbOutput>(
"MAY BE NOT ACCURATE\n");
428 verbose<VbInfo>(
"Here are some details:\n %1% \n") % information;
429 for(
set< set<Diades::Automata::Event> >::const_iterator it = minimalCombinations.begin();
430 it != minimalCombinations.end(); ++it)
432 verbose<VbOutput>(
"%1%\n") %
toStream( it->begin(), it->end());
438 latexFile <<
"\\end{itemize}" << endl;
439 latexFile <<
"\\newpage \\huge{ALERT: failure}\\\\" << endl;
440 latexFile <<
"Here are the logs recorded during the analysis." << endl;
441 latexFile <<
"\\begin{verbatim}" << endl;
442 log<LgProcess>(
"check_accuracy has failed, sorry for any inconvience: %1%")
446 latexFile <<
"\\end{verbatim}" << endl;
449 for(vector<Diades::Automata::ObservableComponent *>::size_type i = 0; i < components.size();
454 delete components[i];
458 latexFile <<
"\\end{itemize}" << endl;
459 latexFile <<
"End of the accuracy analysis." << endl;
const Label & label() const
unordered_set< Node >::const_iterator NodeIterator
Event getEvent(Event::Id id)
void generateLatexPreamble(ofstream &latexfile)
An Identifier is a reference to a string (IdentifierData) that only contains alpha-numeric characters...
ConnectionIterator connectionBegin() const
unsigned numberOfEffectiveConnections() const
ComponentIterator componentBegin() const
InputIterator getFileExtension(const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
ConnectionIterator relaxedConnectionEnd() const
NodeIterator nodeEnd() const
void setVerboseLevel(Diades::Utils::VerboseLevel level)
ConnectionIterator externalConnectionBegin() const
const string & str() const
void importMap(const string &fileName)
unsigned numberOfExternalConnections() const
vector< Event >::const_iterator EventIterator
unsigned numberOfRelaxedConnections() const
An observable Component defined as a automaton.
ConnectionSet::const_iterator ConnectionIterator
void generateLatexEpilog(ofstream &latexfile)
unordered_set< Connection >::const_iterator ConnectionIterator
EventIterator eventBegin() const
NodeIterator nodeBegin() const
ConnectionIterator effectiveConnectionEnd() const
void getInterface(int argc, char **argv, Diades::Utils::Identifier &component, Diades::Utils::Identifier &event, string &topologyFile, string &topologyMapFile, string &subconfigurationFile, int &depth, VerboseLevel &level)
void saveLog(Logger logger, ostream &os)
const ConnectionMap & getConnectionMap(Topology::Connection connection) const
Diades::Utils::ToStream< InputIterator, Diades::Utils::AlwaysTrue< typename InputIterator::reference > > toStream(InputIterator first, InputIterator last)
const Identifier & getNodeName(Node node) const
ComponentIterator componentEnd() const
void mapComponentToNode(const ObservableComponent &component, Topology::Node itsNode)
const Identifier & getConnectionLabel(Connection connection) const
unsigned numberOfComponents() const
unsigned numberOfConnections() const
unsigned numberOfNodes() const
ConnectionIterator effectiveConnectionBegin() const
static EventFactory * factory()
set< Event >::const_iterator EventIterator
ConnectionIterator relaxedConnectionBegin() const
Topology::Node root() const
ConnectionIterator connectionEnd() const
Logging facilities for the Diades projects.
ComponentSet::const_iterator ComponentIterator
EventIterator eventEnd() const
ConnectionIterator externalConnectionEnd() const
void import(const string &fileName)
void importSubConf(istream &is)
int main(int argc, char **argv)
void checkSubconfigurationAccuracy(const TopologyMap &topology, const SubConfiguration &subConfiguration, const set< Event > &events, string &information, bool &result, set< set< Event > > &minimalCombinations, int depth, ofstream &toLatex)