Browse Source

Throw exceptions for all unsupported Galileo distributions

main
Matthias Volk 7 years ago
parent
commit
8d845fad95
  1. 49
      src/storm-dft/parser/DFTGalileoParser.cpp
  2. 19
      src/storm-dft/parser/DFTGalileoParser.h

49
src/storm-dft/parser/DFTGalileoParser.cpp

@ -11,7 +11,6 @@
#include "storm/exceptions/FileIoException.h"
#include "storm/exceptions/NotSupportedException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/parser/ValueParser.h"
#include "storm/utility/macros.h"
#include "storm/utility/file.h"
@ -145,10 +144,8 @@ namespace storm {
} else if (boost::starts_with(type, "pdep=")) {
ValueType probability = valueParser.parseValue(type.substr(5));
success = builder.addDepElement(name, childNames, probability);
} else if (boost::starts_with(type, "lambda=")) {
ValueType failureRate = valueParser.parseValue(type.substr(7));
ValueType dormancyFactor = valueParser.parseValue(tokens[2].substr(5));
success = builder.addBasicElement(name, failureRate, dormancyFactor, false); // TODO set transient BEs
} else if (type.find("=") != std::string::npos) {
success = parseBasicElement(tokens, builder, valueParser);
} else {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Type name: " << type << " in line " << lineNo << " not recognized.");
success = false;
@ -169,6 +166,48 @@ namespace storm {
return dft;
}
template<typename ValueType>
bool DFTGalileoParser<ValueType>::parseBasicElement(std::vector<std::string> const& tokens, storm::storage::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser) {
std::string name = parseName(tokens[0]);
// Default values
ValueType lambda = storm::utility::zero<ValueType>();
ValueType dormancyFactor = storm::utility::one<ValueType>();
bool exponential = false;
for (size_t i = 1; i < tokens.size(); ++i) {
std::string token = tokens[i];
if (boost::starts_with(token, "prob=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Constant distribution is not supported.");
} else if (boost::starts_with(token, "lambda=")) {
lambda = valueParser.parseValue(token.substr(7));
exponential = true;
} else if (boost::starts_with(token, "rate=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Weibull distribution is not supported.");
} else if (boost::starts_with(token, "shape=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Weibull distribution is not supported.");
} else if (boost::starts_with(token, "mean=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "LogNormal distribution is not supported.");
} else if (boost::starts_with(token, "stddev=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "LogNormal distribution is not supported.");
} else if (boost::starts_with(token, "cov=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Coverage is not supported.");
} else if (boost::starts_with(token, "res=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Restoration is not supported.");
} else if (boost::starts_with(token, "repl=")) {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Replication is not supported.");
} else if (boost::starts_with(token, "dorm=")) {
dormancyFactor = valueParser.parseValue(token.substr(5));
}
}
if (exponential) {
return builder.addBasicElement(name, lambda, dormancyFactor, false); // TODO set transient BEs
} else {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "No distribution for basic element defined.");
}
}
// Explicitly instantiate the class.
template class DFTGalileoParser<double>;
template class DFTGalileoParser<RationalFunction>;

19
src/storm-dft/parser/DFTGalileoParser.h

@ -8,6 +8,7 @@
#include "storm-dft/storage/dft/DFT.h"
#include "storm-dft/storage/dft/DFTBuilder.h"
#include "storm/parser/ValueParser.h"
namespace storm {
@ -32,7 +33,25 @@ namespace storm {
static storm::storage::DFT<ValueType> parseDFT(std::string const& filename, bool defaultInclusive = true, bool binaryDependencies = true);
private:
/*!
* Parse element name (strip quotation marks, etc.).
*
* @param name Element name.
*
* @return Name.
*/
static std::string parseName(std::string const& name);
/*!
* Parse basic element and add it to builder.
*
* @param tokens Tokens defining the basic element.
* @param builder DFTBuilder.
* @param valueParser ValueParser.
*
* @return True iff the parsing and creation was successful.
*/
static bool parseBasicElement(std::vector<std::string> const& tokens, storm::storage::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser);
};
}
}
Loading…
Cancel
Save