Browse Source

Small formatting changes

Former-commit-id: 08eb57a9b0
tempestpy_adaptions
Mavo 9 years ago
parent
commit
4bd59b8649
  1. 38
      src/parser/DFTGalileoParser.cpp
  2. 4
      src/parser/DFTGalileoParser.h
  3. 2
      src/storage/dft/DFT.cpp
  4. 4
      src/storage/dft/DFT.h
  5. 29
      src/storage/dft/DFTBuilder.cpp
  6. 4
      src/storage/dft/DFTBuilder.h
  7. 2
      src/storage/dft/DFTUnit.h
  8. 12
      src/storm-dyftee.cpp

38
src/parser/DFTGalileoParser.cpp

@ -24,6 +24,9 @@ namespace storm {
if(firstQuots == std::string::npos) {
return name;
} else if (secondQuots ==std::string::npos) {
std::cerr << "No ending quotation mark found in " << name <<std::endl;
throw storm::exceptions::FileIoException();
} else {
return name.substr(firstQuots+1,secondQuots-1);
}
@ -32,11 +35,8 @@ namespace storm {
bool DFTGalileoParser::readFile(const std::string& filename) {
// constants
std::string topleveltoken = "toplevel";
std::string toplevelId;
std::ifstream file;
file.exceptions ( std::ifstream::failbit );
try {
@ -48,19 +48,25 @@ namespace storm {
}
file.exceptions( 0 );
std::string line;
bool generalSuccess = true;
while(std::getline(file, line))
{
bool success = true;
std::cout << line << std::endl;
size_t commentstarts = line.find("//");
line = line.substr(0, commentstarts);
size_t firstsemicolon = line.find(";");
line = line.substr(0, firstsemicolon);
if (line.find_first_not_of(' ') == std::string::npos)
{
// Only whitespace
continue;
}
// Top level indicator.
if(boost::starts_with(line, topleveltoken)) {
toplevelId = stripQuotsFromName(line.substr(topleveltoken.size()+1));
toplevelId = stripQuotsFromName(line.substr(topleveltoken.size() + 1));
}
else
{
@ -73,30 +79,32 @@ namespace storm {
childNames.push_back(stripQuotsFromName(tokens[i]));
}
if(tokens[1] == "and") {
mBuilder.addAndElement(name, childNames);
success = mBuilder.addAndElement(name, childNames);
} else if(tokens[1] == "or") {
mBuilder.addOrElement(name, childNames);
success = mBuilder.addOrElement(name, childNames);
} else if(boost::starts_with(tokens[1], "vot")) {
mBuilder.addVotElement(name, boost::lexical_cast<unsigned>(tokens[1].substr(3)), childNames);
success = mBuilder.addVotElement(name, boost::lexical_cast<unsigned>(tokens[1].substr(3)), childNames);
} else if(tokens[1] == "pand") {
mBuilder.addPandElement(name, childNames);
success = mBuilder.addPandElement(name, childNames);
} else if(tokens[1] == "wsp" || tokens[1] == "csp") {
mBuilder.addSpareElement(name, childNames);
success = mBuilder.addSpareElement(name, childNames);
} else if(boost::starts_with(tokens[1], "lambda=")) {
mBuilder.addBasicElement(name, boost::lexical_cast<double>(tokens[1].substr(7)), boost::lexical_cast<double>(tokens[2].substr(5)));
success = mBuilder.addBasicElement(name, boost::lexical_cast<double>(tokens[1].substr(7)), boost::lexical_cast<double>(tokens[2].substr(5)));
} else {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Type name: " + tokens[1] + " not recognized.");
success = false;
}
}
if (generalSuccess) {
generalSuccess = success;
}
}
if(!mBuilder.setTopLevel(toplevelId)) {
STORM_LOG_THROW(false, storm::exceptions::FileIoException, "Top level id unknown.");
}
file.close();
return true;
return generalSuccess;
}
}
}

4
src/parser/DFTGalileoParser.h

@ -6,8 +6,6 @@
#include <map>
namespace storm {
namespace parser {
class DFTGalileoParser {
@ -23,7 +21,5 @@ namespace storm {
}
}
#endif /* DFTGALILEOPARSER_H */

2
src/storage/dft/DFT.cpp

@ -75,7 +75,7 @@ namespace storm {
}
void DFT::printSpareModules(std::ostream& os) const {
std::cout << "[" << mElements[mTopLevelIndex] << "] {";
std::cout << "[" << mElements[mTopLevelIndex]->id() << "] {";
std::vector<size_t>::const_iterator it = mTopModule.begin();
assert(it != mTopModule.end());
os << mElements[(*it)]->name();

4
src/storage/dft/DFT.h

@ -16,7 +16,6 @@
namespace storm {
namespace storage {
struct DFTElementSort {
bool operator()(std::shared_ptr<DFTElement> const& a, std::shared_ptr<DFTElement> const& b) const {
if (a->rank() == 0 && b->rank() == 0) {
@ -29,8 +28,6 @@ namespace storm {
class DFT {
private:
std::vector<std::shared_ptr<DFTElement>> mElements;
size_t mNrOfBEs;
@ -44,7 +41,6 @@ namespace storm {
std::vector<size_t> mIdToFailureIndex;
std::map<size_t, size_t> mUsageIndex;
public:
DFT(std::vector<std::shared_ptr<DFTElement>> const& elements, std::shared_ptr<DFTElement> const& tle);

29
src/storage/dft/DFTBuilder.cpp

@ -10,7 +10,6 @@
namespace storm {
namespace storage {
DFT DFTBuilder::build() {
for(auto& elem : mChildNames) {
@ -23,8 +22,6 @@ namespace storm {
// Sort elements topologically
// compute rank
for (auto& elem : mElements) {
computeRank(elem.second);
@ -48,23 +45,22 @@ namespace storm {
if(elem->rank() == -1) {
if(elem->nrChildren() == 0) {
elem->setRank(0);
return 0;
}
std::shared_ptr<DFTGate> gate = std::static_pointer_cast<DFTGate>(elem);
unsigned maxrnk = 0;
unsigned newrnk = 0;
} else {
std::shared_ptr<DFTGate> gate = std::static_pointer_cast<DFTGate>(elem);
unsigned maxrnk = 0;
unsigned newrnk = 0;
for(std::shared_ptr<DFTElement> const& child : gate->children()) {
newrnk = computeRank(child);
if(newrnk > maxrnk) {
maxrnk = newrnk;
for (std::shared_ptr<DFTElement> const &child : gate->children()) {
newrnk = computeRank(child);
if (newrnk > maxrnk) {
maxrnk = newrnk;
}
}
elem->setRank(maxrnk + 1);
}
elem->setRank(maxrnk+1);
return maxrnk + 1;
} else {
return elem->rank();
}
return elem->rank();
}
bool DFTBuilder::addStandardGate(std::string const& name, std::vector<std::string> const& children, DFTElementTypes tp) {
@ -109,7 +105,6 @@ namespace storm {
}
visited[n] = topoSortColour::BLACK;
L.push_back(n);
}
}

4
src/storage/dft/DFTBuilder.h

@ -43,8 +43,6 @@ namespace storm {
return addStandardGate(name, children, DFTElementTypes::SPARE);
}
bool addVotElement(std::string const& name, unsigned threshold, std::vector<std::string> const& children) {
assert(children.size() > 0);
if(mElements.count(name) != 0) {
@ -103,8 +101,8 @@ namespace storm {
enum class topoSortColour {WHITE, BLACK, GREY};
void topoVisit(std::shared_ptr<DFTElement> const& n, std::map<std::shared_ptr<DFTElement>, topoSortColour>& visited, std::vector<std::shared_ptr<DFTElement>>& L);
std::vector<std::shared_ptr<DFTElement>> topoSort();
std::vector<std::shared_ptr<DFTElement>> topoSort();
};
}

2
src/storage/dft/DFTUnit.h

@ -1,6 +1,8 @@
#ifndef DFTUNIT_H
#define DFTUNIT_H
#include "../BitVector.h"
namespace storm {
namespace storage {
class DFT;

12
src/storm-dyftee.cpp

@ -11,12 +11,22 @@ int main(int argc, char** argv) {
std::cout << "Storm-DyFTeE should be called with a filename as argument." << std::endl;
}
storm::utility::setUp();
std::cout << "Parsing DFT file..." << std::endl;
storm::parser::DFTGalileoParser parser;
storm::storage::DFT dft = parser.parseDFT(argv[1]);
std::cout << "Built data structure" << std::endl;
dft.printElements();
dft.printSpareModules();
std::cout << "Building CTMC..." << std::endl;
storm::builder::ExplicitDFTModelBuilder builder(dft);
builder.buildCtmc();
std::cout << "Built CTMC" << std::endl;
//std::cout << "Model checking..." << std::endl;
//TODO check CTMC
//std::cout << "Checked model" << std::endl;
}
Loading…
Cancel
Save