52 changed files with 560 additions and 362 deletions
-
2resources/3rdparty/CMakeLists.txt
-
4resources/3rdparty/include_cpptemplate.cmake
-
23src/storm-dft/modelchecker/dft/DFTASFChecker.cpp
-
17src/storm-dft/parser/DFTGalileoParser.cpp
-
14src/storm-dft/parser/DFTJsonParser.cpp
-
8src/storm-gspn-cli/storm-gspn.cpp
-
20src/storm-gspn/storm-gspn.h
-
11src/storm-pgcl-cli/storm-pgcl.cpp
-
9src/storm-pgcl/parser/PgclParser.cpp
-
5src/storm/abstraction/MenuGameAbstractor.cpp
-
16src/storm/cli/entrypoints.h
-
82src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.cpp
-
4src/storm/modelchecker/multiobjective/pcaa/SparseMaPcaaWeightVectorChecker.h
-
44src/storm/modelchecker/multiobjective/pcaa/SparsePcaaQuantitativeQuery.cpp
-
107src/storm/modelchecker/multiobjective/pcaa/SparsePcaaWeightVectorChecker.cpp
-
5src/storm/modelchecker/region/ParameterRegion.cpp
-
19src/storm/models/symbolic/Model.cpp
-
11src/storm/models/symbolic/Model.h
-
5src/storm/parser/AtomicPropositionLabelingParser.cpp
-
5src/storm/parser/DeterministicSparseTransitionParser.cpp
-
9src/storm/parser/FormulaParser.cpp
-
14src/storm/parser/JaniParser.cpp
-
18src/storm/parser/MappedFile.cpp
-
8src/storm/parser/MappedFile.h
-
5src/storm/parser/MarkovAutomatonSparseTransitionParser.cpp
-
5src/storm/parser/NondeterministicSparseTransitionParser.cpp
-
10src/storm/parser/PrismParser.cpp
-
5src/storm/parser/SparseChoiceLabelingParser.cpp
-
5src/storm/parser/SparseStateRewardParser.cpp
-
8src/storm/settings/SettingsManager.cpp
-
13src/storm/solver/SmtlibSmtSolver.cpp
-
77src/storm/storage/SparseMatrix.cpp
-
6src/storm/storage/dd/Odd.cpp
-
8src/storm/storage/expressions/BaseExpression.cpp
-
10src/storm/storage/expressions/BaseExpression.h
-
14src/storm/storage/expressions/BinaryNumericalFunctionExpression.cpp
-
29src/storm/storage/expressions/BinaryRelationExpression.cpp
-
13src/storm/storage/expressions/ToRationalNumberVisitor.cpp
-
9src/storm/storage/expressions/ToRationalNumberVisitor.h
-
15src/storm/storage/expressions/UnaryNumericalFunctionExpression.cpp
-
18src/storm/storage/jani/JSONExporter.cpp
-
2src/storm/storage/jani/Model.cpp
-
6src/storm/storage/jani/ParallelComposition.cpp
-
50src/storm/transformer/SymbolicToSparseTransformer.cpp
-
15src/storm/transformer/SymbolicToSparseTransformer.h
-
9src/storm/utility/cli.cpp
-
4src/storm/utility/constants.cpp
-
15src/storm/utility/export.h
-
81src/storm/utility/file.h
-
13src/storm/utility/storm.h
-
10src/test/builder/DdJaniModelBuilderTest.cpp
-
7src/test/parser/MappedFileTest.cpp
@ -0,0 +1,50 @@ |
|||
#include "SymbolicToSparseTransformer.h"
|
|||
|
|||
#include "storm/storage/dd/DdManager.h"
|
|||
#include "storm/storage/dd/Add.h"
|
|||
#include "storm/storage/dd/Bdd.h"
|
|||
#include "storm/models/symbolic/StandardRewardModel.h"
|
|||
|
|||
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
|
|||
namespace storm { |
|||
namespace transformer { |
|||
|
|||
template<storm::dd::DdType Type, typename ValueType> |
|||
std::shared_ptr<storm::models::sparse::Mdp<ValueType>> SymbolicMdpToSparseMdpTransformer<Type, ValueType>::translate( |
|||
storm::models::symbolic::Mdp<Type, ValueType> const& symbolicMdp) { |
|||
storm::dd::Odd odd = symbolicMdp.getReachableStates().createOdd(); |
|||
storm::storage::SparseMatrix<ValueType> transitionMatrix = symbolicMdp.getTransitionMatrix().toMatrix(symbolicMdp.getNondeterminismVariables(), odd, odd); |
|||
std::unordered_map<std::string, storm::models::sparse::StandardRewardModel<ValueType>> rewardModels; |
|||
for (auto const& rewardModelNameAndModel : symbolicMdp.getRewardModels()) { |
|||
boost::optional<std::vector<ValueType>> stateRewards; |
|||
boost::optional<std::vector<ValueType>> stateActionRewards; |
|||
boost::optional<storm::storage::SparseMatrix<ValueType>> transitionRewards; |
|||
if (rewardModelNameAndModel.second.hasStateRewards()) { |
|||
stateRewards = rewardModelNameAndModel.second.getStateRewardVector().toVector(odd); |
|||
} |
|||
if (rewardModelNameAndModel.second.hasStateActionRewards()) { |
|||
stateActionRewards = rewardModelNameAndModel.second.getStateActionRewardVector().toVector(odd); |
|||
} |
|||
if (rewardModelNameAndModel.second.hasTransitionRewards()) { |
|||
transitionRewards = rewardModelNameAndModel.second.getTransitionRewardMatrix().toMatrix(symbolicMdp.getNondeterminismVariables(), odd, odd); |
|||
} |
|||
rewardModels.emplace(rewardModelNameAndModel.first,storm::models::sparse::StandardRewardModel<ValueType>(stateRewards, stateActionRewards, transitionRewards)); |
|||
} |
|||
storm::models::sparse::StateLabeling labelling; |
|||
|
|||
labelling.addLabel("initial", symbolicMdp.getInitialStates().toVector(odd)); |
|||
labelling.addLabel("deadlock", symbolicMdp.getDeadlockStates().toVector(odd)); |
|||
for(auto const& label : symbolicMdp.getLabels()) { |
|||
labelling.addLabel(label, symbolicMdp.getStates(label).toVector(odd)); |
|||
} |
|||
return std::make_shared<storm::models::sparse::Mdp<ValueType>>(transitionMatrix, labelling, rewardModels); |
|||
|
|||
|
|||
} |
|||
|
|||
template class SymbolicMdpToSparseMdpTransformer<storm::dd::DdType::CUDD, double>; |
|||
template class SymbolicMdpToSparseMdpTransformer<storm::dd::DdType::Sylvan, double>; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/models/sparse/Mdp.h" |
|||
#include "storm/models/symbolic/Mdp.h" |
|||
|
|||
namespace storm { |
|||
namespace transformer { |
|||
|
|||
template<storm::dd::DdType Type, typename ValueType> |
|||
class SymbolicMdpToSparseMdpTransformer { |
|||
public: |
|||
static std::shared_ptr<storm::models::sparse::Mdp<ValueType>> translate(storm::models::symbolic::Mdp<Type, ValueType> const& symbolicMdp); |
|||
}; |
|||
} |
|||
} |
@ -0,0 +1,81 @@ |
|||
/** |
|||
* @file: file.h |
|||
* @author: Sebastian Junges |
|||
* |
|||
* @since October 7, 2014 |
|||
*/ |
|||
|
|||
#ifndef STORM_UTILITY_FILE_H_ |
|||
#define STORM_UTILITY_FILE_H_ |
|||
|
|||
#include <iostream> |
|||
|
|||
#include "storm/utility/macros.h" |
|||
#include "storm/exceptions/FileIoException.h" |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
/*! |
|||
* Open the given file for writing. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @param filestream Contains the file handler afterwards. |
|||
* @param append If true, the new content is appended instead of clearing the existing content. |
|||
*/ |
|||
inline void openFile(std::string const& filepath, std::ofstream& filestream, bool append = false) { |
|||
if (append) { |
|||
filestream.open(filepath, std::ios::app); |
|||
} else { |
|||
filestream.open(filepath); |
|||
} |
|||
STORM_LOG_THROW(filestream, storm::exceptions::FileIoException , "Could not open file " << filepath << "."); |
|||
STORM_PRINT_AND_LOG("Write to file " << filepath << "." << std::endl); |
|||
} |
|||
|
|||
/*! |
|||
* Open the given file for reading. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @param filestream Contains the file handler afterwards. |
|||
*/ |
|||
inline void openFile(std::string const& filepath, std::ifstream& filestream) { |
|||
filestream.open(filepath); |
|||
STORM_LOG_THROW(filestream, storm::exceptions::FileIoException , "Could not open file " << filepath << "."); |
|||
} |
|||
|
|||
/*! |
|||
* Close the given file after writing. |
|||
* |
|||
* @param filestream Contains the file handler to close. |
|||
*/ |
|||
inline void closeFile(std::ofstream& stream) { |
|||
stream.close(); |
|||
} |
|||
|
|||
/*! |
|||
* Close the given file after reading. |
|||
* |
|||
* @param filestream Contains the file handler to close. |
|||
*/ |
|||
inline void closeFile(std::ifstream& stream) { |
|||
stream.close(); |
|||
} |
|||
|
|||
/*! |
|||
* Tests whether the given file exists and is readable. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @return True iff the file exists and is readable. |
|||
*/ |
|||
inline bool fileExistsAndIsReadable(std::string const& filename) { |
|||
// Test by opening an input file stream and testing the stream flags. |
|||
std::ifstream filestream; |
|||
filestream.open(filename); |
|||
return filestream.good(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue