Browse Source

Refactored everything to match naming scheme.

tempestpy_adaptions
PBerger 12 years ago
parent
commit
cce8391e44
  1. 33
      src/exceptions/FileIoException.h
  2. 18
      src/exceptions/InvalidArgumentException.h
  3. 18
      src/exceptions/InvalidStateException.h
  4. 18
      src/exceptions/OutOfRangeException.h
  5. 35
      src/exceptions/WrongFileFormatException.h
  6. 33
      src/exceptions/file_IO_exception.h
  7. 35
      src/exceptions/wrong_file_format.h
  8. 2
      src/formula/ProbabilisticIntervalOperator.h
  9. 4
      src/modelChecker/EigenDtmcPrctlModelChecker.h
  10. 4
      src/modelChecker/GmmxxDtmcPrctlModelChecker.h
  11. 13
      src/models/AtomicPropositionsLabeling.h
  12. 4
      src/mrmc.cpp
  13. 22
      src/parser/parser.cpp
  14. 6
      src/parser/parser.h
  15. 8
      src/parser/readLabFile.cpp
  16. 8
      src/parser/readTraFile.cpp
  17. 10
      src/solver/GraphAnalyzer.h
  18. 14
      src/storage/BitVector.h
  19. 38
      src/storage/SquareSparseMatrix.h
  20. 8
      src/utility/ConstTemplates.h
  21. 4
      src/utility/IoUtility.cpp
  22. 8
      src/utility/IoUtility.h
  23. 0
      src/utility/OsDetection.h
  24. 4
      src/utility/Settings.cpp
  25. 8
      src/utility/Settings.h
  26. 8
      src/utility/Vector.h
  27. 2
      test/eigen/sparse_matrix_test.cpp
  28. 2
      test/parser/parse_dtmc_test.cpp
  29. 12
      test/parser/read_lab_file_test.cpp
  30. 14
      test/parser/read_tra_file_test.cpp
  31. 2
      test/reward/reward_model_test.cpp
  32. 2
      test/storage/BitVectorTest.cpp
  33. 17
      test/storage/SquareSparseMatrixTest.cpp

33
src/exceptions/FileIoException.h

@ -0,0 +1,33 @@
/*
* FileIoException.h
*
* Created on: 16.08.2012
* Author: Thomas Heinemann
*/
#ifndef MRMC_EXCEPTIONS_FILEIOEXCEPTION_H_
#define MRMC_EXCEPTIONS_FILEIOEXCEPTION_H_
namespace mrmc {
namespace exceptions {
class FileIoException : public std::exception {
public:
#ifdef _WIN32
FileIoException() : exception("::mrmc::FileIoException"){};
FileIoException(const char * const s): exception(s) {};
#else
FileIoException() {};
FileIoException(const char * const s): exception() {};
#endif
virtual const char* what() const throw(){
{ return "mrmc::FileIoException"; }
}
};
}
}
#endif /* MRMC_EXCEPTIONS_FILEIOEXCEPTION_H_ */

18
src/exceptions/invalid_argument.h → src/exceptions/InvalidArgumentException.h

@ -1,5 +1,5 @@
#ifndef MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_
#define MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_
#ifndef MRMC_EXCEPTIONS_INVALIDARGUMENTEXCEPTION_H_
#define MRMC_EXCEPTIONS_INVALIDARGUMENTEXCEPTION_H_
#include <exception>
@ -8,7 +8,7 @@ namespace mrmc {
namespace exceptions {
//!This exception is thrown when a parameter is invalid in this context
class invalid_argument : public std::exception
class InvalidArgumentException : public std::exception
{
public:
/* The Visual C++-Version of the exception class has constructors accepting
@ -18,17 +18,17 @@ class invalid_argument : public std::exception
* constructor is used under linux (which will ignore the parameter)
*/
#ifdef _WIN32
invalid_argument() : exception("::mrmc::invalid_argument"){}
invalid_argument(const char * const s): exception(s) {}
InvalidArgumentException() : exception("::mrmc::InvalidArgumentException"){}
InvalidArgumentException(const char * const s): exception(s) {}
#else
invalid_argument() : exception() {}
invalid_argument(const char * const s): exception() {}
InvalidArgumentException() : exception() {}
InvalidArgumentException(const char * const s): exception() {}
#endif
virtual const char* what() const throw()
{ return "mrmc::invalid_argument"; }
{ return "mrmc::InvalidArgumentException"; }
};
} // namespace exceptions
} // namespace mrmc
#endif // MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_
#endif // MRMC_EXCEPTIONS_INVALIDARGUMENTEXCEPTION_H_

18
src/exceptions/invalid_state.h → src/exceptions/InvalidStateException.h

