Browse Source
Merge branch 'master' of https://sselab.de/lab9/private/git/storm
Merge branch 'master' of https://sselab.de/lab9/private/git/storm
Former-commit-id: 31a498b9a5
main
50 changed files with 3126 additions and 2953 deletions
-
2CMakeLists.txt
-
4examples/mdp/tiny/tiny.clab
-
3src/models/sparse/Model.cpp
-
44src/parser/AutoParser.cpp
-
13src/parser/AutoParser.h
-
35src/parser/DeterministicModelParser.cpp
-
24src/parser/DeterministicModelParser.h
-
70src/parser/DeterministicSparseTransitionParser.cpp
-
15src/parser/DeterministicSparseTransitionParser.h
-
19src/parser/MarkovAutomatonParser.cpp
-
3src/parser/MarkovAutomatonParser.h
-
19src/parser/MarkovAutomatonSparseTransitionParser.cpp
-
5src/parser/MarkovAutomatonSparseTransitionParser.h
-
40src/parser/NondeterministicModelParser.cpp
-
23src/parser/NondeterministicModelParser.h
-
69src/parser/NondeterministicSparseTransitionParser.cpp
-
13src/parser/NondeterministicSparseTransitionParser.h
-
73src/parser/SparseChoiceLabelingParser.cpp
-
27src/parser/SparseChoiceLabelingParser.h
-
18src/parser/SparseStateRewardParser.cpp
-
3src/parser/SparseStateRewardParser.h
-
11src/settings/modules/GeneralSettings.cpp
-
21src/settings/modules/GeneralSettings.h
-
15src/storage/BitVector.cpp
-
8src/utility/storm.h
-
16test/functional/modelchecker/GmmxxDtmcPrctlModelCheckerTest.cpp
-
8test/functional/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
-
6test/functional/modelchecker/NativeDtmcPrctlModelCheckerTest.cpp
-
22test/functional/modelchecker/NativeMdpPrctlModelCheckerTest.cpp
-
14test/functional/modelchecker/SparseDtmcEliminationModelCheckerTest.cpp
-
8test/functional/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp
-
16test/functional/parser/AutoParserTest.cpp
-
25test/functional/parser/DeterministicModelParserTest.cpp
-
43test/functional/parser/DeterministicSparseTransitionParserTest.cpp
-
10test/functional/parser/MarkovAutomatonParserTest.cpp
-
16test/functional/parser/MarkovAutomatonSparseTransitionParserTest.cpp
-
17test/functional/parser/NondeterministicModelParserTest.cpp
-
39test/functional/parser/NondeterministicSparseTransitionParserTest.cpp
-
24test/functional/parser/SparseStateRewardParserTest.cpp
-
4test/functional/storage/DeterministicModelBisimulationDecompositionTest.cpp
-
6test/functional/storage/MaximalEndComponentDecompositionTest.cpp
-
4test/functional/storage/StronglyConnectedComponentDecompositionTest.cpp
-
8test/performance/graph/GraphTest.cpp
-
4test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp
-
4test/performance/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
-
4test/performance/modelchecker/NativeDtmcPrctlModelCheckerTest.cpp
-
4test/performance/modelchecker/NativeMdpPrctlModelCheckerTest.cpp
-
4test/performance/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp
-
4test/performance/storage/MaximalEndComponentDecompositionTest.cpp
-
8test/performance/storage/StronglyConnectedComponentDecompositionTest.cpp
@ -0,0 +1,4 @@ |
|||
0 0 3 |
|||
0 1 1 |
|||
1 0 2 |
|||
2 0 0 |
@ -0,0 +1,73 @@ |
|||
#include "src/parser/SparseChoiceLabelingParser.h"
|
|||
|
|||
#include "src/exceptions/WrongFormatException.h"
|
|||
#include "src/exceptions/OutOfRangeException.h"
|
|||
#include "src/exceptions/FileIoException.h"
|
|||
#include "src/parser/MappedFile.h"
|
|||
#include "src/utility/cstring.h"
|
|||
|
|||
namespace storm { |
|||
namespace parser { |
|||
|
|||
using namespace storm::utility::cstring; |
|||
|
|||
std::vector<storm::models::sparse::LabelSet> SparseChoiceLabelingParser::parseChoiceLabeling(std::vector<uint_fast64_t> const& nondeterministicChoiceIndices, std::string const& filename) { |
|||
// Open file.
|
|||
if (!MappedFile::fileExistsAndIsReadable(filename.c_str())) { |
|||
LOG4CPLUS_ERROR(logger, "Error while parsing " << filename << ": File does not exist or is not readable."); |
|||
throw storm::exceptions::FileIoException() << "Error while parsing " << filename << ": File does not exist or is not readable."; |
|||
} |
|||
|
|||
MappedFile file(filename.c_str()); |
|||
char const* buf = file.getData(); |
|||
|
|||
uint_fast64_t totalNumberOfChoices = nondeterministicChoiceIndices.back(); |
|||
|
|||
// Create choice labeling vector with given choice count.
|
|||
std::vector<storm::models::sparse::LabelSet> result(totalNumberOfChoices); |
|||
|
|||
// Now parse state reward assignments.
|
|||
uint_fast64_t state = 0; |
|||
uint_fast64_t lastState = (uint_fast64_t) - 1; |
|||
uint_fast64_t lastChoice = (uint_fast64_t) - 1; |
|||
uint_fast64_t const startIndexComparison = lastState; |
|||
uint_fast64_t const startChoiceIndexComparison = lastChoice; |
|||
uint_fast64_t choice = 0; |
|||
uint_fast64_t label = 0; |
|||
|
|||
// Iterate over states.
|
|||
while (buf[0] != '\0') { |
|||
|
|||
// Parse state number and choice.
|
|||
state = checked_strtol(buf, &buf); |
|||
choice = checked_strtol(buf, &buf); |
|||
|
|||
// If the state has already been read or skipped once there might be a problem with the file (doubled lines, or blocks).
|
|||
// Note: The value -1 shows that lastState has not yet been set, i.e. this is the first run of the loop (state index (2^64)-1 is a really bad starting index).
|
|||
if (state < lastState && lastState != startIndexComparison) { |
|||
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Error while parsing " << filename << ": State " << state << " was found but has already been read or skipped previously."); |
|||
} |
|||
if (state == lastState && choice < lastChoice && lastChoice != startChoiceIndexComparison) { |
|||
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Error while parsing " << filename << ": Choice " << choice << " was found but has already been read or skipped previously."); |
|||
} |
|||
if (state >= nondeterministicChoiceIndices.size()) { |
|||
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Error while parsing " << filename << ": Illegal state " << state << "."); |
|||
} |
|||
uint_fast64_t numberOfChoicesForState = nondeterministicChoiceIndices[state + 1] - nondeterministicChoiceIndices[state]; |
|||
if (choice >= numberOfChoicesForState) { |
|||
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Error while parsing " << filename << ": Choice " << choice << " is illegal for state " << state << ", because this state has fewer choices."); |
|||
} |
|||
|
|||
label = checked_strtol(buf, &buf); |
|||
|
|||
result[nondeterministicChoiceIndices[state] + choice].insert(label); |
|||
|
|||
buf = trimWhitespaces(buf); |
|||
lastState = state; |
|||
lastChoice = choice; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
#ifndef STORM_PARSER_SPARSECHOICELABELINGPARSER_H_ |
|||
#define STORM_PARSER_SPARSECHOICELABELINGPARSER_H_ |
|||
|
|||
#include "src/models/sparse/Model.h" |
|||
|
|||
namespace storm { |
|||
namespace parser { |
|||
/*! |
|||
* A class providing the functionality to parse a choice labeling. |
|||
*/ |
|||
class SparseChoiceLabelingParser { |
|||
public: |
|||
/*! |
|||
* Parses the given file and returns the resulting choice labeling. |
|||
* |
|||
* @param nondeterministicChoiceIndices The indices at which the choices |
|||
* of the states begin. |
|||
* @param filename The name of the file to parse. |
|||
* @return The resulting choice labeling. |
|||
*/ |
|||
static std::vector<storm::models::sparse::LabelSet> parseChoiceLabeling(std::vector<uint_fast64_t> const& nondeterministicChoiceIndices, std::string const& filename); |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_PARSER_SPARSECHOICELABELINGPARSER_H_ */ |
|||
|
Reference in new issue
xxxxxxxxxx