22 changed files with 1240 additions and 779 deletions
-
66src/storm-parsers/parser/PrismParser.cpp
-
24src/storm-parsers/parser/PrismParser.h
-
28src/storm/builder/ExplicitModelBuilder.cpp
-
2src/storm/builder/ExplicitModelBuilder.h
-
15src/storm/generator/Choice.cpp
-
22src/storm/generator/Choice.h
-
3src/storm/generator/NextStateGenerator.h
-
36src/storm/generator/PrismNextStateGenerator.cpp
-
4src/storm/generator/PrismNextStateGenerator.h
-
5src/storm/models/ModelType.cpp
-
2src/storm/models/ModelType.h
-
7src/storm/models/sparse/Model.cpp
-
49src/storm/models/sparse/Smg.cpp
-
57src/storm/models/sparse/Smg.h
-
1src/storm/storage/SymbolicModelDescription.cpp
-
2src/storm/storage/SymbolicModelDescription.h
-
37src/storm/storage/prism/Player.cpp
-
72src/storm/storage/prism/Player.h
-
36src/storm/storage/prism/Program.cpp
-
32src/storm/storage/prism/Program.h
-
14src/storm/storage/sparse/ModelComponents.h
-
3src/storm/utility/builder.cpp
@ -0,0 +1,49 @@ |
|||
#include "storm/models/sparse/Smg.h"
|
|||
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/vector.h"
|
|||
#include "storm/adapters/RationalFunctionAdapter.h"
|
|||
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
|
|||
namespace storm { |
|||
namespace models { |
|||
namespace sparse { |
|||
|
|||
template <typename ValueType, typename RewardModelType> |
|||
Smg<ValueType, RewardModelType>::Smg(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::models::sparse::StateLabeling const& stateLabeling, |
|||
std::unordered_map<std::string, RewardModelType> const& rewardModels, ModelType type) |
|||
: Smg<ValueType, RewardModelType>(storm::storage::sparse::ModelComponents<ValueType, RewardModelType>(transitionMatrix, stateLabeling, rewardModels), type) { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template <typename ValueType, typename RewardModelType> |
|||
Smg<ValueType, RewardModelType>::Smg(storm::storage::SparseMatrix<ValueType>&& transitionMatrix, storm::models::sparse::StateLabeling&& stateLabeling, |
|||
std::unordered_map<std::string, RewardModelType>&& rewardModels, ModelType type) |
|||
: Smg<ValueType, RewardModelType>(storm::storage::sparse::ModelComponents<ValueType, RewardModelType>(std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels)), type) { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template <typename ValueType, typename RewardModelType> |
|||
Smg<ValueType, RewardModelType>::Smg(storm::storage::sparse::ModelComponents<ValueType, RewardModelType> const& components, ModelType type) |
|||
: NondeterministicModel<ValueType, RewardModelType>(type, components) { |
|||
assert(type == storm::models::ModelType::Smg); |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template <typename ValueType, typename RewardModelType> |
|||
Smg<ValueType, RewardModelType>::Smg(storm::storage::sparse::ModelComponents<ValueType, RewardModelType>&& components, ModelType type) |
|||
: NondeterministicModel<ValueType, RewardModelType>(type, std::move(components)) { |
|||
assert(type == storm::models::ModelType::Smg); |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template class Smg<double>; |
|||
template class Smg<storm::RationalNumber>; |
|||
|
|||
template class Smg<double, storm::models::sparse::StandardRewardModel<storm::Interval>>; |
|||
template class Smg<storm::RationalFunction>; |
|||
} // namespace sparse
|
|||
} // namespace models
|
|||
} // namespace storm
|
@ -0,0 +1,57 @@ |
|||
#ifndef STORM_MODELS_SPARSE_SMG_H_ |
|||
#define STORM_MODELS_SPARSE_SMG_H_ |
|||
|
|||
#include "storm/models/sparse/NondeterministicModel.h" |
|||
|
|||
namespace storm { |
|||
namespace models { |
|||
namespace sparse { |
|||
|
|||
/*! |
|||
* This class represents a stochastic multiplayer game. |
|||
*/ |
|||
template<class ValueType, typename RewardModelType = StandardRewardModel<ValueType>> |
|||
class Smg : public NondeterministicModel<ValueType, RewardModelType> { |
|||
public: |
|||
/*! |
|||
* Constructs a model from the given data. |
|||
* |
|||
* @param transitionMatrix The matrix representing the transitions in the model. |
|||
* @param stateLabeling The labeling of the states. |
|||
* @param rewardModels A mapping of reward model names to reward models. |
|||
*/ |
|||
Smg(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, |
|||
storm::models::sparse::StateLabeling const& stateLabeling, |
|||
std::unordered_map<std::string, RewardModelType> const& rewardModels = std::unordered_map<std::string, RewardModelType>(), ModelType type = ModelType::Smg); |
|||
|
|||
/*! |
|||
* Constructs a model by moving the given data. |
|||
* |
|||
* @param transitionMatrix The matrix representing the transitions in the model. |
|||
* @param stateLabeling The labeling of the states. |
|||
* @param rewardModels A mapping of reward model names to reward models. |
|||
*/ |
|||
Smg(storm::storage::SparseMatrix<ValueType>&& transitionMatrix, |
|||
storm::models::sparse::StateLabeling&& stateLabeling, |
|||
std::unordered_map<std::string, RewardModelType>&& rewardModels = std::unordered_map<std::string, RewardModelType>(), ModelType type = ModelType::Smg); |
|||
|
|||
/*! |
|||
* Constructs a model from the given data. |
|||
* |
|||
* @param components The components for this model. |
|||
*/ |
|||
Smg(storm::storage::sparse::ModelComponents<ValueType, RewardModelType> const& components, ModelType type = ModelType::Smg); |
|||
Smg(storm::storage::sparse::ModelComponents<ValueType, RewardModelType>&& components, ModelType type = ModelType::Smg); |
|||
|
|||
Smg(Smg<ValueType, RewardModelType> const& other) = default; |
|||
Smg& operator=(Smg<ValueType, RewardModelType> const& other) = default; |
|||
|
|||
Smg(Smg<ValueType, RewardModelType>&& other) = default; |
|||
Smg& operator=(Smg<ValueType, RewardModelType>&& other) = default; |
|||
}; |
|||
|
|||
} // namespace sparse |
|||
} // namespace models |
|||
} // namespace storm |
|||
|
|||
#endif /* STORM_MODELS_SPARSE_SMG_H_ */ |
@ -0,0 +1,37 @@ |
|||
#include "storm/storage/prism/Player.h"
|
|||
|
|||
namespace storm { |
|||
namespace prism { |
|||
Player::Player(std::string const& playerName, std::map<std::string, uint_fast32_t> const& controlledModules, std::map<std::string, uint_fast32_t> const& controlledCommands, std::string const& filename, uint_fast32_t lineNumber) : LocatedInformation(filename, lineNumber), playerName(playerName), controlledModules(controlledModules), controlledCommands(controlledCommands) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::string const& Player::getName() const { |
|||
return this->playerName; |
|||
} |
|||
|
|||
std::map<std::string, uint_fast32_t> const& Player::getModules() const { |
|||
return this->controlledModules; |
|||
} |
|||
|
|||
std::map<std::string, uint_fast32_t> const& Player::getCommands() const { |
|||
return this->controlledCommands; |
|||
} |
|||
|
|||
std::ostream& operator<<(std::ostream& stream, Player const& player) { |
|||
stream << "player"; |
|||
if (player.getName() != "") { |
|||
stream << " " << player.getName(); |
|||
} |
|||
stream << std::endl; |
|||
for (auto const& module : player.getModules()) { |
|||
stream << "\t" << module.first << std::endl; |
|||
} |
|||
for (auto const& command : player.getCommands()) { |
|||
stream << "\t[" << command.first << "]" << std::endl; |
|||
} |
|||
stream << "endplayer" << std::endl; |
|||
return stream; |
|||
} |
|||
} // namespace prism
|
|||
} // namespace storm
|
@ -0,0 +1,72 @@ |
|||
#ifndef STORM_STORAGE_PRISM_PLAYER_H_ |
|||
#define STORM_STORAGE_PRISM_PLAYER_H_ |
|||
|
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include "storm/storage/prism/Module.h" |
|||
#include "storm/storage/prism/Command.h" |
|||
|
|||
// needed? |
|||
#include "storm/storage/BoostTypes.h" |
|||
#include "storm/utility/OsDetection.h" |
|||
|
|||
namespace storm { |
|||
namespace prism { |
|||
class Player : public LocatedInformation { |
|||
public: |
|||
/*! |
|||
* Creates a player with the given name, controlled modules and actions. |
|||
* |
|||
* @param playerName The name of the player. |
|||
* @param controlledModules The controlled modules. |
|||
* @param controlledCommands The controlled actions. |
|||
* @param filename The filename in which the player is defined. |
|||
* @param lineNumber The line number in which the player is defined. |
|||
*/ |
|||
Player(std::string const& playerName, std::map<std::string, uint_fast32_t> const& controlledModules, std::map<std::string, uint_fast32_t> const& controlledCommands, std::string const& filename = "", uint_fast32_t lineNumber = 0); |
|||
|
|||
// Create default implementations of constructors/assignment. |
|||
Player() = default; |
|||
Player(Player const& other) = default; |
|||
Player& operator=(Player const& other) = default; |
|||
Player(Player&& other) = default; |
|||
Player& operator=(Player&& other) = default; |
|||
|
|||
/*! |
|||
* Retrieves the name of the player. |
|||
* |
|||
* @return The name of the player. |
|||
*/ |
|||
std::string const& getName() const; |
|||
|
|||
/*! |
|||
* Retrieves all controlled Modules of the player. |
|||
* |
|||
* @return The modules controlled by the player. |
|||
*/ |
|||
std::map<std::string, uint_fast32_t> const& getModules() const; // TODO |
|||
|
|||
/*! |
|||
* Retrieves all controlled Commands of the player. |
|||
* |
|||
* @return The commands controlled by the player. |
|||
*/ |
|||
std::map<std::string, uint_fast32_t> const& getCommands() const; |
|||
|
|||
friend std::ostream& operator<<(std::ostream& stream, Player const& player); |
|||
private: |
|||
// The name of the player. |
|||
std::string playerName; |
|||
|
|||
// The modules associated with this player. |
|||
std::map<std::string, uint_fast32_t> controlledModules; |
|||
|
|||
// The commands associated with this player. |
|||
std::map<std::string, uint_fast32_t> controlledCommands; |
|||
}; |
|||
|
|||
} // namespace prism |
|||
} // namespace storm |
|||
|
|||
#endif /* STORM_STORAGE_PRISM_PLAYER_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue