Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
matrix.h
Go to the documentation of this file.
1#ifndef STORM_UTILITY_MATRIX_H_
2#define STORM_UTILITY_MATRIX_H_
3
7
8namespace storm {
9namespace utility {
10namespace matrix {
11
20template<typename T>
22 storm::storage::SparseMatrixBuilder<T> matrixBuilder(transitionMatrix.getRowGroupCount(), transitionMatrix.getColumnCount());
23
24 for (uint_fast64_t state = 0; state < transitionMatrix.getRowGroupCount(); ++state) {
25 if (scheduler.isChoiceDefined(state)) {
26 // Check whether the choice is valid for this state.
27 uint_fast64_t choice = transitionMatrix.getRowGroupIndices()[state] + scheduler.getChoice(state);
28 if (choice >= transitionMatrix.getRowGroupIndices()[state + 1]) {
29 throw storm::exceptions::InvalidStateException() << "Scheduler defines illegal choice " << choice << " for state " << state << ".";
30 }
31
32 // If a valid choice for this state is defined, we copy over the corresponding entries.
33 typename storm::storage::SparseMatrix<T>::const_rows selectedRow = transitionMatrix.getRow(choice);
34 for (auto const& entry : selectedRow) {
35 matrixBuilder.addNextValue(state, entry.getColumn(), entry.getValue());
36 }
37 } else {
38 // If no valid choice for the state is defined, we insert a self-loop.
39 matrixBuilder.addNextValue(state, state, storm::utility::one<T>());
40 }
41 }
42
43 return matrixBuilder.build();
44}
45} // namespace matrix
46} // namespace utility
47} // namespace storm
48
49#endif /* STORM_UTILITY_MATRIX_H_ */
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
SchedulerChoice< ValueType > const & getChoice(uint_fast64_t modelState, uint_fast64_t memoryState=0) const
Gets the choice defined by the scheduler for the given model and memory state.
Definition Scheduler.cpp:86
This class represents a number of consecutive rows of the matrix.
A class that can be used to build a sparse matrix by adding value by value.
void addNextValue(index_type row, index_type column, value_type const &value)
Sets the matrix entry at the given row and column to the given value.
SparseMatrix< value_type > build(index_type overriddenRowCount=0, index_type overriddenColumnCount=0, index_type overriddenRowGroupCount=0)
A class that holds a possibly non-square matrix in the compressed row storage format.
const_rows getRow(index_type row) const
Returns an object representing the given row.
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
index_type getColumnCount() const
Returns the number of columns of the matrix.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
storm::storage::SparseMatrix< T > applyScheduler(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::Scheduler const &scheduler)
Applies the given scheduler to the given transition matrix.
Definition matrix.h:21
LabParser.cpp.
Definition cli.cpp:18