Browse Source

Replaced VectorSet bei boost::container::flat_set, which does essentially the same. Fixed a bug in sparse matrix creation.

Former-commit-id: cb632bcfd4
tempestpy_adaptions
dehnert 11 years ago
parent
commit
35d16a1191
  1. 20
      src/adapters/ExplicitModelAdapter.h
  2. 22
      src/counterexamples/MILPMinimalLabelSetGenerator.h
  3. 152
      src/counterexamples/SMTMinimalCommandSetGenerator.h
  4. 4
      src/ir/Module.cpp
  5. 4
      src/ir/Module.h
  6. 2
      src/ir/Program.cpp
  7. 4
      src/ir/Program.h
  8. 4
      src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h
  9. 6
      src/models/AbstractDeterministicModel.h
  10. 13
      src/models/AbstractModel.h
  11. 8
      src/models/AbstractNondeterministicModel.h
  12. 6
      src/models/Ctmc.h
  13. 6
      src/models/Ctmdp.h
  14. 14
      src/models/Dtmc.h
  15. 6
      src/models/MarkovAutomaton.h
  16. 18
      src/models/Mdp.h
  17. 4
      src/parser/DeterministicModelParser.cpp
  18. 2
      src/parser/MarkovAutomatonParser.cpp
  19. 4
      src/parser/NondeterministicModelParser.cpp
  20. 7
      src/storage/BitVector.cpp
  21. 15
      src/storage/Decomposition.cpp
  22. 7
      src/storage/Decomposition.h
  23. 18
      src/storage/LabeledValues.h
  24. 14
      src/storage/MaximalEndComponent.cpp
  25. 13
      src/storage/MaximalEndComponent.h
  26. 12
      src/storage/MaximalEndComponentDecomposition.cpp
  27. 52
      src/storage/SparseMatrix.cpp
  28. 49
      src/storage/SparseMatrix.h
  29. 3
      src/storage/StronglyConnectedComponentDecomposition.h
  30. 299
      src/storage/VectorSet.cpp
  31. 116
      src/storage/VectorSet.h
  32. 10
      src/utility/IRUtility.h
  33. 20
      src/utility/counterexamples.h
  34. 53
      src/utility/set.h
  35. 6
      test/functional/storage/SparseMatrixTest.cpp

20
src/adapters/ExplicitModelAdapter.h

