Browse Source

store tuples of player name and index

Store this instead of only the index. Needed for easier parsing of the
rpatl formulas (prism allows player indices and names!)
tempestpy_adaptions
Stefan Pranger 4 years ago
parent
commit
972df05683
  1. 4
      src/storm/generator/Choice.cpp
  2. 2
      src/storm/generator/Choice.h
  3. 25
      src/storm/logic/Coalition.cpp
  4. 32
      src/storm/logic/Coalition.h
  5. 2
      src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.cpp
  6. 4
      src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.h

4
src/storm/generator/Choice.cpp

@ -97,8 +97,8 @@ namespace storm {
}
template<typename ValueType, typename StateType>
bool Choice<ValueType, StateType>::hasPlayerIndex() const {
return playerIndex.is_initialized();
bool Choice<ValueType, StateType>::hasPlayer() const {
return player.is_initialized();
}
template<typename ValueType, typename StateType>

2
src/storm/generator/Choice.h

@ -102,7 +102,7 @@ namespace storm {
/*!
* Returns whether there is an index for the player defined for this choice.
*/
bool hasPlayerIndex() const;
bool hasPlayer() const;
/*!
* Retrieves the players index associated with this choice

25
src/storm/logic/Coalition.cpp

@ -0,0 +1,25 @@
#include "storm/logic/Coalition.h"
namespace storm {
namespace logic {
Coalition::Coalition(std::vector<boost::variant<std::string, uint_fast64_t>> playerIds) : playerIds(playerIds) {
// Intentionally left empty.
}
std::vector<boost::variant<std::string, uint_fast64_t>> Coalition::getPlayerIds() const {
return playerIds;
}
std::ostream& operator<<(std::ostream& stream, Coalition const& coalition) {
bool firstItem = true;
stream << "<<";
for (auto const& id : coalition.playerIds) {
if(firstItem) { firstItem = false; } else { stream << ","; }
stream << id;
}
stream << ">> ";
return stream;
}
}
}

32
src/storm/logic/Coalition.h

@ -0,0 +1,32 @@
#ifndef STORM_LOGIC_COALITION_H_
#define STORM_LOGIC_COALITION_H_
#include <vector>
#include <string>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include "storm/storage/BoostTypes.h"
#include "storm/utility/OsDetection.h"
namespace storm {
namespace logic {
class Coalition {
public:
Coalition() = default;
Coalition(std::vector<boost::variant<std::string, uint_fast64_t>>);
Coalition(Coalition const& other) = default;
std::vector<boost::variant<std::string, uint_fast64_t>> getPlayerIds() const;
friend std::ostream& operator<<(std::ostream& stream, Coalition const& coalition);
private:
std::vector<boost::variant<std::string, uint_fast64_t>> playerIds;
};
}
}
#endif /* STORM_LOGIC_COALITION_H_ */

2
src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.cpp

@ -22,7 +22,7 @@ namespace storm {
namespace helper {
template <typename ValueType>
SparseNondeterministicGameInfiniteHorizonHelper<ValueType>::SparseNondeterministicGameInfiniteHorizonHelper(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<uint64_t> const& coalitionIndices) : SparseInfiniteHorizonHelper<ValueType, true>(transitionMatrix), coalitionIndices(coalitionIndices) {
SparseNondeterministicGameInfiniteHorizonHelper<ValueType>::SparseNondeterministicGameInfiniteHorizonHelper(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<std::pair<std::string, uint_fast64_t>> const& player) : SparseInfiniteHorizonHelper<ValueType, true>(transitionMatrix), player(player) {
// Intentionally left empty.
}

4
src/storm/modelchecker/helper/infinitehorizon/SparseNondeterministicGameInfiniteHorizonHelper.h

@ -27,7 +27,7 @@ namespace storm {
/*!
* Initializes the helper for a discrete time model with different players (i.e. SMG)
*/
SparseNondeterministicGameInfiniteHorizonHelper(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<uint64_t> const& coalitionIndices);
SparseNondeterministicGameInfiniteHorizonHelper(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<std::pair<std::string, uint_fast64_t>> const& player);
/*!
* TODO
@ -57,7 +57,7 @@ namespace storm {
std::vector<ValueType> buildAndSolveSsp(Environment const& env, std::vector<ValueType> const& mecLraValues);
private:
std::vector<uint64_t> coalitionIndices;
std::vector<std::pair<std::string, uint_fast64_t>> player;
};

Loading…
Cancel
Save