@ -1,5 +1,5 @@
#ifndef MRMC_EXCEPTIONS_INVALID_STATE_H_
#define MRMC_EXCEPTIONS_INVALID_STATE_H_
#ifndef MRMC_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_
#define MRMC_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_
#include <exception>
@ -9,7 +9,7 @@ namespace exceptions {
//!This exception is thrown when a memory request can't be
//!fulfilled.
class invalid_state : public std::exception
class InvalidStateException : public std::exception
{
public:
/* The Visual C++-Version of the exception class has constructors accepting
@ -19,19 +19,19 @@ class invalid_state : public std::exception
* constructor is used under linux (which will ignore the parameter)
*/
#ifdef _WIN32
invalid_state() : exception("::mrmc::invalid_state"){}
invalid_state(const char * const s): exception(s) {}
InvalidStateException() : exception("::mrmc::InvalidStateException"){}
InvalidStateException(const char * const s): exception(s) {}
#else
invalid_state() : exception() {}
invalid_state(const char * const s): exception() {}
InvalidStateException() : exception() {}
InvalidStateException(const char * const s): exception() {}
#endif
virtual const char* what() const throw()
{ return "mrmc::invalid_state"; }
{ return "mrmc::InvalidStateException"; }
};
} // namespace exceptions
} // namespace mrmc
#endif // MRMC_EXCEPTIONS_INVALID_STATE_H_
#endif // MRMC_EXCEPTIONS_INVALIDSTATEEXCEPTION_H_

18
src/exceptions/out_of_range.h → src/exceptions/OutOfRangeException.h

@ -1,5 +1,5 @@
#ifndef MRMC_EXCEPTIONS_OUT_OF_RANGE_H_
#define MRMC_EXCEPTIONS_OUT_OF_RANGE_H_
#ifndef MRMC_EXCEPTIONS_OUTOFRANGEEXCEPTION_H_
#define MRMC_EXCEPTIONS_OUTOFRANGEEXCEPTION_H_
#include <exception>
@ -8,7 +8,7 @@ namespace mrmc {
namespace exceptions {
//!This exception is thrown when a parameter is not in the range of valid values
class out_of_range : public std::exception
class OutOfRangeException : public std::exception
{
public:
/* The Visual C++-Version of the exception class has constructors accepting
@ -18,17 +18,17 @@ class out_of_range : public std::exception
* constructor is used under linux (which will ignore the parameter)
*/
#ifdef _WIN32
out_of_range() : exception("::mrmc::out_of_range"){}
out_of_range(const char * const s): exception(s) {}
OutOfRangeException() : exception("::mrmc::OutOfRangeException"){}
OutOfRangeException(const char * const s): exception(s) {}
#else
out_of_range() : exception() {}
out_of_range(const char * const s): exception() {}
OutOfRangeException() : exception() {}
OutOfRangeException(const char * const s): exception() {}
#endif
virtual const char* what() const throw()
{ return "mrmc::out_of_range"; }
{ return "mrmc::OutOfRangeException"; }
};
} // namespace exceptions
} // namespace mrmc
#endif // MRMC_EXCEPTIONS_OUT_OF_RANGE_H_
#endif // MRMC_EXCEPTIONS_OUTOFRANGEEXCEPTION_H_

35
src/exceptions/WrongFileFormatException.h

@ -0,0 +1,35 @@
/*
* WrongFileFormatException.h
*
* Created on: 16.08.2012
* Author: Thomas Heinemann
*/
#ifndef MRMC_EXCEPTIONS_WRONGFILEFORMAT_H_
#define MRMC_EXCEPTIONS_WRONGFILEFORMAT_H_
#include <exception>
namespace mrmc {
namespace exceptions {
class WrongFileFormatException : public std::exception {
public:
#ifdef _WIN32
WrongFileFormatException() : exception("::mrmc::WrongFileFormatException"){};
WrongFileFormatException(const char * const s): exception(s) {};
#else
WrongFileFormatException() {};
WrongFileFormatException(const char * const s): exception() {};
#endif
virtual const char* what() const throw(){
{ return "mrmc::WrongFileFormatException"; }
}
};
} //namespace exceptions
} //namespace mrmc
#endif /* MRMC_EXCEPTIONS_WRONGFILEFORMAT_H_ */

33
src/exceptions/file_IO_exception.h

@ -1,33 +0,0 @@
/*
* file_IO_exception.h
*
* Created on: 16.08.2012
* Author: Thomas Heinemann
*/
#ifndef MRMC_EXCEPTIONS_FILE_IO_EXCEPTION_H_
#define MRMC_EXCEPTIONS_FILE_IO_EXCEPTION_H_
namespace mrmc {
namespace exceptions {
class file_IO_exception : public std::exception {
public:
#ifdef _WIN32
file_IO_exception() : exception("::mrmc::file_IO_exception"){};
file_IO_exception(const char * const s): exception(s) {};
#else
file_IO_exception() {};
file_IO_exception(const char * const s): exception() {};
#endif
virtual const char* what() const throw(){
{ return "mrmc::file_IO_exception"; }
}
};
}
}
#endif /* MRMC_EXCEPTIONS_FILE_IO_EXCEPTION_H_ */

35
src/exceptions/wrong_file_format.h

