Browse Source
Fixed some issues for state elimination when the provided row is not equal to the column (as possible for mdps).
tempestpy_adaptions
Fixed some issues for state elimination when the provided row is not equal to the column (as possible for mdps).
tempestpy_adaptions
TimQu
8 years ago
5 changed files with 91 additions and 21 deletions
-
8src/storm/solver/stateelimination/EliminatorBase.cpp
-
39src/storm/solver/stateelimination/NondeterministicModelStateEliminator.cpp
-
28src/storm/solver/stateelimination/NondeterministicModelStateEliminator.h
-
9src/storm/solver/stateelimination/StateEliminator.cpp
-
28src/storm/transformer/SparseParametricModelSimplifier.cpp
@ -0,0 +1,39 @@ |
|||
#include "storm/solver/stateelimination/NondeterministicModelStateEliminator.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
#include "storm/utility/constants.h"
|
|||
|
|||
#include "storm/exceptions/InvalidArgumentException.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
namespace stateelimination { |
|||
|
|||
template<typename ValueType> |
|||
NondeterministicModelStateEliminator<ValueType>::NondeterministicModelStateEliminator(storm::storage::FlexibleSparseMatrix<ValueType>& transitionMatrix, storm::storage::FlexibleSparseMatrix<ValueType>& backwardTransitions, std::vector<ValueType>& rowValues) |
|||
: StateEliminator<ValueType>(transitionMatrix, backwardTransitions), rowValues(rowValues) { |
|||
|
|||
STORM_LOG_THROW(transitionMatrix.getRowCount() == backwardTransitions.getColumnCount() && transitionMatrix.getColumnCount() == backwardTransitions.getRowCount(), storm::exceptions::InvalidArgumentException, "Invalid matrix dimensions of forward/backwards transition matrices."); |
|||
STORM_LOG_THROW(rowValues.size() == transitionMatrix.getRowCount(), storm::exceptions::InvalidArgumentException, "Invalid size of row value vector"); |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NondeterministicModelStateEliminator<ValueType>::updateValue(storm::storage::sparse::state_type const& row, ValueType const& loopProbability) { |
|||
rowValues[row] = storm::utility::simplify((ValueType) (loopProbability * rowValues[row])); |
|||
} |
|||
|
|||
template<typename ValueType> |
|||
void NondeterministicModelStateEliminator<ValueType>::updatePredecessor(storm::storage::sparse::state_type const& predecessorRow, ValueType const& probability, storm::storage::sparse::state_type const& row) { |
|||
rowValues[predecessorRow] = storm::utility::simplify((ValueType) (rowValues[predecessorRow] + storm::utility::simplify((ValueType) (probability * rowValues[row])))); |
|||
} |
|||
|
|||
template class NondeterministicModelStateEliminator<double>; |
|||
|
|||
#ifdef STORM_HAVE_CARL
|
|||
template class NondeterministicModelStateEliminator<storm::RationalNumber>; |
|||
template class NondeterministicModelStateEliminator<storm::RationalFunction>; |
|||
#endif
|
|||
} // namespace stateelimination
|
|||
} // namespace storage
|
|||
} // namespace storm
|
@ -0,0 +1,28 @@ |
|||
#ifndef STORM_SOLVER_STATEELIMINATION_NONDETERMINISTICMODELSTATEELIMINATOR_H_ |
|||
#define STORM_SOLVER_STATEELIMINATION_NONDETERMINISTICMODELSTATEELIMINATOR_H_ |
|||
|
|||
#include "storm/solver/stateelimination/StateEliminator.h" |
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
namespace stateelimination { |
|||
|
|||
template<typename ValueType> |
|||
class NondeterministicModelStateEliminator : public StateEliminator<ValueType> { |
|||
public: |
|||
|
|||
NondeterministicModelStateEliminator(storm::storage::FlexibleSparseMatrix<ValueType>& transitionMatrix, storm::storage::FlexibleSparseMatrix<ValueType>& backwardTransitions, std::vector<ValueType>& rowValues); |
|||
|
|||
// Instantiaton of virtual methods. |
|||
virtual void updateValue(storm::storage::sparse::state_type const& row, ValueType const& loopProbability) override; |
|||
virtual void updatePredecessor(storm::storage::sparse::state_type const& predecessorRow, ValueType const& probability, storm::storage::sparse::state_type const& row) override; |
|||
|
|||
protected: |
|||
std::vector<ValueType>& rowValues; |
|||
}; |
|||
|
|||
} // namespace stateelimination |
|||
} // namespace storage |
|||
} // namespace storm |
|||
|
|||
#endif // STORM_SOLVER_STATEELIMINATION_NONDETERMINISTICMODELSTATEELIMINATOR_H_ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue