/* * IoUtility.cpp * * Created on: 17.10.2012 * Author: Thomas Heinemann */ #include "src/utility/IoUtility.h" #include #include "src/parser/DeterministicSparseTransitionParser.h" #include "src/parser/AtomicPropositionLabelingParser.h" namespace storm { namespace utility { void dtmcToDot(storm::models::Dtmc const &dtmc, std::string filename) { std::shared_ptr> matrix(dtmc.getTransitionProbabilityMatrix()); std::ofstream file; file.open(filename); file << "digraph dtmc {\n"; //Specify the nodes and their labels for (uint_fast64_t i = 1; i < dtmc.getNumberOfStates(); i++) { file << "\t" << i << "[label=\"" << i << "\\n{"; char komma=' '; std::set propositions = dtmc.getPropositionsForState(i); for(auto it = propositions.begin(); it != propositions.end(); it++) { file << komma << *it; komma=','; } file << " }\"];\n"; } for (uint_fast64_t row = 0; row < dtmc.getNumberOfStates(); row++ ) { //Then, iterate through the row and write each non-diagonal value into the file for ( auto it = matrix->beginConstColumnIterator(row); it != matrix->endConstColumnIterator(row); it++) { double value = 0; matrix->getValue(row,*it,&value); file << "\t" << row << " -> " << *it << " [label=" << value << "]\n"; } } file << "}\n"; file.close(); } //TODO: Should this stay here or be integrated in the new parser structure? /*storm::models::Dtmc* parseDTMC(std::string const &tra_file, std::string const &lab_file) { storm::parser::DeterministicSparseTransitionParser tp(tra_file); uint_fast64_t node_count = tp.getMatrix()->getRowCount(); storm::parser::AtomicPropositionLabelingParser lp(node_count, lab_file); storm::models::Dtmc* result = new storm::models::Dtmc(tp.getMatrix(), lp.getLabeling()); return result; }*/ } }