@ -1,35 +0,0 @@
/*
* wrong_file_format.h
*
* Created on: 16.08.2012
* Author: Thomas Heinemann
*/
#ifndef WRONG_FILE_FORMAT_H_
#define WRONG_FILE_FORMAT_H_
#include <exception>
namespace mrmc {
namespace exceptions {
class wrong_file_format : public std::exception {
public:
#ifdef _WIN32
wrong_file_format() : exception("::mrmc::wrong_file_format"){};
wrong_file_format(const char * const s): exception(s) {};
#else
wrong_file_format() {};
wrong_file_format(const char * const s): exception() {};
#endif
virtual const char* what() const throw(){
{ return "mrmc::wrong_file_format"; }
}
};
} //namespace exceptions
} //namespace mrmc
#endif /* WRONG_FILE_FORMAT_H_ */

2
src/formula/ProbabilisticIntervalOperator.h

@ -10,7 +10,7 @@
#include "PCTLStateFormula.h"
#include "PCTLPathFormula.h"
#include "utility/const_templates.h"
#include "utility/ConstTemplates.h"
namespace mrmc {

4
src/modelChecker/EigenDtmcPrctlModelChecker.h

@ -8,12 +8,12 @@
#ifndef EIGENDTMCPRCTLMODELCHECKER_H_
#define EIGENDTMCPRCTLMODELCHECKER_H_
#include "src/utility/vector.h"
#include "src/utility/Vector.h"
#include "src/models/Dtmc.h"
#include "src/modelChecker/DtmcPrctlModelChecker.h"
#include "src/solver/GraphAnalyzer.h"
#include "src/utility/const_templates.h"
#include "src/utility/ConstTemplates.h"
#include "src/exceptions/NoConvergence.h"
#include "Eigen/Sparse"

4
src/modelChecker/GmmxxDtmcPrctlModelChecker.h

@ -13,9 +13,9 @@
#include "src/models/Dtmc.h"
#include "src/modelChecker/DtmcPrctlModelChecker.h"
#include "src/solver/GraphAnalyzer.h"
#include "src/utility/vector.h"
#include "src/utility/Vector.h"
#include "src/utility/settings.h"
#include "src/utility/Settings.h"
#include "gmm/gmm_matrix.h"
#include "gmm/gmm_iter_solvers.h"

13
src/models/AtomicPropositionsLabeling.h

@ -9,6 +9,7 @@
#define MRMC_MODELS_ATOMIC_PROPOSITIONS_LABELING_H_
#include "src/storage/BitVector.h"
#include "src/exceptions/OutOfRangeException.h"
#include <ostream>
#include <stdexcept>
#include <unordered_map>
@ -81,10 +82,10 @@ public:
*/
uint_fast64_t addAtomicProposition(std::string ap) {
if (nameToLabelingMap.count(ap) != 0) {
throw std::out_of_range("Atomic Proposition already exists.");
throw mrmc::exceptions::OutOfRangeException("Atomic Proposition already exists.");
}
if (apsCurrent >= apCountMax) {
throw std::out_of_range("Added more atomic propositions than"
throw mrmc::exceptions::OutOfRangeException("Added more atomic propositions than"
"previously declared.");
}
nameToLabelingMap[ap] = apsCurrent;
@ -109,10 +110,12 @@ public:
*/
void addAtomicPropositionToState(std::string ap, const uint_fast64_t state) {
if (nameToLabelingMap.count(ap) == 0) {
throw std::out_of_range("Atomic Proposition '" + ap + "' unknown.");
/*throw mrmc::exceptions::OutOfRangeException("Atomic Proposition '" << ap << "' unknown.");*/
// TODO !!!
throw mrmc::exceptions::OutOfRangeException("Atomic Proposition '' unknown.");
}
if (state >= stateCount) {
throw std::out_of_range("State index out of range.");
throw mrmc::exceptions::OutOfRangeException("State index out of range.");
}
this->singleLabelings[nameToLabelingMap[ap]]->set(state, true);
}
@ -124,7 +127,7 @@ public:
*/
std::set<std::string> getPropositionsForState(uint_fast64_t state) {
if (state >= stateCount) {
throw std::out_of_range("State index out of range.");
throw mrmc::exceptions::OutOfRangeException("State index out of range.");
}
std::set<std::string> result;
for (auto it = nameToLabelingMap.begin();

4
src/mrmc.cpp

@ -12,7 +12,7 @@
* Description: Central part of the application containing the main() Method
*/
#include "src/utility/osDetection.h"
#include "src/utility/OsDetection.h"
#include <iostream>
#include <cstdio>
#include <sstream>
@ -28,7 +28,7 @@
#include "src/parser/readTraFile.h"
#include "src/parser/readPrctlFile.h"
#include "src/solver/GraphAnalyzer.h"
#include "src/utility/settings.h"
#include "src/utility/Settings.h"
#include "src/formula/Formulas.h"
#include "src/exceptions/NoConvergence.h"

22
src/parser/parser.cpp

@ -12,8 +12,8 @@
#include <iostream>
#include <cstring>
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -22,7 +22,7 @@ extern log4cplus::Logger logger;
/*!
* Calls strtol() internally and checks if the new pointer is different
* from the original one, i.e. if str != *end. If they are the same, a
* mrmc::exceptions::wrong_file_format will be thrown.
* mrmc::exceptions::WrongFileFormatException will be thrown.
* @param str String to parse
* @param end New pointer will be written there
* @return Result of strtol()
@ -34,7 +34,7 @@ uint_fast64_t mrmc::parser::Parser::checked_strtol(const char* str, char** end)
{
LOG4CPLUS_ERROR(logger, "Error while parsing integer. Next input token is not a number.");
LOG4CPLUS_ERROR(logger, "\tUpcoming input is: \"" << std::string(str, 0, 16) << "\"");
throw mrmc::exceptions::wrong_file_format();
throw mrmc::exceptions::WrongFileFormatException("Error while parsing integer. Next input token is not a number.");
}
return res;
}
@ -71,14 +71,14 @@ mrmc::parser::MappedFile::MappedFile(const char* filename)
#endif
{
LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in stat()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in stat()");
}
this->file = open(filename, O_RDONLY);
if (this->file < 0)
{
LOG4CPLUS_ERROR(logger, "Error in open(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in open()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in open()");
}
this->data = (char*) mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE, this->file, 0);
@ -86,7 +86,7 @@ mrmc::parser::MappedFile::MappedFile(const char* filename)
{
close(this->file);
LOG4CPLUS_ERROR(logger, "Error in mmap(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in mmap()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in mmap()");
}
this->dataend = this->data + this->st.st_size;
#elif defined WINDOWS
@ -97,14 +97,14 @@ mrmc::parser::MappedFile::MappedFile(const char* filename)
if (_stat64(filename, &(this->st)) != 0)
{
LOG4CPLUS_ERROR(logger, "Error in _stat(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in stat()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in stat()");
}
this->file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (this->file == INVALID_HANDLE_VALUE)
{
LOG4CPLUS_ERROR(logger, "Error in CreateFileA(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in CreateFileA()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in CreateFileA()");
}
this->mapping = CreateFileMappingA(this->file, NULL, PAGE_READONLY, (DWORD)(st.st_size >> 32), (DWORD)st.st_size, NULL);
@ -112,7 +112,7 @@ mrmc::parser::MappedFile::MappedFile(const char* filename)
{
CloseHandle(this->file);
LOG4CPLUS_ERROR(logger, "Error in CreateFileMappingA(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in CreateFileMappingA()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in CreateFileMappingA()");
}
this->data = static_cast<char*>(MapViewOfFile(this->mapping, FILE_MAP_READ, 0, 0, this->st.st_size));
@ -121,7 +121,7 @@ mrmc::parser::MappedFile::MappedFile(const char* filename)
CloseHandle(this->mapping);
CloseHandle(this->file);
LOG4CPLUS_ERROR(logger, "Error in MapViewOfFile(" << filename << ").");
throw exceptions::file_IO_exception("mrmc::parser::MappedFile Error in MapViewOfFile()");
throw exceptions::FileIoException("mrmc::parser::MappedFile Error in MapViewOfFile()");
}
this->dataend = this->data + this->st.st_size;
#endif

6
src/parser/parser.h

@ -8,7 +8,7 @@
#ifndef PARSER_H_
#define PARSER_H_
#include "src/utility/osDetection.h"
#include "src/utility/OsDetection.h"
#if defined LINUX || defined MACOSX
# include <sys/mman.h>
@ -23,8 +23,8 @@
#include <iostream>
#include <boost/integer/integer_mask.hpp>
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
namespace mrmc {

8
src/parser/readLabFile.cpp

@ -9,8 +9,8 @@
#include "readLabFile.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/WrongFileFormatException.h"
#include "src/exceptions/FileIoException.h"
#include <cstdlib>
#include <cstdio>
@ -103,7 +103,7 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename)
LOG4CPLUS_ERROR(logger, "Wrong file format in (" << filename << "). File header is corrupted.");
if (! foundDecl) LOG4CPLUS_ERROR(logger, "\tDid not find #DECLARATION token.");
if (! foundEnd) LOG4CPLUS_ERROR(logger, "\tDid not find #END token.");
throw mrmc::exceptions::wrong_file_format();
throw mrmc::exceptions::WrongFileFormatException();
}
}
@ -135,7 +135,7 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename)
* if token is longer than our buffer, the following strncpy code might get risky...
*/
LOG4CPLUS_ERROR(logger, "Wrong file format in (" << filename << "). Atomic proposition with length > " << (sizeof(proposition)-1) << " was found.");
throw mrmc::exceptions::wrong_file_format();
throw mrmc::exceptions::WrongFileFormatException();
}
else if (cnt > 0)
{

8
src/parser/readTraFile.cpp

@ -8,8 +8,8 @@
#include "parser.h"
#include "src/parser/readTraFile.h"
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
#include "boost/integer/integer_mask.hpp"
#include <cstdlib>
#include <cstdio>
@ -142,7 +142,7 @@ TraParser::TraParser(const char * filename)
if (non_zero == 0)
{
LOG4CPLUS_ERROR(logger, "Error while parsing " << filename << ": erroneous file format.");
throw mrmc::exceptions::wrong_file_format();
throw mrmc::exceptions::WrongFileFormatException();
}
/*
@ -195,7 +195,7 @@ TraParser::TraParser(const char * filename)
if ((val <= 0.0) || (val > 1.0))
{
LOG4CPLUS_ERROR(logger, "Found transition probability of " << val << ", but we think probabilities should be from (0,1].");
throw mrmc::exceptions::wrong_file_format();
throw mrmc::exceptions::WrongFileFormatException();
}
this->matrix->addNextValue(row,col,val);
buf = skipWS(buf);

10
src/solver/GraphAnalyzer.h

@ -9,7 +9,7 @@
#define GRAPHANALYZER_H_
#include "src/models/Dtmc.h"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -38,7 +38,7 @@ public:
// Check for valid parameter.
if (existsPhiUntilPsiStates == nullptr) {
LOG4CPLUS_ERROR(logger, "Parameter 'existsPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::invalid_argument("Parameter 'existsPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::InvalidArgumentException("Parameter 'existsPhiUntilPhiStates' must not be null.");
}
// Get the backwards transition relation from the model to ease the search.
@ -85,7 +85,7 @@ public:
// Check for valid parameter.
if (alwaysPhiUntilPsiStates == nullptr) {
LOG4CPLUS_ERROR(logger, "Parameter 'alwaysPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::invalid_argument("Parameter 'alwaysPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::InvalidArgumentException("Parameter 'alwaysPhiUntilPhiStates' must not be null.");
}
GraphAnalyzer::getExistsPhiUntilPsiStates(model, ~psiStates, ~existsPhiUntilPsiStates, alwaysPhiUntilPsiStates);
@ -109,11 +109,11 @@ public:
// Check for valid parameters.
if (existsPhiUntilPsiStates == nullptr) {
LOG4CPLUS_ERROR(logger, "Parameter 'existsPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::invalid_argument("Parameter 'existsPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::InvalidArgumentException("Parameter 'existsPhiUntilPhiStates' must not be null.");
}
if (alwaysPhiUntilPsiStates == nullptr) {
LOG4CPLUS_ERROR(logger, "Parameter 'alwaysPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::invalid_argument("Parameter 'alwaysPhiUntilPhiStates' must not be null.");
throw mrmc::exceptions::InvalidArgumentException("Parameter 'alwaysPhiUntilPhiStates' must not be null.");
}
// Perform search.

14
src/storage/BitVector.h

@ -6,11 +6,11 @@
#include <cmath>
#include "boost/integer/integer_mask.hpp"
#include "src/exceptions/invalid_state.h"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/out_of_range.h"
#include "src/exceptions/InvalidStateException.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/OutOfRangeException.h"
#include "src/utility/osDetection.h"
#include "src/utility/OsDetection.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -102,7 +102,7 @@ public:
// Check whether the given length is valid.
if (length == 0) {
LOG4CPLUS_ERROR(logger, "Trying to create bit vector of size 0.");
throw mrmc::exceptions::invalid_argument("Trying to create a bit vector of size 0.");
throw mrmc::exceptions::InvalidArgumentException("Trying to create a bit vector of size 0.");
}
// Compute the correct number of buckets needed to store the given number of bits
@ -205,7 +205,7 @@ public:
*/
void set(const uint_fast64_t index, const bool value) {
uint_fast64_t bucket = index >> 6;
if (bucket >= this->bucketCount) throw mrmc::exceptions::out_of_range();
if (bucket >= this->bucketCount) throw mrmc::exceptions::OutOfRangeException();
uint_fast64_t mask = static_cast<uint_fast64_t>(1) << (index & mod64mask);
if (value) {
this->bucketArray[bucket] |= mask;
@ -223,7 +223,7 @@ public:
*/
bool get(const uint_fast64_t index) const {
uint_fast64_t bucket = index >> 6;
if (bucket >= this->bucketCount) throw mrmc::exceptions::out_of_range();
if (bucket >= this->bucketCount) throw mrmc::exceptions::OutOfRangeException();
uint_fast64_t mask = static_cast<uint_fast64_t>(1) << (index & mod64mask);
return ((this->bucketArray[bucket] & mask) == mask);
}

38
src/storage/SquareSparseMatrix.h

@ -7,14 +7,14 @@
#include <iostream>
#include "boost/integer/integer_mask.hpp"
#include "src/exceptions/invalid_state.h"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/out_of_range.h"
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/InvalidStateException.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/OutOfRangeException.h"
#include "src/exceptions/FileIoException.h"
#include "src/storage/BitVector.h"
#include "src/storage/JacobiDecomposition.h"
#include "src/utility/const_templates.h"
#include "src/utility/ConstTemplates.h"
#include "Eigen/Sparse"
#include "gmm/gmm_matrix.h"
@ -78,7 +78,7 @@ public:
// Check whether copying the matrix is safe.
if (!ssm.hasError()) {
LOG4CPLUS_ERROR(logger, "Trying to copy sparse matrix in error state.");
throw mrmc::exceptions::invalid_argument("Trying to copy sparse matrix in error state.");
throw mrmc::exceptions::InvalidArgumentException("Trying to copy sparse matrix in error state.");
} else {
// Try to prepare the internal storage and throw an error in case
// of a failure.
@ -142,15 +142,15 @@ public:
if (internalStatus != MatrixStatus::UnInitialized) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to initialize matrix that is not uninitialized.");
throw mrmc::exceptions::invalid_state("Trying to initialize matrix that is not uninitialized.");
throw mrmc::exceptions::InvalidStateException("Trying to initialize matrix that is not uninitialized.");
} else if (rowCount == 0) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to create initialize a matrix with 0 rows.");
throw mrmc::exceptions::invalid_argument("Trying to create initialize a matrix with 0 rows.");
throw mrmc::exceptions::InvalidArgumentException("Trying to create initialize a matrix with 0 rows.");
} else if (((rowCount * rowCount) - rowCount) < nonZeroEntries) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to initialize a matrix with more non-zero entries than there can be.");
throw mrmc::exceptions::invalid_argument("Trying to initialize a matrix with more non-zero entries than there can be.");
throw mrmc::exceptions::InvalidArgumentException("Trying to initialize a matrix with more non-zero entries than there can be.");
} else {
// If it is safe, initialize necessary members and prepare the
// internal storage.
@ -181,7 +181,7 @@ public:
if (!eigenSparseMatrix.isCompressed()) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to initialize from an Eigen matrix that is not in compressed form.");
throw mrmc::exceptions::invalid_argument("Trying to initialize from an Eigen matrix that is not in compressed form.");
throw mrmc::exceptions::InvalidArgumentException("Trying to initialize from an Eigen matrix that is not in compressed form.");
}
// Compute the actual (i.e. non-diagonal) number of non-zero entries.
@ -274,7 +274,7 @@ public:
if ((row > rowCount) || (col > rowCount)) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to add a value at illegal position (" << row << ", " << col << ").");
throw mrmc::exceptions::out_of_range("Trying to add a value at illegal position.");
throw mrmc::exceptions::OutOfRangeException("Trying to add a value at illegal position.");
}
if (row == col) { // Set a diagonal element.
@ -307,11 +307,11 @@ public:
if (!isInitialized()) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to finalize an uninitialized matrix.");
throw mrmc::exceptions::invalid_state("Trying to finalize an uninitialized matrix.");
throw mrmc::exceptions::InvalidStateException("Trying to finalize an uninitialized matrix.");
} else if (currentSize != nonZeroEntryCount) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to finalize a matrix that was initialized with more non-zero entries than given.");
throw mrmc::exceptions::invalid_state("Trying to finalize a matrix that was initialized with more non-zero entries than given.");
throw mrmc::exceptions::InvalidStateException("Trying to finalize a matrix that was initialized with more non-zero entries than given.");
} else {
// Fill in the missing entries in the row_indications array.
// (Can happen because of empty rows at the end.)
@ -345,7 +345,7 @@ public:
// Check for illegal access indices.
if ((row > rowCount) || (col > rowCount)) {
LOG4CPLUS_ERROR(logger, "Trying to read a value from illegal position (" << row << ", " << col << ").");
throw mrmc::exceptions::out_of_range("Trying to read a value from illegal position.");
throw mrmc::exceptions::OutOfRangeException("Trying to read a value from illegal position.");
return false;
}
@ -395,7 +395,7 @@ public:
// Check for illegal access indices.
if ((row > rowCount) || (col > rowCount)) {
LOG4CPLUS_ERROR(logger, "Trying to read a value from illegal position (" << row << ", " << col << ").");
throw mrmc::exceptions::out_of_range("Trying to read a value from illegal position.");
throw mrmc::exceptions::OutOfRangeException("Trying to read a value from illegal position.");
return false;
}
@ -423,7 +423,7 @@ public:
++rowStart;
}
throw mrmc::exceptions::invalid_argument("Trying to get a reference to a non-existant value.");
throw mrmc::exceptions::InvalidArgumentException("Trying to get a reference to a non-existant value.");
}
/*!
@ -515,7 +515,7 @@ public:
if (!isReadReady()) {
triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to convert a matrix that is not in a readable state to an Eigen matrix.");
throw mrmc::exceptions::invalid_state("Trying to convert a matrix that is not in a readable state to an Eigen matrix.");
throw mrmc::exceptions::InvalidStateException("Trying to convert a matrix that is not in a readable state to an Eigen matrix.");
} else {
// Create the resulting matrix.
int_fast32_t eigenRows = static_cast<int_fast32_t>(rowCount);
@ -733,7 +733,7 @@ public:
// Check whether the accessed state exists.
if (row > rowCount) {
LOG4CPLUS_ERROR(logger, "Trying to make an illegal row " << row << " absorbing.");
throw mrmc::exceptions::out_of_range("Trying to make an illegal row absorbing.");
throw mrmc::exceptions::OutOfRangeException("Trying to make an illegal row absorbing.");
return false;
}
@ -797,7 +797,7 @@ public:
// Check for valid constraint.
if (constraint.getNumberOfSetBits() == 0) {
LOG4CPLUS_ERROR(logger, "Trying to create a sub-matrix of size 0.");
throw mrmc::exceptions::invalid_argument("Trying to create a sub-matrix of size 0.");
throw mrmc::exceptions::InvalidArgumentException("Trying to create a sub-matrix of size 0.");
}
// First, we need to determine the number of non-zero entries of the

8
src/utility/const_templates.h → src/utility/ConstTemplates.h

@ -1,12 +1,12 @@
/*
* const_templates.h
* ConstTemplates.h
*
* Created on: 11.10.2012
* Author: Thomas Heinemann
*/
#ifndef CONST_TEMPLATES_H_
#define CONST_TEMPLATES_H_
#ifndef MRMC_UTILITY_CONSTTEMPLATES_H_
#define MRMC_UTILITY_CONSTTEMPLATES_H_
namespace mrmc {
@ -93,4 +93,4 @@ inline double constGetOne(double&) {
} //namespace mrmc
#endif /* CONST_TEMPLATES_H_ */
#endif /* MRMC_UTILITY_CONSTTEMPLATES_H_ */

4
src/utility/ioUtility.cpp → src/utility/IoUtility.cpp

@ -1,11 +1,11 @@
/*
* ioUtility.cpp
* IoUtility.cpp
*
* Created on: 17.10.2012
* Author: Thomas Heinemann
*/
#include "src/utility/ioUtility.h"
#include "src/utility/IoUtility.h"
#include "src/parser/readTraFile.h"
#include "src/parser/readLabFile.h"

8
src/utility/ioUtility.h → src/utility/IoUtility.h

@ -1,12 +1,12 @@
/*
* ioUtility.h
* IoUtility.h
*
* Created on: 17.10.2012
* Author: Thomas Heinemann
*/
#ifndef UTILITY_H_
#define UTILITY_H_
#ifndef MRMC_UTILITY_IOUTILITY_H_
#define MRMC_UTILITY_IOUTILITY_H_
#include "src/models/Dtmc.h"
@ -42,4 +42,4 @@ mrmc::models::Dtmc<double>* parseDTMC(const char* tra_file, const char* lab_file
} //namespace mrmc
#endif /* UTILITY_H_ */
#endif /* MRMC_UTILITY_IOUTILITY_H_ */

0
src/utility/osDetection.h → src/utility/OsDetection.h

4
src/utility/settings.cpp → src/utility/Settings.cpp

@ -1,11 +1,11 @@
/*
* settings.cpp
* Settings.cpp
*
* Created on: 22.11.2012
* Author: Gereon Kremer
*/
#include "src/utility/settings.h"
#include "src/utility/Settings.h"
#include "src/exceptions/BaseException.h"

8
src/utility/settings.h → src/utility/Settings.h

@ -1,12 +1,12 @@
/*
* settings.h
* Settings.h
*
* Created on: 22.11.2012
* Author: Gereon Kremer
*/
#ifndef SETTINGS_H_
#define SETTINGS_H_
#ifndef MRMC_SETTINGS_SETTINGS_H_
#define MRMC_SETTINGS_SETTINGS_H_
#include <iostream>
#include <sstream>
@ -212,4 +212,4 @@ namespace settings {
} // namespace settings
} // namespace mrmc
#endif // SETTINGS_H_
#endif // MRMC_SETTINGS_SETTINGS_H_

8
src/utility/vector.h → src/utility/Vector.h

@ -1,12 +1,12 @@
/*
* vector.h
* Vector.h
*
* Created on: 06.12.2012
* Author: Christian Dehnert
*/
#ifndef VECTOR_H_
#define VECTOR_H_
#ifndef MRMC_UTILITY_VECTOR_H_
#define MRMC_UTILITY_VECTOR_H_
#include "Eigen/src/Core/Matrix.h"
@ -40,4 +40,4 @@ void setVectorValues(Eigen::Matrix<T, -1, 1, 0, -1, 1>* eigenVector, const mrmc:
} //namespace mrmc
#endif /* VECTOR_H_ */
#endif /* MRMC_UTILITY_VECTOR_H_ */

2
test/eigen/sparse_matrix_test.cpp

@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include "Eigen/Sparse"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "boost/integer/integer_mask.hpp"
TEST(EigenSparseMatrixTest, BasicReadWriteTest) {

2
test/parser/parse_dtmc_test.cpp

@ -8,7 +8,7 @@
#include "gtest/gtest.h"
#include "mrmc-config.h"
#include "src/utility/ioUtility.h"
#include "src/utility/IoUtility.h"
TEST(ParseDtmcTest, parseAndOutput) {
mrmc::models::Dtmc<double>* myDtmc;

12
test/parser/read_lab_file_test.cpp

@ -9,14 +9,14 @@
#include "mrmc-config.h"
#include "src/models/AtomicPropositionsLabeling.h"
#include "src/parser/readLabFile.h"
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
#include <memory>
TEST(ReadLabFileTest, NonExistingFileTest) {
//No matter what happens, please don't create a file with the name "nonExistingFile.not"! :-)
ASSERT_THROW(mrmc::parser::LabParser(0,MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::file_IO_exception);
ASSERT_THROW(mrmc::parser::LabParser(0,MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::FileIoException);
}
TEST(ReadLabFileTest, ParseTest) {
@ -86,14 +86,14 @@ TEST(ReadLabFileTest, ParseTest) {
}
TEST(ReadLabFileTest, WrongHeaderTest1) {
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_header1.lab"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_header1.lab"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadLabFileTest, WrongHeaderTest2) {
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_header2.lab"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_header2.lab"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadLabFileTest, WrongPropositionTest) {
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_proposition.lab"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::LabParser(3, MRMC_CPP_TESTS_BASE_PATH "/parser/lab_files/wrong_format_proposition.lab"), mrmc::exceptions::WrongFileFormatException);
}

14
test/parser/read_tra_file_test.cpp

@ -9,14 +9,14 @@
#include "mrmc-config.h"
#include "src/storage/SquareSparseMatrix.h"
#include "src/parser/readTraFile.h"
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
#include "src/utility/ioUtility.h"
#include "src/utility/IoUtility.h"
TEST(ReadTraFileTest, NonExistingFileTest) {
//No matter what happens, please don't create a file with the name "nonExistingFile.not"! :-)
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::file_IO_exception);
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::FileIoException);
}
/* The following test case is based on one of the original MRMC test cases
@ -69,13 +69,13 @@ TEST(ReadTraFileTest, ParseFileTest1) {
}
TEST(ReadTraFileTest, WrongFormatTestHeader1) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header1.tra"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header1.tra"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadTraFileTest, WrongFormatTestHeader2) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header2.tra"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header2.tra"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadTraFileTest, WrongFormatTestTransition) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_transition.tra"), mrmc::exceptions::wrong_file_format);
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_transition.tra"), mrmc::exceptions::WrongFileFormatException);
}

2
test/reward/reward_model_test.cpp

@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include "Eigen/Sparse"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "boost/integer/integer_mask.hpp"
#include <vector>

2
test/storage/BitVectorTest.cpp

@ -1,6 +1,6 @@
#include "gtest/gtest.h"
#include "src/storage/BitVector.h"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/InvalidArgumentException.h"
TEST(BitVectorTest, GetSetTest) {
mrmc::storage::BitVector *bv = NULL;

17
test/storage/SquareSparseMatrixTest.cpp

@ -1,12 +1,13 @@
#include "gtest/gtest.h"
#include "src/storage/SquareSparseMatrix.h"
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/OutOfRangeException.h"
TEST(SquareSparseMatrixTest, ZeroRowsTest) {
mrmc::storage::SquareSparseMatrix<int> *ssm = new mrmc::storage::SquareSparseMatrix<int>(0);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::UnInitialized);
ASSERT_THROW(ssm->initialize(50), mrmc::exceptions::invalid_argument);
ASSERT_THROW(ssm->initialize(50), mrmc::exceptions::InvalidArgumentException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
delete ssm;
@ -16,7 +17,7 @@ TEST(SquareSparseMatrixTest, TooManyEntriesTest) {
mrmc::storage::SquareSparseMatrix<int> *ssm = new mrmc::storage::SquareSparseMatrix<int>(2);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::UnInitialized);
ASSERT_THROW(ssm->initialize(10), mrmc::exceptions::invalid_argument);
ASSERT_THROW(ssm->initialize(10), mrmc::exceptions::InvalidArgumentException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
delete ssm;
@ -29,16 +30,16 @@ TEST(SquareSparseMatrixTest, addNextValueTest) {
ASSERT_NO_THROW(ssm->initialize(1));
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Initialized);
ASSERT_THROW(ssm->addNextValue(-1, 1, 1), mrmc::exceptions::out_of_range);
ASSERT_THROW(ssm->addNextValue(-1, 1, 1), mrmc::exceptions::OutOfRangeException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
ASSERT_THROW(ssm->addNextValue(1, -1, 1), mrmc::exceptions::out_of_range);
ASSERT_THROW(ssm->addNextValue(1, -1, 1), mrmc::exceptions::OutOfRangeException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
ASSERT_THROW(ssm->addNextValue(6, 1, 1), mrmc::exceptions::out_of_range);
ASSERT_THROW(ssm->addNextValue(6, 1, 1), mrmc::exceptions::OutOfRangeException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
ASSERT_THROW(ssm->addNextValue(1, 6, 1), mrmc::exceptions::out_of_range);
ASSERT_THROW(ssm->addNextValue(1, 6, 1), mrmc::exceptions::OutOfRangeException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
delete ssm;
@ -57,7 +58,7 @@ TEST(SquareSparseMatrixTest, finalizeTest) {
ASSERT_NO_THROW(ssm->addNextValue(1, 5, 1));
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Initialized);
ASSERT_THROW(ssm->finalize(), mrmc::exceptions::invalid_state);
ASSERT_THROW(ssm->finalize(), mrmc::exceptions::InvalidStateException);
ASSERT_EQ(ssm->getState(), mrmc::storage::SquareSparseMatrix<int>::MatrixStatus::Error);
delete ssm;

Loading…
Cancel
Save