@ -14,6 +14,7 @@
#include <vector>
#include <queue>
#include <boost/functional/hash.hpp>
#include <boost/container/flat_set.hpp>
#include "src/ir/Program.h"
#include "src/ir/RewardModel.h"
@ -77,7 +78,7 @@ namespace storm {
storm::storage::SparseMatrix<ValueType> transitionRewardMatrix;
// A vector that stores a labeling for each choice.
std::vector<storm::storage::VectorSet<uint_fast64_t>> choiceLabeling;
std::vector<boost::container::flat_set<uint_fast64_t>> choiceLabeling;
};
/*!
@ -294,10 +295,9 @@ namespace storm {
// Update the choice by adding the probability/target state to it.
double probabilityToAdd = update.getLikelihoodExpression()->getValueAsDouble(currentState);
probabilitySum += probabilityToAdd;
std::set<uint_fast64_t> lables;
lables.insert(update.getGlobalIndex());
//addProbabilityToChoice(choice, flagTargetStateIndexPair.second, probabilityToAdd, {update.getGlobalIndex()});
addProbabilityToChoice(choice, flagTargetStateIndexPair.second, probabilityToAdd, lables);
boost::container::flat_set<uint_fast64_t> labels;
labels.insert(update.getGlobalIndex());
addProbabilityToChoice(choice, flagTargetStateIndexPair.second, probabilityToAdd, labels);
}
// Check that the resulting distribution is in fact a distribution.
@ -351,7 +351,7 @@ namespace storm {
double updateProbability = update.getLikelihoodExpression()->getValueAsDouble(currentState);
for (auto const& valueLabelSetPair : stateProbabilityPair.second) {
// Copy the label set, so we can modify it.
storm::storage::VectorSet<uint_fast64_t> newLabelSet = valueLabelSetPair.second;
boost::container::flat_set<uint_fast64_t> newLabelSet = valueLabelSetPair.second;
newLabelSet.insert(update.getGlobalIndex());
newProbability.addValue(valueLabelSetPair.first * updateProbability, newLabelSet);
@ -455,9 +455,9 @@ namespace storm {
* @return A tuple containing a vector with all rows at which the nondeterministic choices of each state begin
* and a vector containing the labels associated with each choice.
*/
static std::pair<std::vector<uint_fast64_t>, std::vector<storm::storage::VectorSet<uint_fast64_t>>> buildMatrices(storm::ir::Program const& program, VariableInformation const& variableInformation, std::vector<storm::ir::TransitionReward> const& transitionRewards, StateInformation& stateInformation, bool deterministicModel, storm::storage::SparseMatrixBuilder<ValueType>& transitionMatrixBuilder, storm::storage::SparseMatrixBuilder<ValueType>& transitionRewardMatrixBuilder) {
static std::pair<std::vector<uint_fast64_t>, std::vector<boost::container::flat_set<uint_fast64_t>>> buildMatrices(storm::ir::Program const& program, VariableInformation const& variableInformation, std::vector<storm::ir::TransitionReward> const& transitionRewards, StateInformation& stateInformation, bool deterministicModel, storm::storage::SparseMatrixBuilder<ValueType>& transitionMatrixBuilder, storm::storage::SparseMatrixBuilder<ValueType>& transitionRewardMatrixBuilder) {
std::vector<uint_fast64_t> nondeterministicChoiceIndices;
std::vector<storm::storage::VectorSet<uint_fast64_t>> choiceLabels;
std::vector<boost::container::flat_set<uint_fast64_t>> choiceLabels;
// Initialize a queue and insert the initial state.
std::queue<uint_fast64_t> stateQueue;
@ -492,7 +492,7 @@ namespace storm {
if (deterministicModel) {
Choice<ValueType> globalChoice("");
std::map<uint_fast64_t, ValueType> stateToRewardMap;
storm::storage::VectorSet<uint_fast64_t> allChoiceLabels;
boost::container::flat_set<uint_fast64_t> allChoiceLabels;
// Combine all the choices and scale them with the total number of choices of the current state.
for (auto const& choice : allUnlabeledChoices) {
@ -633,7 +633,7 @@ namespace storm {
// Build the transition and reward matrices.
storm::storage::SparseMatrixBuilder<ValueType> transitionMatrixBuilder;
storm::storage::SparseMatrixBuilder<ValueType> transitionRewardMatrixBuilder;
std::pair<std::vector<uint_fast64_t>, std::vector<storm::storage::VectorSet<uint_fast64_t>>> nondeterministicChoiceIndicesAndChoiceLabelsPair = buildMatrices(program, variableInformation, rewardModel.getTransitionRewards(), stateInformation, deterministicModel, transitionMatrixBuilder, transitionRewardMatrixBuilder);
std::pair<std::vector<uint_fast64_t>, std::vector<boost::container::flat_set<uint_fast64_t>>> nondeterministicChoiceIndicesAndChoiceLabelsPair = buildMatrices(program, variableInformation, rewardModel.getTransitionRewards(), stateInformation, deterministicModel, transitionMatrixBuilder, transitionRewardMatrixBuilder);
modelComponents.nondeterministicChoiceIndices = std::move(nondeterministicChoiceIndicesAndChoiceLabelsPair.first);
modelComponents.choiceLabeling = std::move(nondeterministicChoiceIndicesAndChoiceLabelsPair.second);

22
src/counterexamples/MILPMinimalLabelSetGenerator.h

@ -57,8 +57,8 @@ namespace storm {
struct ChoiceInformation {
std::unordered_map<uint_fast64_t, std::list<uint_fast64_t>> relevantChoicesForRelevantStates;
std::unordered_map<uint_fast64_t, std::list<uint_fast64_t>> problematicChoicesForProblematicStates;
storm::storage::VectorSet<uint_fast64_t> allRelevantLabels;
storm::storage::VectorSet<uint_fast64_t> knownLabels;
boost::container::flat_set<uint_fast64_t> allRelevantLabels;
boost::container::flat_set<uint_fast64_t> knownLabels;
};
/*!
@ -116,7 +116,7 @@ namespace storm {
ChoiceInformation result;
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = labeledMdp.getNondeterministicChoiceIndices();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
// Now traverse all choices of all relevant states and check whether there is a relevant target state.
// If so, the associated labels become relevant. Also, if a choice of relevant state has at least one
@ -168,7 +168,7 @@ namespace storm {
* @param relevantLabels The set of relevant labels of the model.
* @return A mapping from labels to variable indices.
*/
static std::pair<std::unordered_map<uint_fast64_t, uint_fast64_t>, uint_fast64_t> createLabelVariables(storm::solver::LpSolver& solver, storm::storage::VectorSet<uint_fast64_t> const& relevantLabels) {
static std::pair<std::unordered_map<uint_fast64_t, uint_fast64_t>, uint_fast64_t> createLabelVariables(storm::solver::LpSolver& solver, boost::container::flat_set<uint_fast64_t> const& relevantLabels) {
int error = 0;
std::stringstream variableNameBuffer;
std::unordered_map<uint_fast64_t, uint_fast64_t> resultingMap;
@ -482,7 +482,7 @@ namespace storm {
static uint_fast64_t assertChoicesImplyLabels(storm::solver::LpSolver& solver, storm::models::Mdp<T> const& labeledMdp, StateInformation const& stateInformation, ChoiceInformation const& choiceInformation, VariableInformation const& variableInformation) {
uint_fast64_t numberOfConstraintsCreated = 0;
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
for (auto state : stateInformation.relevantStates) {
std::list<uint_fast64_t>::const_iterator choiceVariableIndicesIterator = variableInformation.stateToChoiceVariablesIndexMap.at(state).begin();
for (auto choice : choiceInformation.relevantChoicesForRelevantStates.at(state)) {
@ -888,8 +888,8 @@ namespace storm {
* @param solver The MILP solver.
* @param variableInformation A struct with information about the variables of the model.
*/
static storm::storage::VectorSet<uint_fast64_t> getUsedLabelsInSolution(storm::solver::LpSolver const& solver, VariableInformation const& variableInformation) {
storm::storage::VectorSet<uint_fast64_t> result;
static boost::container::flat_set<uint_fast64_t> getUsedLabelsInSolution(storm::solver::LpSolver const& solver, VariableInformation const& variableInformation) {
boost::container::flat_set<uint_fast64_t> result;
for (auto labelVariablePair : variableInformation.labelToVariableIndexMap) {
bool labelTaken = solver.getBinaryValue(labelVariablePair.second);
@ -951,7 +951,7 @@ namespace storm {
public:
static storm::storage::VectorSet<uint_fast64_t> getMinimalLabelSet(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeSchedulerCuts = false) {
static boost::container::flat_set<uint_fast64_t> getMinimalLabelSet(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeSchedulerCuts = false) {
// (0) Check whether the MDP is indeed labeled.
if (!labeledMdp.hasChoiceLabeling()) {
throw storm::exceptions::InvalidArgumentException() << "Minimal label set generation is impossible for unlabeled model.";
@ -987,8 +987,8 @@ namespace storm {
solver->optimize();
// (4.4) Read off result from variables.
storm::storage::VectorSet<uint_fast64_t> usedLabelSet = getUsedLabelsInSolution(*solver, variableInformation);
usedLabelSet.insert(choiceInformation.knownLabels);
boost::container::flat_set<uint_fast64_t> usedLabelSet = getUsedLabelsInSolution(*solver, variableInformation);
usedLabelSet.insert(choiceInformation.knownLabels.begin(), choiceInformation.knownLabels.end());
// Display achieved probability.
std::pair<uint_fast64_t, double> initialStateProbabilityPair = getReachabilityProbability(*solver, labeledMdp, variableInformation);
@ -1044,7 +1044,7 @@ namespace storm {
// Delegate the actual computation work to the function of equal name.
auto startTime = std::chrono::high_resolution_clock::now();
storm::storage::VectorSet<uint_fast64_t> usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, true);
boost::container::flat_set<uint_fast64_t> usedLabelSet = getMinimalLabelSet(labeledMdp, phiStates, psiStates, bound, strictBound, true, true);
auto endTime = std::chrono::high_resolution_clock::now();
std::cout << std::endl << "Computed minimal label set of size " << usedLabelSet.size() << " in " << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() << "ms." << std::endl;

152
src/counterexamples/SMTMinimalCommandSetGenerator.h

@ -43,10 +43,10 @@ namespace storm {
storm::storage::BitVector relevantStates;
// The set of relevant labels.
storm::storage::VectorSet<uint_fast64_t> relevantLabels;
boost::container::flat_set<uint_fast64_t> relevantLabels;
// A set of labels that is definitely known to be taken in the final solution.
storm::storage::VectorSet<uint_fast64_t> knownLabels;
boost::container::flat_set<uint_fast64_t> knownLabels;
// A list of relevant choices for each relevant state.
std::map<uint_fast64_t, std::list<uint_fast64_t>> relevantChoicesForRelevantStates;
@ -112,7 +112,7 @@ namespace storm {
// Retrieve some references for convenient access.
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = labeledMdp.getNondeterministicChoiceIndices();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
// Now traverse all choices of all relevant states and check whether there is a successor target state.
// If so, the associated labels become relevant. Also, if a choice of relevant state has at least one
@ -141,7 +141,7 @@ namespace storm {
// Compute the set of labels that are known to be taken in any case.
relevancyInformation.knownLabels = storm::utility::counterexamples::getGuaranteedLabelSet(labeledMdp, psiStates, relevancyInformation.relevantLabels);
if (!relevancyInformation.knownLabels.empty()) {
storm::storage::VectorSet<uint_fast64_t> remainingLabels;
boost::container::flat_set<uint_fast64_t> remainingLabels;
std::set_difference(relevancyInformation.relevantLabels.begin(), relevancyInformation.relevantLabels.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(remainingLabels, remainingLabels.end()));
relevancyInformation.relevantLabels = remainingLabels;
}
@ -282,19 +282,19 @@ namespace storm {
// * identify labels that directly reach a target state
// * identify labels that can directly follow a given action
storm::storage::VectorSet<uint_fast64_t> initialLabels;
std::set<storm::storage::VectorSet<uint_fast64_t>> initialCombinations;
std::map<uint_fast64_t, storm::storage::VectorSet<uint_fast64_t>> precedingLabels;
storm::storage::VectorSet<uint_fast64_t> targetLabels;
storm::storage::VectorSet<storm::storage::VectorSet<uint_fast64_t>> targetCombinations;
std::map<storm::storage::VectorSet<uint_fast64_t>, std::set<storm::storage::VectorSet<uint_fast64_t>>> followingLabels;
std::map<uint_fast64_t, std::set<storm::storage::VectorSet<uint_fast64_t>>> synchronizingLabels;
boost::container::flat_set<uint_fast64_t> initialLabels;
std::set<boost::container::flat_set<uint_fast64_t>> initialCombinations;
std::map<uint_fast64_t, boost::container::flat_set<uint_fast64_t>> precedingLabels;
boost::container::flat_set<uint_fast64_t> targetLabels;
boost::container::flat_set<boost::container::flat_set<uint_fast64_t>> targetCombinations;
std::map<boost::container::flat_set<uint_fast64_t>, std::set<boost::container::flat_set<uint_fast64_t>>> followingLabels;
std::map<uint_fast64_t, std::set<boost::container::flat_set<uint_fast64_t>>> synchronizingLabels;
// Get some data from the MDP for convenient access.
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = labeledMdp.getNondeterministicChoiceIndices();
storm::storage::BitVector const& initialStates = labeledMdp.getInitialStates();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
storm::storage::SparseMatrix<T> backwardTransitions = labeledMdp.getBackwardTransitions();
for (auto currentState : relevancyInformation.relevantStates) {
@ -309,7 +309,7 @@ namespace storm {
// If the state is initial, we need to add all the choice labels to the initial label set.
if (initialStates.get(currentState)) {
initialLabels.insert(choiceLabeling[currentChoice]);
initialLabels.insert(choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end());
initialCombinations.insert(choiceLabeling[currentChoice]);
}
@ -327,7 +327,7 @@ namespace storm {
// If the choice can reach a target state directly, we add all the labels to the target label set.
if (canReachTargetState) {
targetLabels.insert(choiceLabeling[currentChoice]);
targetLabels.insert(choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end());
targetCombinations.insert(choiceLabeling[currentChoice]);
}
}
@ -368,7 +368,7 @@ namespace storm {
// combination that is already known. Otherwise this condition would be too strong.
bool initialCombinationKnown = false;
for (auto const& combination : initialCombinations) {
storm::storage::VectorSet<uint_fast64_t> tmpSet;
boost::container::flat_set<uint_fast64_t> tmpSet;
std::set_difference(combination.begin(), combination.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(tmpSet, tmpSet.end()));
if (tmpSet.size() == 0) {
initialCombinationKnown = true;
@ -393,7 +393,7 @@ namespace storm {
// Likewise, if no target combination is known, we may assert that there is at least one.
bool targetCombinationKnown = false;
for (auto const& combination : targetCombinations) {
storm::storage::VectorSet<uint_fast64_t> tmpSet;
boost::container::flat_set<uint_fast64_t> tmpSet;
std::set_difference(combination.begin(), combination.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(tmpSet, tmpSet.end()));
if (tmpSet.size() == 0) {
targetCombinationKnown = true;
@ -412,10 +412,10 @@ namespace storm {
}
// Compute the sets of labels such that the transitions labeled with this set possess at least one known successor.
storm::storage::VectorSet<storm::storage::VectorSet<uint_fast64_t>> hasKnownSuccessor;
boost::container::flat_set<boost::container::flat_set<uint_fast64_t>> hasKnownSuccessor;
for (auto const& labelSetFollowingSetsPair : followingLabels) {
for (auto const& set : labelSetFollowingSetsPair.second) {
if (set.subsetOf(relevancyInformation.knownLabels)) {
if (std::includes(relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), set.begin(), set.end())) {
hasKnownSuccessor.insert(set);
break;
}
@ -429,17 +429,17 @@ namespace storm {
// Only build a constraint if the combination does not lead to a target state and
// no successor set is already known.
if (!targetCombinations.contains(labelSetFollowingSetsPair.first) && !hasKnownSuccessor.contains(labelSetFollowingSetsPair.first)) {
if (targetCombinations.find(labelSetFollowingSetsPair.first) == targetCombinations.end() && hasKnownSuccessor.find(labelSetFollowingSetsPair.first) == hasKnownSuccessor.end()) {
// Compute the set of unknown labels on the left-hand side of the implication.
storm::storage::VectorSet<uint_fast64_t> unknownLhsLabels;
boost::container::flat_set<uint_fast64_t> unknownLhsLabels;
std::set_difference(labelSetFollowingSetsPair.first.begin(), labelSetFollowingSetsPair.first.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownLhsLabels, unknownLhsLabels.end()));
for (auto label : unknownLhsLabels) {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
}
for (auto const& followingSet : labelSetFollowingSetsPair.second) {
storm::storage::VectorSet<uint_fast64_t> tmpSet;
boost::container::flat_set<uint_fast64_t> tmpSet;
// Check which labels of the current following set are not known. This set must be non-empty, because
// otherwise a successor combination would already be known and control cannot reach this point.
@ -461,7 +461,7 @@ namespace storm {
z3::expr finalDisjunct = context.bool_val(false);
for (auto label : labelSetFollowingSetsPair.first) {
z3::expr alternativeExpressionForLabel = context.bool_val(false);
std::set<storm::storage::VectorSet<uint_fast64_t>> const& synchsForCommand = synchronizingLabels.at(label);
std::set<boost::container::flat_set<uint_fast64_t>> const& synchsForCommand = synchronizingLabels.at(label);
for (auto const& synchSet : synchsForCommand) {
z3::expr alternativeExpression = context.bool_val(true);
@ -471,9 +471,9 @@ namespace storm {
// Now that we have the labels that are unknown and "missing", we still need to check whether this other
// synchronizing set already has a known successor or leads directly to a target state.
if (!hasKnownSuccessor.contains(synchSet) && !targetCombinations.contains(synchSet)) {
if (hasKnownSuccessor.find(synchSet) == hasKnownSuccessor.end() && targetCombinations.find(synchSet) == targetCombinations.end()) {
// If not, we can assert that we take one of its possible successors.
storm::storage::VectorSet<uint_fast64_t> unknownSynchs;
boost::container::flat_set<uint_fast64_t> unknownSynchs;
std::set_difference(synchSet.begin(), synchSet.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownSynchs, unknownSynchs.end()));
unknownSynchs.erase(label);
@ -485,7 +485,7 @@ namespace storm {
for (auto successorSet : followingLabels.at(synchSet)) {
z3::expr conjunctionOverLabels = context.bool_val(true);
for (auto label : successorSet) {
if (!relevancyInformation.knownLabels.contains(label)) {
if (relevancyInformation.knownLabels.find(label) == relevancyInformation.knownLabels.end()) {
conjunctionOverLabels = conjunctionOverLabels && variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label));
}
}
@ -516,7 +516,7 @@ namespace storm {
for (auto const& labelSynchronizingSetsPair : synchronizingLabels) {
std::vector<z3::expr> formulae;
if (!relevancyInformation.knownLabels.contains(labelSynchronizingSetsPair.first)) {
if (relevancyInformation.knownLabels.find(labelSynchronizingSetsPair.first) == relevancyInformation.knownLabels.end()) {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(labelSynchronizingSetsPair.first)));
}
@ -527,7 +527,7 @@ namespace storm {
z3::expr currentCombination = context.bool_val(true);
bool allImplicantsKnownForCurrentSet = true;
for (auto label : synchronizingSet) {
if (!relevancyInformation.knownLabels.contains(label) && label != labelSynchronizingSetsPair.first) {
if (relevancyInformation.knownLabels.find(label) == relevancyInformation.knownLabels.end() && label != labelSynchronizingSetsPair.first) {
currentCombination = currentCombination && variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label));
}
}
@ -557,14 +557,14 @@ namespace storm {
static void assertSymbolicCuts(storm::ir::Program const& program, storm::models::Mdp<T> const& labeledMdp, VariableInformation const& variableInformation, RelevancyInformation const& relevancyInformation, z3::context& context, z3::solver& solver) {
// A container storing the label sets that may precede a given label set.
std::map<storm::storage::VectorSet<uint_fast64_t>, std::set<storm::storage::VectorSet<uint_fast64_t>>> precedingLabelSets;
std::map<boost::container::flat_set<uint_fast64_t>, std::set<boost::container::flat_set<uint_fast64_t>>> precedingLabelSets;
// A container that maps labels to their reachable synchronization sets.
std::map<uint_fast64_t, std::set<storm::storage::VectorSet<uint_fast64_t>>> synchronizingLabels;
std::map<uint_fast64_t, std::set<boost::container::flat_set<uint_fast64_t>>> synchronizingLabels;
// Get some data from the MDP for convenient access.
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
storm::storage::SparseMatrix<T> backwardTransitions = labeledMdp.getBackwardTransitions();
// Compute the set of labels that may precede a given action.
@ -640,7 +640,7 @@ namespace storm {
}
// Store the found implications in a container similar to the preceding label sets.
std::map<storm::storage::VectorSet<uint_fast64_t>, std::set<storm::storage::VectorSet<uint_fast64_t>>> backwardImplications;
std::map<boost::container::flat_set<uint_fast64_t>, std::set<boost::container::flat_set<uint_fast64_t>>> backwardImplications;
// Now check for possible backward cuts.
for (auto const& labelSetAndPrecedingLabelSetsPair : precedingLabelSets) {
@ -654,7 +654,7 @@ namespace storm {
storm::ir::Command const& command = module.getCommand(commandIndex);
// If the current command is one of the commands we need to consider, store a reference to it in the container.
if (labelSetAndPrecedingLabelSetsPair.first.contains(command.getGlobalIndex())) {
if (labelSetAndPrecedingLabelSetsPair.first.find(command.getGlobalIndex()) != labelSetAndPrecedingLabelSetsPair.first.end()) {
currentCommandVector.push_back(command);
}
}
@ -723,7 +723,7 @@ namespace storm {
storm::ir::Command const& command = module.getCommand(commandIndex);
// If the current command is one of the commands we need to consider, store a reference to it in the container.
if (precedingLabelSet.contains(command.getGlobalIndex())) {
if (precedingLabelSet.find(command.getGlobalIndex()) != precedingLabelSet.end()) {
currentPrecedingCommandVector.push_back(command);
}
}
@ -789,10 +789,10 @@ namespace storm {
}
// Compute the sets of labels such that the transitions labeled with this set possess at least one known successor.
storm::storage::VectorSet<storm::storage::VectorSet<uint_fast64_t>> hasKnownPredecessor;
boost::container::flat_set<boost::container::flat_set<uint_fast64_t>> hasKnownPredecessor;
for (auto const& labelSetImplicationsPair : backwardImplications) {
for (auto const& set : labelSetImplicationsPair.second) {
if (set.subsetOf(relevancyInformation.knownLabels)) {
if (std::includes(relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), set.begin(), set.end())) {
hasKnownPredecessor.insert(set);
break;
}
@ -805,17 +805,17 @@ namespace storm {
std::vector<z3::expr> formulae;
// Only build a constraint if the combination no predecessor set is already known.
if (!hasKnownPredecessor.contains(labelSetImplicationsPair.first)) {
if (hasKnownPredecessor.find(labelSetImplicationsPair.first) == hasKnownPredecessor.end()) {
// Compute the set of unknown labels on the left-hand side of the implication.
storm::storage::VectorSet<uint_fast64_t> unknownLhsLabels;
boost::container::flat_set<uint_fast64_t> unknownLhsLabels;
std::set_difference(labelSetImplicationsPair.first.begin(), labelSetImplicationsPair.first.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownLhsLabels, unknownLhsLabels.end()));
for (auto label : unknownLhsLabels) {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
}
for (auto const& precedingSet : labelSetImplicationsPair.second) {
storm::storage::VectorSet<uint_fast64_t> tmpSet;
boost::container::flat_set<uint_fast64_t> tmpSet;
// Check which labels of the current following set are not known. This set must be non-empty, because
// otherwise a predecessor combination would already be known and control cannot reach this point.
@ -837,7 +837,7 @@ namespace storm {
z3::expr finalDisjunct = context.bool_val(false);
for (auto label : labelSetImplicationsPair.first) {
z3::expr alternativeExpressionForLabel = context.bool_val(false);
std::set<storm::storage::VectorSet<uint_fast64_t>> const& synchsForCommand = synchronizingLabels.at(label);
std::set<boost::container::flat_set<uint_fast64_t>> const& synchsForCommand = synchronizingLabels.at(label);
for (auto const& synchSet : synchsForCommand) {
z3::expr alternativeExpression = context.bool_val(true);
@ -847,9 +847,9 @@ namespace storm {
// Now that we have the labels that are unknown and "missing", we still need to check whether this other
// synchronizing set already has a known predecessor.
if (!hasKnownPredecessor.contains(synchSet)) {
if (hasKnownPredecessor.find(synchSet) == hasKnownPredecessor.end()) {
// If not, we can assert that we take one of its possible predecessors.
storm::storage::VectorSet<uint_fast64_t> unknownSynchs;
boost::container::flat_set<uint_fast64_t> unknownSynchs;
std::set_difference(synchSet.begin(), synchSet.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownSynchs, unknownSynchs.end()));
unknownSynchs.erase(label);
@ -863,7 +863,7 @@ namespace storm {
for (auto precedingSet : precedingLabelSetsIterator->second) {
z3::expr conjunctionOverLabels = context.bool_val(true);
for (auto label : precedingSet) {
if (!relevancyInformation.knownLabels.contains(label)) {
if (relevancyInformation.knownLabels.find(label) == relevancyInformation.knownLabels.end()) {
conjunctionOverLabels = conjunctionOverLabels && variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label));
}
}
@ -901,7 +901,7 @@ namespace storm {
// Get some data from the MDP for convenient access.
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
storm::storage::SparseMatrix<T> backwardTransitions = labeledMdp.getBackwardTransitions();
// First, we add the formulas that encode
@ -911,14 +911,14 @@ namespace storm {
for (auto relevantState : relevancyInformation.relevantStates) {
if (!labeledMdp.getInitialStates().get(relevantState)) {
// Assert the constraints (1).
storm::storage::VectorSet<uint_fast64_t> relevantPredecessors;
boost::container::flat_set<uint_fast64_t> relevantPredecessors;
for (auto const& predecessorEntry : backwardTransitions.getRow(relevantState)) {
if (relevantState != predecessorEntry.first && relevancyInformation.relevantStates.get(predecessorEntry.first)) {
relevantPredecessors.insert(predecessorEntry.first);
}
}
storm::storage::VectorSet<uint_fast64_t> relevantSuccessors;
boost::container::flat_set<uint_fast64_t> relevantSuccessors;
for (auto const& relevantChoice : relevancyInformation.relevantChoicesForRelevantStates.at(relevantState)) {
for (auto const& successorEntry : transitionMatrix.getRow(relevantChoice)) {
if (relevantState != successorEntry.first && (relevancyInformation.relevantStates.get(successorEntry.first) || psiStates.get(successorEntry.first))) {
@ -938,7 +938,7 @@ namespace storm {
solver.add(expression);
} else {
// Assert the constraints (2).
storm::storage::VectorSet<uint_fast64_t> relevantSuccessors;
boost::container::flat_set<uint_fast64_t> relevantSuccessors;
for (auto const& relevantChoice : relevancyInformation.relevantChoicesForRelevantStates.at(relevantState)) {
for (auto const& successorEntry : transitionMatrix.getRow(relevantChoice)) {
if (relevantState != successorEntry.first && (relevancyInformation.relevantStates.get(successorEntry.first) || psiStates.get(successorEntry.first))) {
@ -962,7 +962,7 @@ namespace storm {
uint_fast64_t targetState = statePairIndexPair.first.second;
// Assert constraint for (1).
storm::storage::VectorSet<uint_fast64_t> choicesForStatePair;
boost::container::flat_set<uint_fast64_t> choicesForStatePair;
for (auto const& relevantChoice : relevancyInformation.relevantChoicesForRelevantStates.at(sourceState)) {
for (auto const& successorEntry : transitionMatrix.getRow(relevantChoice)) {
if (successorEntry.first == targetState) {
@ -974,7 +974,7 @@ namespace storm {
for (auto choice : choicesForStatePair) {
z3::expr choiceExpression = context.bool_val(true);
for (auto element : choiceLabeling.at(choice)) {
if (!relevancyInformation.knownLabels.contains(element)) {
if (relevancyInformation.knownLabels.find(element) == relevancyInformation.knownLabels.end()) {
choiceExpression = choiceExpression && variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(element));
}
}
@ -1271,10 +1271,10 @@ namespace storm {
* @param commandSet The command set to rule out as a solution.
* @param variableInformation A structure with information about the variables for the labels.
*/
static void ruleOutSolution(z3::context& context, z3::solver& solver, storm::storage::VectorSet<uint_fast64_t> const& commandSet, VariableInformation const& variableInformation) {
static void ruleOutSolution(z3::context& context, z3::solver& solver, boost::container::flat_set<uint_fast64_t> const& commandSet, VariableInformation const& variableInformation) {
z3::expr blockSolutionExpression = context.bool_val(false);
for (auto labelIndexPair : variableInformation.labelToIndexMap) {
if (commandSet.contains(labelIndexPair.first)) {
if (commandSet.find(labelIndexPair.first) != commandSet.end()) {
blockSolutionExpression = blockSolutionExpression || variableInformation.labelVariables[labelIndexPair.second];
}
}
@ -1289,8 +1289,8 @@ namespace storm {
* @param model The Z3 model from which to extract the information.
* @param variableInformation A structure with information about the variables of the solver.
*/
static storm::storage::VectorSet<uint_fast64_t> getUsedLabelSet(z3::context& context, z3::model const& model, VariableInformation const& variableInformation) {
storm::storage::VectorSet<uint_fast64_t> result;
static boost::container::flat_set<uint_fast64_t> getUsedLabelSet(z3::context& context, z3::model const& model, VariableInformation const& variableInformation) {
boost::container::flat_set<uint_fast64_t> result;
for (auto const& labelIndexPair : variableInformation.labelToIndexMap) {
z3::expr auxValue = model.eval(variableInformation.labelVariables.at(labelIndexPair.second));
@ -1342,7 +1342,7 @@ namespace storm {
* in order to satisfy the constraint system.
* @return The smallest set of labels such that the constraint system of the solver is satisfiable.
*/
static storm::storage::VectorSet<uint_fast64_t> findSmallestCommandSet(z3::context& context, z3::solver& solver, VariableInformation& variableInformation, uint_fast64_t& currentBound) {
static boost::container::flat_set<uint_fast64_t> findSmallestCommandSet(z3::context& context, z3::solver& solver, VariableInformation& variableInformation, uint_fast64_t& currentBound) {
// Check if we can find a solution with the current bound.
z3::expr assumption = !variableInformation.auxiliaryVariables.back();
@ -1372,7 +1372,7 @@ namespace storm {
* @param commandSet The currently chosen set of commands.
* @param variableInformation A structure with information about the variables of the solver.
*/
static void analyzeZeroProbabilitySolution(z3::context& context, z3::solver& solver, storm::models::Mdp<T> const& subMdp, storm::models::Mdp<T> const& originalMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, storm::storage::VectorSet<uint_fast64_t> const& commandSet, VariableInformation& variableInformation, RelevancyInformation const& relevancyInformation) {
static void analyzeZeroProbabilitySolution(z3::context& context, z3::solver& solver, storm::models::Mdp<T> const& subMdp, storm::models::Mdp<T> const& originalMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, boost::container::flat_set<uint_fast64_t> const& commandSet, VariableInformation& variableInformation, RelevancyInformation const& relevancyInformation) {
storm::storage::BitVector reachableStates(subMdp.getNumberOfStates());
LOG4CPLUS_DEBUG(logger, "Analyzing solution with zero probability.");
@ -1388,10 +1388,10 @@ namespace storm {
storm::storage::SparseMatrix<T> const& transitionMatrix = subMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = subMdp.getNondeterministicChoiceIndices();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& subChoiceLabeling = subMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& subChoiceLabeling = subMdp.getChoiceLabeling();
// Now determine which states and labels are actually reachable.
storm::storage::VectorSet<uint_fast64_t> reachableLabels;
boost::container::flat_set<uint_fast64_t> reachableLabels;
while (!stack.empty()) {
uint_fast64_t currentState = stack.back();
stack.pop_back();
@ -1428,17 +1428,17 @@ namespace storm {
storm::storage::BitVector unreachableRelevantStates = ~reachableStates & relevancyInformation.relevantStates;
storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getTransitionMatrix(), subMdp.getNondeterministicChoiceIndices(), subMdp.getBackwardTransitions(), phiStates, psiStates);
std::vector<storm::storage::VectorSet<uint_fast64_t>> guaranteedLabelSets = storm::utility::counterexamples::getGuaranteedLabelSets(originalMdp, statesThatCanReachTargetStates, relevancyInformation.relevantLabels);
std::vector<boost::container::flat_set<uint_fast64_t>> guaranteedLabelSets = storm::utility::counterexamples::getGuaranteedLabelSets(originalMdp, statesThatCanReachTargetStates, relevancyInformation.relevantLabels);
LOG4CPLUS_DEBUG(logger, "Found " << reachableLabels.size() << " reachable labels and " << reachableStates.getNumberOfSetBits() << " reachable states.");
// Search for states on the border of the reachable state space, i.e. states that are still reachable
// and possess a (disabled) option to leave the reachable part of the state space.
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = originalMdp.getChoiceLabeling();
std::set<storm::storage::VectorSet<uint_fast64_t>> cutLabels;
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = originalMdp.getChoiceLabeling();
std::set<boost::container::flat_set<uint_fast64_t>> cutLabels;
for (auto state : reachableStates) {
for (auto currentChoice : relevancyInformation.relevantChoicesForRelevantStates.at(state)) {
if (!choiceLabeling[currentChoice].subsetOf(commandSet)) {
if (!std::includes(commandSet.begin(), commandSet.end(), choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end())) {
bool isBorderChoice = false;
// Determine whether the state has the option to leave the reachable state space and go to the unreachable relevant states.
@ -1449,9 +1449,9 @@ namespace storm {
}
if (isBorderChoice) {
storm::storage::VectorSet<uint_fast64_t> currentLabelSet;
boost::container::flat_set<uint_fast64_t> currentLabelSet;
for (auto label : choiceLabeling.at(currentChoice)) {
if (!commandSet.contains(label)) {
if (commandSet.find(label) == commandSet.end()) {
currentLabelSet.insert(label);
}
}
@ -1465,7 +1465,7 @@ namespace storm {
// Given the results of the previous analysis, we construct the implications.
std::vector<z3::expr> formulae;
storm::storage::VectorSet<uint_fast64_t> unknownReachableLabels;
boost::container::flat_set<uint_fast64_t> unknownReachableLabels;
std::set_difference(reachableLabels.begin(), reachableLabels.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownReachableLabels, unknownReachableLabels.end()));
for (auto label : unknownReachableLabels) {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
@ -1497,7 +1497,7 @@ namespace storm {
* @param commandSet The currently chosen set of commands.
* @param variableInformation A structure with information about the variables of the solver.
*/
static void analyzeInsufficientProbabilitySolution(z3::context& context, z3::solver& solver, storm::models::Mdp<T> const& subMdp, storm::models::Mdp<T> const& originalMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, storm::storage::VectorSet<uint_fast64_t> const& commandSet, VariableInformation& variableInformation, RelevancyInformation const& relevancyInformation) {
static void analyzeInsufficientProbabilitySolution(z3::context& context, z3::solver& solver, storm::models::Mdp<T> const& subMdp, storm::models::Mdp<T> const& originalMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, boost::container::flat_set<uint_fast64_t> const& commandSet, VariableInformation& variableInformation, RelevancyInformation const& relevancyInformation) {
LOG4CPLUS_DEBUG(logger, "Analyzing solution with insufficient probability.");
@ -1514,10 +1514,10 @@ namespace storm {
storm::storage::SparseMatrix<T> const& transitionMatrix = subMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = subMdp.getNondeterministicChoiceIndices();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& subChoiceLabeling = subMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& subChoiceLabeling = subMdp.getChoiceLabeling();
// Now determine which states and labels are actually reachable.
storm::storage::VectorSet<uint_fast64_t> reachableLabels;
boost::container::flat_set<uint_fast64_t> reachableLabels;
while (!stack.empty()) {
uint_fast64_t currentState = stack.back();
stack.pop_back();
@ -1548,17 +1548,17 @@ namespace storm {
storm::storage::BitVector unreachableRelevantStates = ~reachableStates & relevancyInformation.relevantStates;
storm::storage::BitVector statesThatCanReachTargetStates = storm::utility::graph::performProbGreater0E(subMdp.getTransitionMatrix(), subMdp.getNondeterministicChoiceIndices(), subMdp.getBackwardTransitions(), phiStates, psiStates);
std::vector<storm::storage::VectorSet<uint_fast64_t>> guaranteedLabelSets = storm::utility::counterexamples::getGuaranteedLabelSets(originalMdp, statesThatCanReachTargetStates, relevancyInformation.relevantLabels);
std::vector<boost::container::flat_set<uint_fast64_t>> guaranteedLabelSets = storm::utility::counterexamples::getGuaranteedLabelSets(originalMdp, statesThatCanReachTargetStates, relevancyInformation.relevantLabels);
// Search for states for which we could enable another option and possibly improve the reachability probability.
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = originalMdp.getChoiceLabeling();
std::set<storm::storage::VectorSet<uint_fast64_t>> cutLabels;
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = originalMdp.getChoiceLabeling();
std::set<boost::container::flat_set<uint_fast64_t>> cutLabels;
for (auto state : reachableStates) {
for (auto currentChoice : relevancyInformation.relevantChoicesForRelevantStates.at(state)) {
if (!choiceLabeling[currentChoice].subsetOf(commandSet)) {
storm::storage::VectorSet<uint_fast64_t> currentLabelSet;
if (!std::includes(commandSet.begin(), commandSet.end(), choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end())) {
boost::container::flat_set<uint_fast64_t> currentLabelSet;
for (auto label : choiceLabeling[currentChoice]) {
if (!commandSet.contains(label)) {
if (commandSet.find(label) == commandSet.end()) {
currentLabelSet.insert(label);
}
}
@ -1572,7 +1572,7 @@ namespace storm {
// Given the results of the previous analysis, we construct the implications
std::vector<z3::expr> formulae;
storm::storage::VectorSet<uint_fast64_t> unknownReachableLabels;
boost::container::flat_set<uint_fast64_t> unknownReachableLabels;
std::set_difference(reachableLabels.begin(), reachableLabels.end(), relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end(), std::inserter(unknownReachableLabels, unknownReachableLabels.end()));
for (auto label : unknownReachableLabels) {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(label)));
@ -1607,7 +1607,7 @@ namespace storm {
* @param checkThresholdFeasible If set, it is verified that the model can actually achieve/exceed the given probability value. If this check
* is made and fails, an exception is thrown.
*/
static storm::storage::VectorSet<uint_fast64_t> getMinimalCommandSet(storm::ir::Program program, std::string const& constantDefinitionString, storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeReachabilityEncoding = false) {
static boost::container::flat_set<uint_fast64_t> getMinimalCommandSet(storm::ir::Program program, std::string const& constantDefinitionString, storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, double probabilityThreshold, bool strictBound, bool checkThresholdFeasible = false, bool includeReachabilityEncoding = false) {
#ifdef STORM_HAVE_Z3
// Set up all clocks used for time measurement.
auto totalClock = std::chrono::high_resolution_clock::now();
@ -1683,7 +1683,7 @@ namespace storm {
// the solver.
// Set up some variables for the iterations.
storm::storage::VectorSet<uint_fast64_t> commandSet(relevancyInformation.relevantLabels);
boost::container::flat_set<uint_fast64_t> commandSet(relevancyInformation.relevantLabels);
bool done = false;
uint_fast64_t iterations = 0;
uint_fast64_t currentBound = 0;
@ -1699,7 +1699,7 @@ namespace storm {
// Restrict the given MDP to the current set of labels and compute the reachability probability.
modelCheckingClock = std::chrono::high_resolution_clock::now();
commandSet.insert(relevancyInformation.knownLabels);
commandSet.insert(relevancyInformation.knownLabels.begin(), relevancyInformation.knownLabels.end());
storm::models::Mdp<T> subMdp = labeledMdp.restrictChoiceLabels(commandSet);
storm::modelchecker::prctl::SparseMdpPrctlModelChecker<T> modelchecker(subMdp);
LOG4CPLUS_DEBUG(logger, "Invoking model checker.");

4
src/ir/Module.cpp

@ -186,10 +186,10 @@ namespace storm {
}
}
void Module::restrictCommands(storm::storage::VectorSet<uint_fast64_t> const& indexSet) {
void Module::restrictCommands(boost::container::flat_set<uint_fast64_t> const& indexSet) {
std::vector<storm::ir::Command> newCommands;
for (auto const& command : commands) {
if (indexSet.contains(command.getGlobalIndex())) {
if (indexSet.find(command.getGlobalIndex()) != indexSet.end()) {
newCommands.push_back(std::move(command));
}
}

4
src/ir/Module.h

@ -9,6 +9,7 @@
#define STORM_IR_MODULE_H_
#include "utility/OsDetection.h"
#include <boost/container/flat_set.hpp>
#ifdef LINUX
#include <boost/container/map.hpp>
@ -20,7 +21,6 @@
#include <vector>
#include <memory>
#include "src/storage/VectorSet.h"
#include "BooleanVariable.h"
#include "IntegerVariable.h"
#include "Command.h"
@ -187,7 +187,7 @@ namespace storm {
*
* @param indexSet The set of indices for which to keep the commands.
*/
void restrictCommands(storm::storage::VectorSet<uint_fast64_t> const& indexSet);
void restrictCommands(boost::container::flat_set<uint_fast64_t> const& indexSet);
private:
/*!

2
src/ir/Program.cpp

@ -290,7 +290,7 @@ namespace storm {
return this->globalIntegerVariableToIndexMap.at(variableName);
}
void Program::restrictCommands(storm::storage::VectorSet<uint_fast64_t> const& indexSet) {
void Program::restrictCommands(boost::container::flat_set<uint_fast64_t> const& indexSet) {
for (auto& module : modules) {
module.restrictCommands(indexSet);
}

4
src/ir/Program.h

@ -12,8 +12,8 @@
#include <vector>
#include <memory>
#include <set>
#include <boost/container/flat_set.hpp>
#include "src/storage/VectorSet.h"
#include "expressions/BaseExpression.h"
#include "expressions/BooleanConstantExpression.h"
#include "expressions/IntegerConstantExpression.h"
@ -267,7 +267,7 @@ namespace storm {
*
* @param indexSet The set of indices for which to keep the commands.
*/
void restrictCommands(storm::storage::VectorSet<uint_fast64_t> const& indexSet);
void restrictCommands(boost::container::flat_set<uint_fast64_t> const& indexSet);
private:
// The type of the model.
ModelType modelType;

4
src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h

@ -339,13 +339,13 @@ namespace storm {
for (auto const& stateChoicesPair : mec) {
uint_fast64_t state = stateChoicesPair.first;
storm::storage::VectorSet<uint_fast64_t> const& choicesInMec = stateChoicesPair.second;
boost::container::flat_set<uint_fast64_t> const& choicesInMec = stateChoicesPair.second;
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice) {
std::vector<ValueType> auxiliaryStateToProbabilityMap(mecDecomposition.size());
// If the choice is not contained in the MEC itself, we have to add a similar distribution to the auxiliary state.
if (!choicesInMec.contains(choice)) {
if (choicesInMec.find(choice) == choicesInMec.end()) {
b.push_back(storm::utility::constantZero<ValueType>());
typename storm::storage::SparseMatrix<ValueType>::Rows row = transitionMatrix.getRow(choice);

6
src/models/AbstractDeterministicModel.h

@ -29,7 +29,7 @@ class AbstractDeterministicModel: public AbstractModel<T> {
*/
AbstractDeterministicModel(storm::storage::SparseMatrix<T> const& transitionMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling,
boost::optional<std::vector<T>> const& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractModel<T>(transitionMatrix, stateLabeling, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) {
}
@ -43,7 +43,7 @@ class AbstractDeterministicModel: public AbstractModel<T> {
*/
AbstractDeterministicModel(storm::storage::SparseMatrix<T>&& transitionMatrix, storm::models::AtomicPropositionsLabeling&& stateLabeling,
boost::optional<std::vector<T>>&& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractModel<T>(std::move(transitionMatrix), std::move(stateLabeling), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)) {
@ -109,7 +109,7 @@ class AbstractDeterministicModel: public AbstractModel<T> {
* @return void
*/
virtual void setStateIdBasedChoiceLabeling() override {
std::vector<storm::storage::VectorSet<uint_fast64_t>> newChoiceLabeling;
std::vector<boost::container::flat_set<uint_fast64_t>> newChoiceLabeling;
size_t stateCount = this->getNumberOfStates();
newChoiceLabeling.resize(stateCount);

13
src/models/AbstractModel.h

@ -3,14 +3,13 @@
#include <memory>
#include <vector>
#include <boost/container/flat_set.hpp>
#include <boost/optional.hpp>
#include "src/models/AtomicPropositionsLabeling.h"
#include "src/storage/BitVector.h"
#include "src/storage/SparseMatrix.h"
#include "src/storage/Scheduler.h"
#include "src/storage/VectorSet.h"
#include "src/storage/StronglyConnectedComponentDecomposition.h"
#include "src/utility/Hash.h"
@ -74,7 +73,7 @@ class AbstractModel: public std::enable_shared_from_this<AbstractModel<T>> {
*/
AbstractModel(storm::storage::SparseMatrix<T> const& transitionMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling,
boost::optional<std::vector<T>> const& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: transitionMatrix(transitionMatrix), stateLabeling(stateLabeling) {
if (optionalStateRewardVector) {
@ -99,7 +98,7 @@ class AbstractModel: public std::enable_shared_from_this<AbstractModel<T>> {
*/
AbstractModel(storm::storage::SparseMatrix<T>&& transitionMatrix, storm::models::AtomicPropositionsLabeling&& stateLabeling,
boost::optional<std::vector<T>>&& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling) :
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling) :
transitionMatrix(std::move(transitionMatrix)), choiceLabeling(std::move(optionalChoiceLabeling)),
stateLabeling(std::move(stateLabeling)), stateRewardVector(std::move(optionalStateRewardVector)),
transitionRewardMatrix(std::move(optionalTransitionRewardMatrix)) {
@ -167,7 +166,7 @@ class AbstractModel: public std::enable_shared_from_this<AbstractModel<T>> {
typename storm::storage::StateBlock const& block = decomposition[currentBlockIndex];
// Now, we determine the blocks which are reachable (in one step) from the current block.
storm::storage::VectorSet<uint_fast64_t> allTargetBlocks;
boost::container::flat_set<uint_fast64_t> allTargetBlocks;
for (auto state : block) {
for (auto const& transitionEntry : this->getRows(state)) {
uint_fast64_t targetBlock = stateToBlockMap[transitionEntry.first];
@ -281,7 +280,7 @@ class AbstractModel: public std::enable_shared_from_this<AbstractModel<T>> {
* Returns the labels for the choices of the model, if there are any.
* @return The labels for the choices of the model.
*/
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& getChoiceLabeling() const {
std::vector<boost::container::flat_set<uint_fast64_t>> const& getChoiceLabeling() const {
return choiceLabeling.get();
}
@ -469,7 +468,7 @@ protected:
storm::storage::SparseMatrix<T> transitionMatrix;
/*! The labeling that is associated with the choices for each state. */
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> choiceLabeling;
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> choiceLabeling;
private:
/*! The labeling of the states of the model. */
storm::models::AtomicPropositionsLabeling stateLabeling;

8
src/models/AbstractNondeterministicModel.h

@ -33,7 +33,7 @@ namespace storm {
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices,
boost::optional<std::vector<T>> const& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractModel<T>(transitionMatrix, stateLabeling, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) {
this->nondeterministicChoiceIndices = nondeterministicChoiceIndices;
}
@ -52,7 +52,7 @@ namespace storm {
std::vector<uint_fast64_t>&& nondeterministicChoiceIndices,
boost::optional<std::vector<T>>&& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractModel<T>(std::move(transitionMatrix), std::move(stateLabeling), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)), nondeterministicChoiceIndices(std::move(nondeterministicChoiceIndices)) {
@ -124,7 +124,7 @@ namespace storm {
*/
storm::storage::SparseMatrix<T> getBackwardTransitions() const {
uint_fast64_t numberOfStates = this->getNumberOfStates();
uint_fast64_t numberOfTransitions = this->getNumberOfTransitions();
uint_fast64_t numberOfTransitions = this->getTransitionMatrix().getEntryCount();
std::vector<uint_fast64_t> rowIndications(numberOfStates + 1);
std::vector<std::pair<uint_fast64_t, T>> columnsAndValues(numberOfTransitions, std::make_pair(0, storm::utility::constantZero<T>()));
@ -266,7 +266,7 @@ namespace storm {
* @return void
*/
virtual void setStateIdBasedChoiceLabeling() override {
std::vector<storm::storage::VectorSet<uint_fast64_t>> newChoiceLabeling;
std::vector<boost::container::flat_set<uint_fast64_t>> newChoiceLabeling;
size_t stateCount = this->getNumberOfStates();
size_t choiceCount = this->getNumberOfChoices();

6
src/models/Ctmc.h

@ -37,7 +37,7 @@ public:
*/
Ctmc(storm::storage::SparseMatrix<T> const& rateMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling,
boost::optional<std::vector<T>> const& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractDeterministicModel<T>(rateMatrix, stateLabeling, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) {
// Intentionally left empty.
}
@ -52,7 +52,7 @@ public:
*/
Ctmc(storm::storage::SparseMatrix<T>&& rateMatrix, storm::models::AtomicPropositionsLabeling&& stateLabeling,
boost::optional<std::vector<T>>&& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractDeterministicModel<T>(std::move(rateMatrix), std::move(stateLabeling), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)) {
@ -95,7 +95,7 @@ public:
nondeterministicChoiceIndices[this->getNumberOfStates()] = this->getNumberOfStates();
storm::storage::SparseMatrix<T> newTransitionMatrix = storm::utility::matrix::applyScheduler(this->getTransitionMatrix(), nondeterministicChoiceIndices, scheduler);
return std::shared_ptr<AbstractModel<T>>(new Ctmc(newTransitionMatrix, this->getStateLabeling(), this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>()));
return std::shared_ptr<AbstractModel<T>>(new Ctmc(newTransitionMatrix, this->getStateLabeling(), this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>()));
}
};

6
src/models/Ctmdp.h

@ -42,7 +42,7 @@ public:
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices,
boost::optional<std::vector<T>> const& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractNondeterministicModel<T>(probabilityMatrix, stateLabeling, nondeterministicChoiceIndices, optionalStateRewardVector, optionalTransitionRewardMatrix,
optionalChoiceLabeling) {
if (!this->checkValidityOfProbabilityMatrix()) {
@ -65,7 +65,7 @@ public:
std::vector<uint_fast64_t>&& nondeterministicChoiceIndices,
boost::optional<std::vector<T>>&& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractNondeterministicModel<T>(std::move(probabilityMatrix), std::move(stateLabeling), std::move(nondeterministicChoiceIndices), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix), std::move(optionalChoiceLabeling)) {
if (!this->checkValidityOfProbabilityMatrix()) {
@ -124,7 +124,7 @@ public:
nondeterministicChoiceIndices[state] = state;
}
nondeterministicChoiceIndices[this->getNumberOfStates()] = this->getNumberOfStates();
return std::shared_ptr<AbstractModel<T>>(new Ctmdp(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>()));
return std::shared_ptr<AbstractModel<T>>(new Ctmdp(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>()));
}
private:

14
src/models/Dtmc.h

@ -46,7 +46,7 @@ public:
*/
Dtmc(storm::storage::SparseMatrix<T> const& probabilityMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling,
boost::optional<std::vector<T>> const& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractDeterministicModel<T>(probabilityMatrix, stateLabeling, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) {
if (!this->checkValidityOfProbabilityMatrix()) {
LOG4CPLUS_ERROR(logger, "Probability matrix is invalid.");
@ -73,7 +73,7 @@ public:
*/
Dtmc(storm::storage::SparseMatrix<T>&& probabilityMatrix, storm::models::AtomicPropositionsLabeling&& stateLabeling,
boost::optional<std::vector<T>>&& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractDeterministicModel<T>(std::move(probabilityMatrix), std::move(stateLabeling), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)) {
@ -143,7 +143,7 @@ public:
storm::models::AtomicPropositionsLabeling(this->getStateLabeling(), subSysStates),
boost::optional<std::vector<T>>(),
boost::optional<storm::storage::SparseMatrix<T>>(),
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
}
// Does the vector have the right size?
@ -266,16 +266,16 @@ public:
newTransitionRewards = newTransRewardsBuilder.build();
}
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> newChoiceLabels;
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> newChoiceLabels;
if(this->hasChoiceLabeling()) {
// Get the choice label sets and move the needed values to the front.
std::vector<storm::storage::VectorSet<uint_fast64_t>> newChoice(this->getChoiceLabeling());
std::vector<boost::container::flat_set<uint_fast64_t>> newChoice(this->getChoiceLabeling());
storm::utility::vector::selectVectorValues(newChoice, subSysStates, newChoice);
// Throw away all values after the last state and set the choice label set for s_b as empty.
newChoice.resize(newStateCount);
newChoice[newStateCount - 1] = storm::storage::VectorSet<uint_fast64_t>();
newChoice[newStateCount - 1] = boost::container::flat_set<uint_fast64_t>();
newChoiceLabels = newChoice;
}
@ -293,7 +293,7 @@ public:
nondeterministicChoiceIndices[this->getNumberOfStates()] = this->getNumberOfStates();
storm::storage::SparseMatrix<T> newTransitionMatrix = storm::utility::matrix::applyScheduler(this->getTransitionMatrix(), nondeterministicChoiceIndices, scheduler);
return std::shared_ptr<AbstractModel<T>>(new Dtmc(newTransitionMatrix, this->getStateLabeling(), this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>()));
return std::shared_ptr<AbstractModel<T>>(new Dtmc(newTransitionMatrix, this->getStateLabeling(), this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>()));
}
private:

6
src/models/MarkovAutomaton.h

@ -26,7 +26,7 @@ namespace storm {
MarkovAutomaton(storm::storage::SparseMatrix<T> const& transitionMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling,
std::vector<uint_fast64_t>& nondeterministicChoiceIndices, storm::storage::BitVector const& markovianStates, std::vector<T> const& exitRates,
boost::optional<std::vector<T>> const& optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractNondeterministicModel<T>(transitionMatrix, stateLabeling, nondeterministicChoiceIndices, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling),
markovianStates(markovianStates), exitRates(exitRates), closed(false) {
@ -46,7 +46,7 @@ namespace storm {
storm::storage::BitVector const& markovianStates, std::vector<T> const& exitRates,
boost::optional<std::vector<T>>&& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
: AbstractNondeterministicModel<T>(std::move(transitionMatrix), std::move(stateLabeling), std::move(nondeterministicChoiceIndices), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)), markovianStates(markovianStates), exitRates(std::move(exitRates)), closed(false) {
@ -181,7 +181,7 @@ namespace storm {
}
nondeterministicChoiceIndices[this->getNumberOfStates()] = this->getNumberOfStates();
return std::shared_ptr<AbstractModel<T>>(new MarkovAutomaton(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, markovianStates, exitRates, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>()));
return std::shared_ptr<AbstractModel<T>>(new MarkovAutomaton(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, markovianStates, exitRates, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>()));
}
virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector<T> const* firstValue = nullptr, std::vector<T> const* secondValue = nullptr, std::vector<uint_fast64_t> const* stateColoring = nullptr, std::vector<std::string> const* colors = nullptr, std::vector<uint_fast64_t>* scheduler = nullptr, bool finalizeOutput = true) const override {

18
src/models/Mdp.h

@ -12,12 +12,12 @@
#include <iostream>
#include <memory>
#include <cstdlib>
#include <algorithm>
#include "AtomicPropositionsLabeling.h"
#include "src/storage/SparseMatrix.h"
#include "src/settings/Settings.h"
#include "src/models/AbstractNondeterministicModel.h"
#include "src/utility/set.h"
#include "src/utility/matrix.h"
namespace storm {
@ -50,7 +50,7 @@ public:
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices,
boost::optional<std::vector<T>> const& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>> const& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>> const& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>> const& optionalChoiceLabeling)
: AbstractNondeterministicModel<T>(transitionMatrix, stateLabeling, nondeterministicChoiceIndices, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) {
if (!this->checkValidityOfProbabilityMatrix()) {
LOG4CPLUS_ERROR(logger, "Probability matrix is invalid.");
@ -78,7 +78,7 @@ public:
std::vector<uint_fast64_t>&& nondeterministicChoiceIndices,
boost::optional<std::vector<T>>&& optionalStateRewardVector,
boost::optional<storm::storage::SparseMatrix<T>>&& optionalTransitionRewardMatrix,
boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>&& optionalChoiceLabeling)
boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>&& optionalChoiceLabeling)
// The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class
: AbstractNondeterministicModel<T>(std::move(transitionMatrix), std::move(stateLabeling), std::move(nondeterministicChoiceIndices), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix),
std::move(optionalChoiceLabeling)) {
@ -135,24 +135,24 @@ public:
* and which ones need to be ignored.
* @return A restricted version of the current MDP that only uses choice labels from the given set.
*/
Mdp<T> restrictChoiceLabels(storm::storage::VectorSet<uint_fast64_t> const& enabledChoiceLabels) const {
Mdp<T> restrictChoiceLabels(boost::container::flat_set<uint_fast64_t> const& enabledChoiceLabels) const {
// Only perform this operation if the given model has choice labels.
if (!this->hasChoiceLabeling()) {
throw storm::exceptions::InvalidArgumentException() << "Restriction to label set is impossible for unlabeled model.";
}
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = this->getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = this->getChoiceLabeling();
storm::storage::SparseMatrixBuilder<T> transitionMatrixBuilder;
std::vector<uint_fast64_t> nondeterministicChoiceIndices;
std::vector<storm::storage::VectorSet<uint_fast64_t>> newChoiceLabeling;
std::vector<boost::container::flat_set<uint_fast64_t>> newChoiceLabeling;
// Check for each choice of each state, whether the choice labels are fully contained in the given label set.
uint_fast64_t currentRow = 0;
for(uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) {
bool stateHasValidChoice = false;
for (uint_fast64_t choice = this->getNondeterministicChoiceIndices()[state]; choice < this->getNondeterministicChoiceIndices()[state + 1]; ++choice) {
bool choiceValid = choiceLabeling[choice].subsetOf(enabledChoiceLabels);
bool choiceValid = std::includes(enabledChoiceLabels.begin(), enabledChoiceLabels.end(), choiceLabeling[choice].begin(), choiceLabeling[choice].end());
// If the choice is valid, copy over all its elements.
if (choiceValid) {
@ -179,7 +179,7 @@ public:
nondeterministicChoiceIndices.push_back(currentRow);
Mdp<T> restrictedMdp(transitionMatrixBuilder.build(), storm::models::AtomicPropositionsLabeling(this->getStateLabeling()), std::move(nondeterministicChoiceIndices), this->hasStateRewards() ? boost::optional<std::vector<T>>(this->getStateRewardVector()) : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? boost::optional<storm::storage::SparseMatrix<T>>(this->getTransitionRewardMatrix()) : boost::optional<storm::storage::SparseMatrix<T>>(), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>(newChoiceLabeling));
Mdp<T> restrictedMdp(transitionMatrixBuilder.build(), storm::models::AtomicPropositionsLabeling(this->getStateLabeling()), std::move(nondeterministicChoiceIndices), this->hasStateRewards() ? boost::optional<std::vector<T>>(this->getStateRewardVector()) : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? boost::optional<storm::storage::SparseMatrix<T>>(this->getTransitionRewardMatrix()) : boost::optional<storm::storage::SparseMatrix<T>>(), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>(newChoiceLabeling));
return restrictedMdp;
}
@ -200,7 +200,7 @@ public:
nondeterministicChoiceIndices[state] = state;
}
nondeterministicChoiceIndices[this->getNumberOfStates()] = this->getNumberOfStates();
return std::shared_ptr<AbstractModel<T>>(new Mdp(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>()));
return std::shared_ptr<AbstractModel<T>>(new Mdp(newTransitionMatrix, this->getStateLabeling(), nondeterministicChoiceIndices, this->hasStateRewards() ? this->getStateRewardVector() : boost::optional<std::vector<T>>(), this->hasTransitionRewards() ? this->getTransitionRewardMatrix() : boost::optional<storm::storage::SparseMatrix<T>>(), this->hasChoiceLabeling() ? this->getChoiceLabeling() : boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>()));
}
private:

4
src/parser/DeterministicModelParser.cpp

@ -58,7 +58,7 @@ DeterministicModelParserResultContainer<double> parseDeterministicModel(std::str
storm::models::Dtmc<double> DeterministicModelParserAsDtmc(std::string const & transitionSystemFile, std::string const & labelingFile,
std::string const & stateRewardFile, std::string const & transitionRewardFile) {
DeterministicModelParserResultContainer<double> parserResult(std::move(parseDeterministicModel(transitionSystemFile, labelingFile, stateRewardFile, transitionRewardFile)));
return storm::models::Dtmc<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
return storm::models::Dtmc<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
}
/*!
@ -69,7 +69,7 @@ storm::models::Dtmc<double> DeterministicModelParserAsDtmc(std::string const & t
storm::models::Ctmc<double> DeterministicModelParserAsCtmc(std::string const & transitionSystemFile, std::string const & labelingFile,
std::string const & stateRewardFile, std::string const & transitionRewardFile) {
DeterministicModelParserResultContainer<double> parserResult(std::move(parseDeterministicModel(transitionSystemFile, labelingFile, stateRewardFile, transitionRewardFile)));
return storm::models::Ctmc<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
return storm::models::Ctmc<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
}
} /* namespace parser */

2
src/parser/MarkovAutomatonParser.cpp

@ -19,7 +19,7 @@ namespace storm {
throw storm::exceptions::WrongFormatException() << "Transition rewards are unsupported for Markov automata.";
}
storm::models::MarkovAutomaton<double> resultingAutomaton(std::move(transitionResult.transitionMatrix), std::move(resultLabeling), std::move(transitionResult.nondeterministicChoiceIndices), std::move(transitionResult.markovianStates), std::move(transitionResult.exitRates), std::move(stateRewards), boost::optional<storm::storage::SparseMatrix<double>>(), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
storm::models::MarkovAutomaton<double> resultingAutomaton(std::move(transitionResult.transitionMatrix), std::move(resultLabeling), std::move(transitionResult.nondeterministicChoiceIndices), std::move(transitionResult.markovianStates), std::move(transitionResult.exitRates), std::move(stateRewards), boost::optional<storm::storage::SparseMatrix<double>>(), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
return resultingAutomaton;
}

4
src/parser/NondeterministicModelParser.cpp

@ -58,7 +58,7 @@ NondeterministicModelParserResultContainer<double> parseNondeterministicModel(st
storm::models::Mdp<double> NondeterministicModelParserAsMdp(std::string const & transitionSystemFile, std::string const & labelingFile,
std::string const & stateRewardFile, std::string const & transitionRewardFile) {
NondeterministicModelParserResultContainer<double> parserResult = parseNondeterministicModel(transitionSystemFile, labelingFile, stateRewardFile, transitionRewardFile);
return storm::models::Mdp<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.rowMapping), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
return storm::models::Mdp<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.rowMapping), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
}
/*!
@ -69,7 +69,7 @@ storm::models::Mdp<double> NondeterministicModelParserAsMdp(std::string const &
storm::models::Ctmdp<double> NondeterministicModelParserAsCtmdp(std::string const & transitionSystemFile, std::string const & labelingFile,
std::string const & stateRewardFile, std::string const & transitionRewardFile) {
NondeterministicModelParserResultContainer<double> parserResult = parseNondeterministicModel(transitionSystemFile, labelingFile, stateRewardFile, transitionRewardFile);
return storm::models::Ctmdp<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.rowMapping), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<storm::storage::VectorSet<uint_fast64_t>>>());
return storm::models::Ctmdp<double>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(parserResult.rowMapping), std::move(parserResult.stateRewards), std::move(parserResult.transitionRewards), boost::optional<std::vector<boost::container::flat_set<uint_fast64_t>>>());
}
} /* namespace parser */

7
src/storage/BitVector.cpp

@ -1,5 +1,6 @@
#include "src/storage/BitVector.h"
#include <boost/container/flat_set.hpp>
#include "src/storage/BitVector.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/OutOfRangeException.h"
@ -496,7 +497,11 @@ namespace storm {
// All necessary explicit template instantiations.
template BitVector::BitVector(uint_fast64_t length, std::vector<uint_fast64_t>::iterator begin, std::vector<uint_fast64_t>::iterator end);
template BitVector::BitVector(uint_fast64_t length, std::vector<uint_fast64_t>::const_iterator begin, std::vector<uint_fast64_t>::const_iterator end);
template BitVector::BitVector(uint_fast64_t length, boost::container::flat_set<uint_fast64_t>::iterator begin, boost::container::flat_set<uint_fast64_t>::iterator end);
template BitVector::BitVector(uint_fast64_t length, boost::container::flat_set<uint_fast64_t>::const_iterator begin, boost::container::flat_set<uint_fast64_t>::const_iterator end);
template void BitVector::set(std::vector<uint_fast64_t>::iterator begin, std::vector<uint_fast64_t>::iterator end);
template void BitVector::set(std::vector<uint_fast64_t>::const_iterator begin, std::vector<uint_fast64_t>::const_iterator end);
template void BitVector::set(boost::container::flat_set<uint_fast64_t>::iterator begin, boost::container::flat_set<uint_fast64_t>::iterator end);
template void BitVector::set(boost::container::flat_set<uint_fast64_t>::const_iterator begin, boost::container::flat_set<uint_fast64_t>::const_iterator end);
}
}

15
src/storage/Decomposition.cpp

@ -66,16 +66,25 @@ namespace storm {
return blocks[index];
}
std::ostream& operator<<(std::ostream& out, StateBlock const& block) {
out << "{";
for (auto const& element : block) {
out << element << ", ";
}
out << "}";
return out;
}
template <typename BlockType>
std::ostream& operator<<(std::ostream& out, Decomposition<BlockType> const& decomposition) {
out << "{";
out << "[";
if (decomposition.size() > 0) {
for (uint_fast64_t blockIndex = 0; blockIndex < decomposition.size() - 1; ++blockIndex) {
out << decomposition.blocks[blockIndex] << ", ";
}
out << decomposition.blocks[decomposition.size() - 1];
out << decomposition.blocks.back();
}
out << "}";
out << "]";
return out;
}

7
src/storage/Decomposition.h

@ -2,12 +2,13 @@
#define STORM_STORAGE_DECOMPOSITION_H_
#include <vector>
#include "src/storage/VectorSet.h"
#include <boost/container/flat_set.hpp>
namespace storm {
namespace storage {
typedef storm::storage::VectorSet<uint_fast64_t> StateBlock;
typedef boost::container::flat_set<uint_fast64_t> StateBlock;
std::ostream& operator<<(std::ostream& out, StateBlock const& block);
/*!
* This class represents the decomposition of a model into blocks which are of the template type.

18
src/storage/LabeledValues.h

@ -9,7 +9,7 @@
#define STORM_STORAGE_LABELEDVALUES_H
#include <list>
#include "src/storage/VectorSet.h"
#include <boost/container/flat_set.hpp>
namespace storm {
namespace utility {
@ -45,8 +45,8 @@ namespace storm {
* @param value The value to add.
* @return A reference to the list of labels that is associated with the given value.
*/
storm::storage::VectorSet<uint_fast64_t>& addValue(ValueType value) {
valueLabelList.emplace_back(value, storm::storage::VectorSet<uint_fast64_t>());
boost::container::flat_set<uint_fast64_t>& addValue(ValueType value) {
valueLabelList.emplace_back(value, boost::container::flat_set<uint_fast64_t>());
return valueLabelList.back().second;
}
@ -57,7 +57,7 @@ namespace storm {
* @param labels The labels to associate with this value.
* @return A reference to the list of labels that is associated with the given value.
*/
storm::storage::VectorSet<uint_fast64_t>& addValue(ValueType value, storm::storage::VectorSet<uint_fast64_t> const& labels) {
boost::container::flat_set<uint_fast64_t>& addValue(ValueType value, boost::container::flat_set<uint_fast64_t> const& labels) {
valueLabelList.emplace_back(value, labels);
return valueLabelList.back().second;
}
@ -67,7 +67,7 @@ namespace storm {
*
* @return An iterator pointing to the first labeled probability.
*/
typename std::list<std::pair<ValueType, storm::storage::VectorSet<uint_fast64_t>>>::iterator begin() {
typename std::list<std::pair<ValueType, boost::container::flat_set<uint_fast64_t>>>::iterator begin() {
return valueLabelList.begin();
}
@ -76,7 +76,7 @@ namespace storm {
*
* @return An iterator pointing past the last labeled probability.
*/
typename std::list<std::pair<ValueType, storm::storage::VectorSet<uint_fast64_t>>>::const_iterator end() {
typename std::list<std::pair<ValueType, boost::container::flat_set<uint_fast64_t>>>::const_iterator end() {
return valueLabelList.end();
}
@ -85,7 +85,7 @@ namespace storm {
*
* @return A const iterator pointing to the first labeled probability.
*/
typename std::list<std::pair<ValueType, storm::storage::VectorSet<uint_fast64_t>>>::const_iterator begin() const {
typename std::list<std::pair<ValueType, boost::container::flat_set<uint_fast64_t>>>::const_iterator begin() const {
return valueLabelList.begin();
}
@ -94,7 +94,7 @@ namespace storm {
*
* @return A const iterator pointing past the last labeled probability.
*/
typename std::list<std::pair<ValueType, storm::storage::VectorSet<uint_fast64_t>>>::const_iterator end() const {
typename std::list<std::pair<ValueType, boost::container::flat_set<uint_fast64_t>>>::const_iterator end() const {
return valueLabelList.end();
}
@ -178,7 +178,7 @@ namespace storm {
private:
// The actual storage used to store the list of values and the associated labels.
std::list<std::pair<ValueType, storm::storage::VectorSet<uint_fast64_t>>> valueLabelList;
std::list<std::pair<ValueType, boost::container::flat_set<uint_fast64_t>>> valueLabelList;
/*!
* Returns the sum of the values.

14
src/storage/MaximalEndComponent.cpp

@ -4,6 +4,8 @@
namespace storm {
namespace storage {
std::ostream& operator<<(std::ostream& out, boost::container::flat_set<uint_fast64_t> const& block);
MaximalEndComponent::MaximalEndComponent() : stateToChoicesMapping() {
// Intentionally left empty.
}
@ -27,14 +29,14 @@ namespace storm {
}
void MaximalEndComponent::addState(uint_fast64_t state, std::vector<uint_fast64_t> const& choices) {
stateToChoicesMapping[state] = choices;
stateToChoicesMapping[state] = boost::container::flat_set<uint_fast64_t>(choices.begin(), choices.end());
}
void MaximalEndComponent::addState(uint_fast64_t state, std::vector<uint_fast64_t>&& choices) {
stateToChoicesMapping.emplace(state, choices);
stateToChoicesMapping.emplace(state, boost::container::flat_set<uint_fast64_t>(choices.begin(), choices.end()));
}
storm::storage::VectorSet<uint_fast64_t> const& MaximalEndComponent::getChoicesForState(uint_fast64_t state) const {
boost::container::flat_set<uint_fast64_t> const& MaximalEndComponent::getChoicesForState(uint_fast64_t state) const {
auto stateChoicePair = stateToChoicesMapping.find(state);
if (stateChoicePair == stateToChoicesMapping.end()) {
@ -80,10 +82,10 @@ namespace storm {
throw storm::exceptions::InvalidStateException() << "Cannot delete choice for state not contained in MEC.";
}
return stateChoicePair->second.contains(choice);
return stateChoicePair->second.find(choice) != stateChoicePair->second.end();
}
storm::storage::VectorSet<uint_fast64_t> MaximalEndComponent::getStateSet() const {
boost::container::flat_set<uint_fast64_t> MaximalEndComponent::getStateSet() const {
std::vector<uint_fast64_t> states;
states.reserve(stateToChoicesMapping.size());
@ -91,7 +93,7 @@ namespace storm {
states.push_back(stateChoicesPair.first);
}
return storm::storage::VectorSet<uint_fast64_t>(states);
return boost::container::flat_set<uint_fast64_t>(states.begin(), states.end());
}
std::ostream& operator<<(std::ostream& out, MaximalEndComponent const& component) {

13
src/storage/MaximalEndComponent.h

@ -2,8 +2,7 @@
#define STORM_STORAGE_MAXIMALENDCOMPONENT_H_
#include <unordered_map>
#include "src/storage/VectorSet.h"
#include <boost/container/flat_set.hpp>
namespace storm {
namespace storage {
@ -12,8 +11,8 @@ namespace storm {
*/
class MaximalEndComponent {
public:
typedef std::unordered_map<uint_fast64_t, storm::storage::VectorSet<uint_fast64_t>>::iterator iterator;
typedef std::unordered_map<uint_fast64_t, storm::storage::VectorSet<uint_fast64_t>>::const_iterator const_iterator;
typedef std::unordered_map<uint_fast64_t, boost::container::flat_set<uint_fast64_t>>::iterator iterator;
typedef std::unordered_map<uint_fast64_t, boost::container::flat_set<uint_fast64_t>>::const_iterator const_iterator;
/*!
* Creates an empty MEC.
@ -51,7 +50,7 @@ namespace storm {
* @param state The state for which to retrieve the choices.
* @return A list of choices of the state in the MEC.
*/
storm::storage::VectorSet<uint_fast64_t> const& getChoicesForState(uint_fast64_t state) const;
boost::container::flat_set<uint_fast64_t> const& getChoicesForState(uint_fast64_t state) const;
/*!
* Removes the given choice from the list of choices of the named state.
@ -90,7 +89,7 @@ namespace storm {
*
* @return The set of states contained in the MEC.
*/
storm::storage::VectorSet<uint_fast64_t> getStateSet() const;
boost::container::flat_set<uint_fast64_t> getStateSet() const;
iterator begin();
@ -104,7 +103,7 @@ namespace storm {
private:
// This stores the mapping from states contained in the MEC to the choices in this MEC.
std::unordered_map<uint_fast64_t, storm::storage::VectorSet<uint_fast64_t>> stateToChoicesMapping;
std::unordered_map<uint_fast64_t, boost::container::flat_set<uint_fast64_t>> stateToChoicesMapping;
};
}
}

12
src/storage/MaximalEndComponentDecomposition.cpp

@ -52,7 +52,7 @@ namespace storm {
// Initialize the maximal end component list to be the full state space.
std::list<StateBlock> endComponentStateSets;
endComponentStateSets.emplace_back(subsystem);
endComponentStateSets.emplace_back(subsystem.begin(), subsystem.end());
storm::storage::BitVector statesToCheck(model.getNumberOfStates());
@ -83,7 +83,7 @@ namespace storm {
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice) {
bool choiceContainedInMEC = true;
for (auto const& entry : transitionMatrix.getRow(choice)) {
if (!scc.contains(entry.first)) {
if (scc.find(entry.first) == scc.end()) {
choiceContainedInMEC = false;
break;
}
@ -103,13 +103,15 @@ namespace storm {
// Now erase the states that have no option to stay inside the MEC with all successors.
mecChanged |= !statesToRemove.empty();
scc.erase(storm::storage::VectorSet<uint_fast64_t>(statesToRemove.begin(), statesToRemove.end()));
for (uint_fast64_t state : statesToRemove) {
scc.erase(state);
}
// Now check which states should be reconsidered, because successors of them were removed.
statesToCheck.clear();
for (auto state : statesToRemove) {
for (auto const& entry : transitionMatrix.getRow(state)) {
if (scc.contains(entry.first)) {
if (scc.find(entry.first) != scc.end()) {
statesToCheck.set(entry.first);
}
}
@ -145,7 +147,7 @@ namespace storm {
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice) {
bool choiceContained = true;
for (auto const& entry : transitionMatrix.getRow(choice)) {
if (!mecStateSet.contains(entry.first)) {
if (mecStateSet.find(entry.first) == mecStateSet.end()) {
choiceContained = false;
break;
}

52
src/storage/SparseMatrix.cpp

@ -72,7 +72,7 @@ namespace storm {
} else {
columnsAndValues.emplace_back(column, value);
if (!columnCountSet) {
columnCount = column + 1;
columnCount = std::max(columnCount, column + 1);
}
if (!rowCountSet) {
rowCount = row + 1;
@ -661,7 +661,25 @@ namespace storm {
template<typename T>
void SparseMatrix<T>::multiplyWithVector(std::vector<T> const& vector, std::vector<T>& result) const {
#ifdef STORM_HAVE_INTELTBB
tbb::parallel_for(tbb::blocked_range<uint_fast64_t>(0, result.size()), TbbMatrixRowVectorScalarProduct<T>(*this, vector, result));
tbb::parallel_for(tbb::blocked_range<uint_fast64_t>(0, result.size()),
[&] (tbb::blocked_range<uint_fast64_t> const& range) {
uint_fast64_t startRow = range.begin();
uint_fast64_t endRow = range.end();
const_iterator it = this->begin(startRow);
const_iterator ite;
typename std::vector<uint_fast64_t>::const_iterator rowIterator = this->rowIndications.begin() + startRow;
typename std::vector<uint_fast64_t>::const_iterator rowIteratorEnd = this->rowIndications.begin() + endRow;
typename std::vector<T>::iterator resultIterator = result.begin() + startRow;
typename std::vector<T>::iterator resultIteratorEnd = result.begin() + endRow;
for (; resultIterator != resultIteratorEnd; ++rowIterator, ++resultIterator) {
*resultIterator = storm::utility::constantZero<T>();
for (ite = this->begin() + *(rowIterator + 1); it != ite; ++it) {
*resultIterator += it->second * vector[it->first];
}
}
});
#else
const_iterator it = this->begin();
const_iterator ite;
@ -832,36 +850,6 @@ namespace storm {
template class SparseMatrix<int>;
template std::ostream& operator<<(std::ostream& out, SparseMatrix<int> const& matrix);
#ifdef STORM_HAVE_INTELTBB
template <typename ValueType>
TbbMatrixRowVectorScalarProduct<ValueType>::TbbMatrixRowVectorScalarProduct(SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& vector, std::vector<ValueType>& result) : result(result), vector(vector), matrix(matrix) {
// Intentionally left empty.
}
template <typename ValueType>
void TbbMatrixRowVectorScalarProduct<ValueType>::operator() (tbb::blocked_range<uint_fast64_t> const& range) const {
uint_fast64_t startRow = range.begin();
uint_fast64_t endRow = range.end();
typename SparseMatrix<ValueType>::const_iterator it = matrix.begin(startRow);
typename SparseMatrix<ValueType>::const_iterator ite;
typename std::vector<uint_fast64_t>::const_iterator rowIterator = matrix.rowIndications.begin() + startRow;
typename std::vector<uint_fast64_t>::const_iterator rowIteratorEnd = matrix.rowIndications.begin() + endRow;
typename std::vector<ValueType>::iterator resultIterator = result.begin() + startRow;
typename std::vector<ValueType>::iterator resultIteratorEnd = result.begin() + endRow;
for (; resultIterator != resultIteratorEnd; ++rowIterator, ++resultIterator) {
*resultIterator = storm::utility::constantZero<ValueType>();
for (ite = matrix.begin() + *(rowIterator + 1); it != ite; ++it) {
*resultIterator += it->second * vector[it->first];
}
}
}
// Explicitly instantiate the helper class.
template class TbbMatrixRowVectorScalarProduct<double>;
#endif
} // namespace storage
} // namespace storm

49
src/storage/SparseMatrix.h

@ -34,12 +34,6 @@ namespace storm {
namespace storm {
namespace storage {
#ifdef STORM_HAVE_INTELTBB
// Forward declaration of the TBB Helper class.
template <typename ValueType>
class TbbMatrixRowVectorScalarProduct;
#endif
// Forward declare matrix class.
template<typename T> class SparseMatrix;
@ -159,12 +153,6 @@ namespace storm {
friend class storm::adapters::EigenAdapter;
friend class storm::adapters::StormAdapter;
#ifdef STORM_HAVE_INTELTBB
// Declare the helper class for TBB as friend.
template <typename ValueType>
friend class TbbMatrixRowVectorScalarProduct;
#endif
typedef typename std::vector<std::pair<uint_fast64_t, T>>::iterator iterator;
typedef typename std::vector<std::pair<uint_fast64_t, T> const>::const_iterator const_iterator;
@ -619,42 +607,7 @@ namespace storm {
// entry is not included anymore.
std::vector<uint_fast64_t> rowIndications;
};
#ifdef STORM_HAVE_INTELTBB
/*!
* This class is a helper class for parallel matrix-vector multiplication using Intel TBB.
*/
template <typename ValueType>
class TbbMatrixRowVectorScalarProduct {
public:
/*!
* Constructs a helper object with which TBB can perform parallel matrix-vector multiplication.
*
* @param matrix The matrix to use for the multiplication.
* @param vector The vector with which to multiply the matrix.
* @param result The vector that is supposed to hold the result after performing the multiplication.
*/
TbbMatrixRowVectorScalarProduct(SparseMatrix<ValueType> const& matrix, std::vector<ValueType> const& vector, std::vector<ValueType>& result);
/*!
* Performs the actual multiplication of a range of rows with the given vector.
*
* @param range The range of rows to multiply with the given vector.
*/
void operator() (tbb::blocked_range<uint_fast64_t> const& range) const;
private:
// The vector that is supposed to hold the result after performing the multiplication.
std::vector<ValueType>& result;
// The vector with which to multiply the matrix.
std::vector<ValueType> const& vector;
// The matrix to use for the multiplication.
SparseMatrix<ValueType> const& matrix;
};
#endif
} // namespace storage
} // namespace storm

3
src/storage/StronglyConnectedComponentDecomposition.h

@ -1,9 +1,10 @@
#ifndef STORM_STORAGE_STRONGLYCONNECTEDCOMPONENTDECOMPOSITION_H_
#define STORM_STORAGE_STRONGLYCONNECTEDCOMPONENTDECOMPOSITION_H_
#include <boost/container/flat_set.hpp>
#include "src/storage/SparseMatrix.h"
#include "src/storage/Decomposition.h"
#include "src/storage/VectorSet.h"
#include "src/storage/BitVector.h"

299
src/storage/VectorSet.cpp

@ -1,299 +0,0 @@
#include "src/storage/VectorSet.h"
#include "src/storage/BitVector.h"
namespace storm {
namespace storage {
template<typename ValueType>
VectorSet<ValueType>::VectorSet() : data(), dirty(false) {
// Intentionally left empty.
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(uint_fast64_t size) : data(), dirty(false) {
data.reserve(size);
}
template<typename ValueType>
template<typename InputIterator>
VectorSet<ValueType>::VectorSet(InputIterator first, InputIterator last) : dirty(true) {
this->data.insert(this->data.end(), first, last);
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(std::vector<ValueType> const& data) : data(data), dirty(true) {
ensureSet();
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(std::set<ValueType> const& data) : dirty(false) {
this->data.reserve(data.size());
for (auto const& element : data) {
this->data.push_back(element);
}
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(storm::storage::BitVector const& data) : dirty(false) {
this->data.reserve(data.getNumberOfSetBits());
for (auto element : data) {
this->data.push_back(element);
}
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(uint_fast64_t from, uint_fast64_t to) : dirty(false) {
data.reserve(to - from);
for (uint_fast64_t element = from; element < to; ++element) {
data.push_back(element);
}
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(VectorSet const& other) : dirty(false) {
other.ensureSet();
data = other.data;
}
template<typename ValueType>
VectorSet<ValueType>& VectorSet<ValueType>::operator=(VectorSet<ValueType> const& other) {
data = other.data;
dirty = other.dirty;
return *this;
}
template<typename ValueType>
VectorSet<ValueType>::VectorSet(VectorSet<ValueType>&& other) : data(std::move(other.data)), dirty(std::move(other.dirty)) {
// Intentionally left empty.
}
template<typename ValueType>
VectorSet<ValueType>& VectorSet<ValueType>::operator=(VectorSet&& other) {
data = std::move(other.data);
dirty = std::move(other.dirty);
return *this;
}
template<typename ValueType>
bool VectorSet<ValueType>::operator==(VectorSet<ValueType> const& other) const {
ensureSet();
if (this->size() != other.size()) return false;
return std::equal(data.begin(), data.end(), other.begin());
}
template<typename ValueType>
bool VectorSet<ValueType>::operator<(VectorSet<ValueType> const& other) const {
ensureSet();
if (this->size() < other.size()) return true;
if (this->size() > other.size()) return false;
for (auto it1 = this->begin(), it2 = other.begin(); it1 != this->end(); ++it1, ++it2) {
if (*it1 < *it2) return true;
if (*it1 > *it2) return false;
}
return false;
}
template<typename ValueType>
bool VectorSet<ValueType>::operator>(VectorSet<ValueType> const& other) const {
ensureSet();
if (this->size() > other.size()) return true;
if (this->size() < other.size()) return false;
for (auto it1 = this->begin(), it2 = other.begin(); it1 != this->end(); ++it1, ++it2) {
if (*it1 > *it2) return true;
if (*it1 < *it2) return false;
}
return false;
}
template<typename ValueType>
void VectorSet<ValueType>::ensureSet() const {
if (dirty) {
std::sort(data.begin(), data.end());
data.erase(std::unique(data.begin(), data.end()), data.end());
dirty = false;
}
}
template<typename ValueType>
bool VectorSet<ValueType>::contains(ValueType const& element) const {
ensureSet();
return std::binary_search(data.begin(), data.end(), element);
}
template<typename ValueType>
bool VectorSet<ValueType>::subsetOf(VectorSet<ValueType> const& other) const {
ensureSet();
other.ensureSet();
return std::includes(other.begin(), other.end(), data.begin(), data.end());
}
template<typename ValueType>
bool VectorSet<ValueType>::supersetOf(VectorSet<ValueType> const& other) const {
ensureSet();
return other.subsetOf(*this);
}
template<typename ValueType>
VectorSet<ValueType> VectorSet<ValueType>::intersect(VectorSet<ValueType> const& other) {
ensureSet();
other.ensureSet();
VectorSet result;
std::set_intersection(data.begin(), data.end(), other.begin(), other.end(), std::inserter(result.data, result.data.end()));
return result;
}
template<typename ValueType>
VectorSet<ValueType> VectorSet<ValueType>::join(VectorSet<ValueType> const& other) {
ensureSet();
other.ensureSet();
VectorSet result;
std::set_union(data.begin(), data.end(), other.begin(), other.end(), std::inserter(result.data, result.data.end()));
return result;
}
template<typename ValueType>
typename VectorSet<ValueType>::iterator VectorSet<ValueType>::begin() {
ensureSet();
return data.begin();
}
template<typename ValueType>
typename VectorSet<ValueType>::iterator VectorSet<ValueType>::end() {
ensureSet();
return data.end();
}
template<typename ValueType>
typename VectorSet<ValueType>::const_iterator VectorSet<ValueType>::begin() const {
ensureSet();
return data.begin();
}
template<typename ValueType>
typename VectorSet<ValueType>::const_iterator VectorSet<ValueType>::end() const {
ensureSet();
return data.end();
}
template<typename ValueType>
ValueType const& VectorSet<ValueType>::min() const {
if (this->size() == 0) {
throw storm::exceptions::InvalidStateException() << "Cannot retrieve minimum of empty set.";
}
ensureSet();
return data.front();
}
template<typename ValueType>
ValueType const& VectorSet<ValueType>::max() const {
if (this->size() == 0) {
throw storm::exceptions::InvalidStateException() << "Cannot retrieve minimum of empty set.";
}
ensureSet();
return data.back();
}
template<typename ValueType>
void VectorSet<ValueType>::insert(ValueType const& element) {
data.push_back(element);
dirty = true;
}
template<typename ValueType>
typename VectorSet<ValueType>::iterator VectorSet<ValueType>::insert(typename VectorSet<ValueType>::iterator pos, ValueType const& element) {
dirty = true;
return data.insert(pos, element);
}
template<typename ValueType>
void VectorSet<ValueType>::insert(VectorSet<ValueType> const& other) {
data.insert(data.end(), other.data.begin(), other.data.end());
dirty = true;
}
template<typename ValueType>
bool VectorSet<ValueType>::empty() const {
ensureSet();
return data.empty();
}
template<typename ValueType>
size_t VectorSet<ValueType>::size() const {
ensureSet();
return data.size();
}
template<typename ValueType>
void VectorSet<ValueType>::clear() {
data.clear();
dirty = false;
}
template<typename ValueType>
bool VectorSet<ValueType>::erase(ValueType const& element) {
ensureSet();
uint_fast64_t lowerBound = 0;
uint_fast64_t upperBound = data.size();
while (lowerBound != upperBound) {
uint_fast64_t currentPosition = lowerBound + (upperBound - lowerBound) / 2;
bool searchInLowerHalf = element < data[currentPosition];
if (searchInLowerHalf) {
upperBound = currentPosition;
} else {
bool searchInRightHalf = element > data[currentPosition];
if (searchInRightHalf) {
lowerBound = currentPosition + 1;
} else {
// At this point we have found the element.
data.erase(data.begin() + currentPosition);
return true;
}
}
}
return false;
}
template<typename ValueType>
void VectorSet<ValueType>::erase(VectorSet<ValueType> const& eraseSet) {
if (eraseSet.size() > 0 && this->size() > 0) {
ensureSet();
eraseSet.ensureSet();
for (typename std::vector<ValueType>::reverse_iterator delIt = eraseSet.data.rbegin(), setIt = data.rbegin(); delIt != eraseSet.data.rend() && setIt != eraseSet.data.rend(); ++delIt) {
while (setIt != eraseSet.data.rend() && *setIt > *delIt) {
++setIt;
}
if (setIt == data.rend()) break;
if (*setIt == *delIt) {
data.erase((setIt + 1).base());
++setIt;
}
}
}
}
template<typename ValueType>
std::ostream& operator<<(std::ostream& stream, VectorSet<ValueType> const& set) {
set.ensureSet();
stream << "VectorSet(" << set.size() << ") { ";
if (set.size() > 0) {
for (uint_fast64_t index = 0; index < set.size() - 1; ++index) {
stream << set.data[index] << ", ";
}
stream << set.data[set.size() - 1] << " }";
} else {
stream << "}";
}
return stream;
}
template class VectorSet<uint_fast64_t>;
template class VectorSet<VectorSet<uint_fast64_t>>;
template VectorSet<uint_fast64_t>::VectorSet(storm::storage::BitVector::const_iterator, storm::storage::BitVector::const_iterator);
template std::ostream& operator<<(std::ostream& stream, VectorSet<uint_fast64_t> const& set);
template std::ostream& operator<<(std::ostream& stream, VectorSet<VectorSet<uint_fast64_t>> const& set);
}
}

116
src/storage/VectorSet.h

@ -1,116 +0,0 @@
/*
* VectorSet.h
*
* Created on: 23.10.2013
* Author: Christian Dehnert
*/
#ifndef STORM_STORAGE_VECTORSET_H
#define STORM_STORAGE_VECTORSET_H
#include <cstdint>
#include <set>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include "src/exceptions/InvalidStateException.h"
namespace storm {
namespace storage {
// Forward declare bit vector class.
class BitVector;
template<typename ValueType>
class VectorSet {
public:
typedef ValueType* difference_type;
typedef ValueType value_type;
typedef ValueType* pointer;
typedef ValueType& reference;
typedef typename std::vector<ValueType>::iterator iterator;
typedef typename std::vector<ValueType>::const_iterator const_iterator;
VectorSet();
VectorSet(uint_fast64_t size);
template<typename InputIterator>
VectorSet(InputIterator first, InputIterator last);
VectorSet(std::vector<ValueType> const& data);
VectorSet(std::set<ValueType> const& data);
VectorSet(BitVector const& data);
VectorSet(uint_fast64_t from, uint_fast64_t to);
VectorSet(VectorSet const& other);
VectorSet& operator=(VectorSet const& other);
VectorSet(VectorSet&& other);
VectorSet& operator=(VectorSet&& other);
bool operator==(VectorSet const& other) const;
bool operator<(VectorSet const& other) const;
bool operator>(VectorSet const& other) const;
void ensureSet() const;
bool contains(ValueType const& element) const;
bool subsetOf(VectorSet const& other) const;
bool supersetOf(VectorSet const& other) const;
VectorSet intersect(VectorSet const& other);
VectorSet join(VectorSet const& other);
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
ValueType const& min() const;
ValueType const& max() const;
void insert(ValueType const& element);
// FIXME: As soon as gcc provides an erase(const_iterator) method, change this iterator back to a const_iterator.
iterator insert(iterator pos, ValueType const& element);
void insert(VectorSet<ValueType> const& other);
bool empty() const;
size_t size() const;
void clear();
bool erase(ValueType const& element);
void erase(VectorSet const& eraseSet);
template<typename ValueTypePrime>
friend std::ostream& operator<< (std::ostream& stream, VectorSet<ValueTypePrime> const& set);
private:
mutable std::vector<ValueType> data;
mutable bool dirty;
};
}
}
#endif /* STORM_STORAGE_VECTORSET_H */

10
src/utility/IRUtility.h

@ -160,7 +160,7 @@ namespace storm {
*
* @param labelSet The label set to associate with this choice.
*/
void addChoiceLabels(storm::storage::VectorSet<uint_fast64_t> const& labelSet) {
void addChoiceLabels(boost::container::flat_set<uint_fast64_t> const& labelSet) {
for (uint_fast64_t label : labelSet) {
addChoiceLabel(label);
}
@ -171,7 +171,7 @@ namespace storm {
*
* @return The set of labels associated with this choice.
*/
storm::storage::VectorSet<uint_fast64_t> const& getChoiceLabels() const {
boost::container::flat_set<uint_fast64_t> const& getChoiceLabels() const {
return choiceLabels;
}
@ -224,7 +224,7 @@ namespace storm {
std::string actionLabel;
// The labels that are associated with this choice.
storm::storage::VectorSet<uint_fast64_t> choiceLabels;
boost::container::flat_set<uint_fast64_t> choiceLabels;
};
/*!
@ -238,7 +238,7 @@ namespace storm {
* is ignored by this particular function but not by the overloaded functions.
*/
template<typename ValueType>
void addProbabilityToChoice(Choice<ValueType>& choice, uint_fast64_t state, ValueType probability, storm::storage::VectorSet<uint_fast64_t> const& labels) {
void addProbabilityToChoice(Choice<ValueType>& choice, uint_fast64_t state, ValueType probability, boost::container::flat_set<uint_fast64_t> const& labels) {
choice.getOrAddEntry(state) += probability;
}
@ -252,7 +252,7 @@ namespace storm {
* @param labels A set of labels that is supposed to be associated with this state and probability.
*/
template<typename ValueType>
void addProbabilityToChoice(Choice<storm::storage::LabeledValues<ValueType>>& choice, uint_fast64_t state, ValueType probability, storm::storage::VectorSet<uint_fast64_t> const& labels) {
void addProbabilityToChoice(Choice<storm::storage::LabeledValues<ValueType>>& choice, uint_fast64_t state, ValueType probability, boost::container::flat_set<uint_fast64_t> const& labels) {
auto& labeledEntry = choice.getOrAddEntry(state);
labeledEntry.addValue(probability, labels);
}

20
src/utility/counterexamples.h

@ -20,20 +20,20 @@ namespace storm {
* @return The set of action labels that is visited on all paths from any state to a target state.
*/
template <typename T>
std::vector<storm::storage::VectorSet<uint_fast64_t>> getGuaranteedLabelSets(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& psiStates, storm::storage::VectorSet<uint_fast64_t> const& relevantLabels) {
std::vector<boost::container::flat_set<uint_fast64_t>> getGuaranteedLabelSets(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& psiStates, boost::container::flat_set<uint_fast64_t> const& relevantLabels) {
// Get some data from the MDP for convenient access.
storm::storage::SparseMatrix<T> const& transitionMatrix = labeledMdp.getTransitionMatrix();
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = labeledMdp.getNondeterministicChoiceIndices();
std::vector<storm::storage::VectorSet<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
std::vector<boost::container::flat_set<uint_fast64_t>> const& choiceLabeling = labeledMdp.getChoiceLabeling();
storm::storage::SparseMatrix<T> backwardTransitions = labeledMdp.getBackwardTransitions();
// Now we compute the set of labels that is present on all paths from the initial to the target states.
std::vector<storm::storage::VectorSet<uint_fast64_t>> analysisInformation(labeledMdp.getNumberOfStates(), relevantLabels);
std::vector<boost::container::flat_set<uint_fast64_t>> analysisInformation(labeledMdp.getNumberOfStates(), relevantLabels);
std::queue<std::pair<uint_fast64_t, uint_fast64_t>> worklist;
// Initially, put all predecessors of target states in the worklist and empty the analysis information them.
for (auto state : psiStates) {
analysisInformation[state] = std::set<uint_fast64_t>();
analysisInformation[state] = boost::container::flat_set<uint_fast64_t>();
for (auto& predecessorEntry : backwardTransitions.getRow(state)) {
if (predecessorEntry.first != state) {
worklist.push(std::make_pair(predecessorEntry.first, state));
@ -53,7 +53,7 @@ namespace storm {
// Iterate over the successor states for all choices and compute new analysis information.
for (uint_fast64_t currentChoice = nondeterministicChoiceIndices[currentState]; currentChoice < nondeterministicChoiceIndices[currentState + 1]; ++currentChoice) {
storm::storage::VectorSet<uint_fast64_t> tmpIntersection;
boost::container::flat_set<uint_fast64_t> tmpIntersection;
bool choiceTargetsTargetState = false;
for (auto& entry : transitionMatrix.getRow(currentChoice)) {
@ -96,13 +96,13 @@ namespace storm {
* @return The set of action labels that is visited on all paths from an initial state to a target state.
*/
template <typename T>
storm::storage::VectorSet<uint_fast64_t> getGuaranteedLabelSet(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& psiStates, storm::storage::VectorSet<uint_fast64_t> const& relevantLabels) {
std::vector<storm::storage::VectorSet<uint_fast64_t>> guaranteedLabels = getGuaranteedLabelSets(labeledMdp, psiStates, relevantLabels);
boost::container::flat_set<uint_fast64_t> getGuaranteedLabelSet(storm::models::Mdp<T> const& labeledMdp, storm::storage::BitVector const& psiStates, boost::container::flat_set<uint_fast64_t> const& relevantLabels) {
std::vector<boost::container::flat_set<uint_fast64_t>> guaranteedLabels = getGuaranteedLabelSets(labeledMdp, psiStates, relevantLabels);
storm::storage::VectorSet<uint_fast64_t> knownLabels(relevantLabels);
storm::storage::VectorSet<uint_fast64_t> tempIntersection;
boost::container::flat_set<uint_fast64_t> knownLabels(relevantLabels);
boost::container::flat_set<uint_fast64_t> tempIntersection;
for (auto initialState : labeledMdp.getInitialStates()) {
tempIntersection = knownLabels.intersect(guaranteedLabels[initialState]);
std::set_intersection(knownLabels.begin(), knownLabels.end(), guaranteedLabels[initialState].begin(), guaranteedLabels[initialState].end(), std::inserter(tempIntersection, tempIntersection.end()));
std::swap(knownLabels, tempIntersection);
}

53
src/utility/set.h

@ -1,53 +0,0 @@
/*
* set.h
*
* Created on: 06.12.2012
* Author: Christian Dehnert
*/
#ifndef STORM_UTILITY_SET_H_
#define STORM_UTILITY_SET_H_
#include <set>
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
namespace storm {
namespace utility {
namespace set {
template<typename T, typename Compare>
bool isSubsetOf(std::set<T, Compare> const& set1, std::set<T, Compare> const& set2) {
// First, get a comparator object.
typename std::set<T, Compare>::key_compare comparator = set1.key_comp();
for (typename std::set<T, Compare>::const_iterator it1 = set1.begin(), it2 = set2.begin(); it1 != set1.end() && it2 != set2.end(); ++it1) {
// If the value in set1 is smaller than the value in set2, set1 is not a subset of set2.
if (comparator(*it1, *it2)) {
return false;
}
// If the value in the second set is smaller, we need to move the iterator until the comparison is false.
while(comparator(*it2, *it1) && it2 != set2.end()) {
++it2;
}
// If we have reached the end of set2 or the element we found is actually larger than the one in set1
// we know that the subset property is violated.
if (it2 == set2.end() || comparator(*it1, *it2)) {
return false;
}
// Otherwise, we have found an equivalent element and can continue with the next one.
}
return true;
}
} // namespace set
} // namespace utility
} // namespace storm
#endif /* STORM_UTILITY_SET_H_ */

6
test/functional/storage/SparseMatrixTest.cpp

@ -1,6 +1,6 @@
#include "gtest/gtest.h"
#include "src/storage/SparseMatrix.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/InvalidStateException.h"
#include "src/exceptions/OutOfRangeException.h"
TEST(SparseMatrixBuilder, CreationWithDimensions) {
@ -54,10 +54,10 @@ TEST(SparseMatrixBuilder, CreationWithNumberOfRows) {
TEST(SparseMatrixBuilder, CreationWithoutDimensions) {
storm::storage::SparseMatrixBuilder<double> matrixBuilder;
ASSERT_NO_THROW(matrixBuilder.addNextValue(0, 1, 1.0));
ASSERT_NO_THROW(matrixBuilder.addNextValue(0, 2, 1.2));
ASSERT_NO_THROW(matrixBuilder.addNextValue(0, 3, 1.2));
ASSERT_NO_THROW(matrixBuilder.addNextValue(1, 0, 0.5));
ASSERT_NO_THROW(matrixBuilder.addNextValue(1, 1, 0.7));
ASSERT_NO_THROW(matrixBuilder.addNextValue(1, 3, 0.2));
ASSERT_NO_THROW(matrixBuilder.addNextValue(1, 2, 0.2));
storm::storage::SparseMatrix<double> matrix;
ASSERT_NO_THROW(matrix = matrixBuilder.build());

Loading…
Cancel
Save