mCRL2
Loading...
Searching...
No Matches
mcrl2::lts::probabilistic_state< STATE, PROBABILITY > Class Template Reference

A class that contains a probabilistic state. More...

#include <probabilistic_state.h>

Public Types

using state_probability_pair = typename lps::state_probability_pair< STATE, PROBABILITY >
 
using state_t = STATE
 
using probability_t = PROBABILITY
 
using iterator = typename std::vector< state_probability_pair >::iterator
 
using const_iterator = typename std::vector< state_probability_pair >::const_iterator
 
using reverse_iterator = typename std::vector< state_probability_pair >::reverse_iterator
 
using const_reverse_iterator = typename std::vector< state_probability_pair >::const_reverse_iterator
 

Public Member Functions

 probabilistic_state ()
 Default constructor.
 
 probabilistic_state (const STATE &s)
 Constructor of a probabilistic state from a non probabilistic state.
 
 probabilistic_state (const probabilistic_state &other)
 Copy constructor.
 
probabilistic_state & operator= (const probabilistic_state &other)
 Copy assignment constructor.
 
 probabilistic_state (probabilistic_state &&other)=default
 Move constructor.
 
probabilistic_state & operator= (probabilistic_state &&other)=default
 Move assignment operator.
 
template<class STATE_PROBABILITY_PAIR_ITERATOR >
 probabilistic_state (const STATE_PROBABILITY_PAIR_ITERATOR begin, const STATE_PROBABILITY_PAIR_ITERATOR end)
 Creates a probabilistic state on the basis of state_probability_pairs.
 
bool operator== (const probabilistic_state &other) const
 Standard equality operator.
 
bool operator!= (const probabilistic_state &other) const
 Standard equality operator.
 
void swap (probabilistic_state &other) noexcept
 Swap this probabilistic state.
 
void construct_internal_vector_representation ()
 Guarantee that this probabilistic state is internally stored as a vector, such that begin/end, cbegin/cend and size are properly defined.
 
void set (const STATE &s)
 Set this probabilistic state to a single state with probability one.
 
STATE get () const
 Get a probabilistic state if is is simple, i.e., consists of a single state.
 
void add (const STATE &s, const PROBABILITY &p)
 Add a state with a probability to the probabilistic state.
 
void shrink_to_fit ()
 If a probabilistic state is ready, shrinking it to minimal size might be useful to reduce its memory usage. A requirement is that the sum of the probabilities must be one.
 
std::size_t size () const
 Gets the number of probabilistic states in the vector representation of this state. If the state is stored as a simple number this size returns 0. So, 0 means that there is one state, which should then be obtained using get(). If the size is larger than 0 the state is stored in a vector, and it must be accessed throught the iterators begin() and n.
 
void clear ()
 Makes the probabilistic state empty.
 
STATE maximal_state () const
 Provides the maximal state index in a probabilistic state.
 
const_iterator begin () const
 Gets an iterator over pairs of state and probability. This can only be used when the state is stored internally as a vector.

 
const_iterator end () const
 Gets the end iterator over pairs of state and probability.
 
iterator begin ()
 Gets an iterator over pairs of state and probability. This can only be used if the state is internally stored as a vector.
 
iterator end ()
 Gets the end iterator over pairs of state and probability.
 
const_reverse_iterator rbegin () const
 Gets a reverse iterator over pairs of state and probability. This can only be used when the state is stored internally as a vector.

 
const_reverse_iterator rend () const
 Gets the reverse end iterator over pairs of state and probability.
 
reverse_iterator rbegin ()
 Gets a reverse iterator over pairs of state and probability. This can only be used if the state is internally stored as a vector.
 
reverse_iterator rend ()
 Gets the reverse end iterator over pairs of state and probability.
 

Protected Attributes

STATE m_single_state
 
std::vector< state_probability_pair > m_probabilistic_state
 

Detailed Description

template<class STATE, class PROBABILITY>
class mcrl2::lts::probabilistic_state< STATE, PROBABILITY >

A class that contains a probabilistic state.

A probabilistic state is essentially a sequence of pairs of a state and a probability. The probability indicates the likelyhood with which that particular state can be reached. The sum of all probabilities in a probabilistic state is one. Internally, it is either stored as single state, or as a vector of states. When using a probabilistic state, a user should be aware which of the two internal representations are used. After calling "construct_internal_vector_representation" it is guaranteed that the state is stored as a vector, and iterators over begin/end, and cbegin/cend can be used.

Definition at line 45 of file probabilistic_state.h.

Member Typedef Documentation

◆ const_iterator

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::const_iterator = typename std::vector<state_probability_pair>::const_iterator

Definition at line 55 of file probabilistic_state.h.

◆ const_reverse_iterator

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::const_reverse_iterator = typename std::vector<state_probability_pair>::const_reverse_iterator

Definition at line 57 of file probabilistic_state.h.

◆ iterator

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::iterator = typename std::vector<state_probability_pair>::iterator

Definition at line 54 of file probabilistic_state.h.

◆ probability_t

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probability_t = PROBABILITY

Definition at line 53 of file probabilistic_state.h.

◆ reverse_iterator

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::reverse_iterator = typename std::vector<state_probability_pair>::reverse_iterator

Definition at line 56 of file probabilistic_state.h.

◆ state_probability_pair

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::state_probability_pair = typename lps::state_probability_pair<STATE, PROBABILITY>

Definition at line 51 of file probabilistic_state.h.

◆ state_t

template<class STATE , class PROBABILITY >
using mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::state_t = STATE

Definition at line 52 of file probabilistic_state.h.

Constructor & Destructor Documentation

◆ probabilistic_state() [1/5]

template<class STATE , class PROBABILITY >
mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probabilistic_state ( )
inline

Default constructor.

Definition at line 70 of file probabilistic_state.h.

◆ probabilistic_state() [2/5]

template<class STATE , class PROBABILITY >
mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probabilistic_state ( const STATE &  s)
inlineexplicit

Constructor of a probabilistic state from a non probabilistic state.

Parameters
[in]sA state.

Definition at line 78 of file probabilistic_state.h.

◆ probabilistic_state() [3/5]

template<class STATE , class PROBABILITY >
mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probabilistic_state ( const probabilistic_state< STATE, PROBABILITY > &  other)
inline

Copy constructor.

Definition at line 84 of file probabilistic_state.h.

◆ probabilistic_state() [4/5]

template<class STATE , class PROBABILITY >
mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probabilistic_state ( probabilistic_state< STATE, PROBABILITY > &&  other)
default

Move constructor.

◆ probabilistic_state() [5/5]

template<class STATE , class PROBABILITY >
template<class STATE_PROBABILITY_PAIR_ITERATOR >
mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::probabilistic_state ( const STATE_PROBABILITY_PAIR_ITERATOR  begin,
const STATE_PROBABILITY_PAIR_ITERATOR  end 
)
inline

Creates a probabilistic state on the basis of state_probability_pairs.

Parameters
[in]beginIterator to the first state_probability_pair.
[in]endIterator to the last state_probability_pair.

Definition at line 110 of file probabilistic_state.h.

Member Function Documentation

◆ add()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::add ( const STATE &  s,
const PROBABILITY &  p 
)
inline

Add a state with a probability to the probabilistic state.

Parameters
[in]sThe state to be added.
[in]pThe probability of this state.

Definition at line 214 of file probabilistic_state.h.

◆ begin() [1/2]

template<class STATE , class PROBABILITY >
iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::begin ( )
inline

Gets an iterator over pairs of state and probability. This can only be used if the state is internally stored as a vector.

Returns
The iterator pointing at the first state probability pair.

Definition at line 299 of file probabilistic_state.h.

◆ begin() [2/2]

template<class STATE , class PROBABILITY >
const_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::begin ( ) const
inline

Gets an iterator over pairs of state and probability. This can only be used when the state is stored internally as a vector.

Returns
The iterator pointing at the first state probability pair.

Definition at line 285 of file probabilistic_state.h.

◆ clear()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::clear ( )
inline

Makes the probabilistic state empty.

Definition at line 254 of file probabilistic_state.h.

◆ construct_internal_vector_representation()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::construct_internal_vector_representation ( )
inline

Guarantee that this probabilistic state is internally stored as a vector, such that begin/end, cbegin/cend and size are properly defined.

Definition at line 172 of file probabilistic_state.h.

◆ end() [1/2]

template<class STATE , class PROBABILITY >
iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::end ( )
inline

Gets the end iterator over pairs of state and probability.

Returns
The iterator pointing beyond the last state probability pair in a probabilistic state.

Definition at line 306 of file probabilistic_state.h.

◆ end() [2/2]

template<class STATE , class PROBABILITY >
const_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::end ( ) const
inline

Gets the end iterator over pairs of state and probability.

Returns
The iterator pointing beyond the last state probability pair in a probabilistic state.

Definition at line 292 of file probabilistic_state.h.

◆ get()

template<class STATE , class PROBABILITY >
STATE mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::get ( ) const
inline

Get a probabilistic state if is is simple, i.e., consists of a single state.

It is assumed that the given state probability pair does not have any element.

Definition at line 195 of file probabilistic_state.h.

◆ maximal_state()

template<class STATE , class PROBABILITY >
STATE mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::maximal_state ( ) const
inline

Provides the maximal state index in a probabilistic state.

Returns
A STATE with the maximal index, ordered using >.

Definition at line 262 of file probabilistic_state.h.

◆ operator!=()

template<class STATE , class PROBABILITY >
bool mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::operator!= ( const probabilistic_state< STATE, PROBABILITY > &  other) const
inline

Standard equality operator.

Returns
Returns true iff the probabilistic states are equal.

Definition at line 156 of file probabilistic_state.h.

◆ operator=() [1/2]

template<class STATE , class PROBABILITY >
probabilistic_state & mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::operator= ( const probabilistic_state< STATE, PROBABILITY > &  other)
inline

Copy assignment constructor.

Definition at line 92 of file probabilistic_state.h.

◆ operator=() [2/2]

template<class STATE , class PROBABILITY >
probabilistic_state & mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::operator= ( probabilistic_state< STATE, PROBABILITY > &&  other)
default

Move assignment operator.

◆ operator==()

template<class STATE , class PROBABILITY >
bool mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::operator== ( const probabilistic_state< STATE, PROBABILITY > &  other) const
inline

Standard equality operator.

Returns
Returns true iff the probabilistic states are equal.

Definition at line 121 of file probabilistic_state.h.

◆ rbegin() [1/2]

template<class STATE , class PROBABILITY >
reverse_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::rbegin ( )
inline

Gets a reverse iterator over pairs of state and probability. This can only be used if the state is internally stored as a vector.

Returns
The iterator pointing at the last state probability pair.

Definition at line 328 of file probabilistic_state.h.

◆ rbegin() [2/2]

template<class STATE , class PROBABILITY >
const_reverse_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::rbegin ( ) const
inline

Gets a reverse iterator over pairs of state and probability. This can only be used when the state is stored internally as a vector.

Returns
The iterator pointing at the last state probability pair.

Definition at line 314 of file probabilistic_state.h.

◆ rend() [1/2]

template<class STATE , class PROBABILITY >
reverse_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::rend ( )
inline

Gets the reverse end iterator over pairs of state and probability.

Returns
The iterator pointing before the first state probability pair in a probabilistic state.

Definition at line 335 of file probabilistic_state.h.

◆ rend() [2/2]

template<class STATE , class PROBABILITY >
const_reverse_iterator mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::rend ( ) const
inline

Gets the reverse end iterator over pairs of state and probability.

Returns
The iterator pointing before the first state probability pair in a probabilistic state.

Definition at line 321 of file probabilistic_state.h.

◆ set()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::set ( const STATE &  s)
inline

Set this probabilistic state to a single state with probability one.

It is assumed that the given state probability pair does not have any element.

Parameters
[in]sThe state.

Definition at line 186 of file probabilistic_state.h.

◆ shrink_to_fit()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::shrink_to_fit ( )
inline

If a probabilistic state is ready, shrinking it to minimal size might be useful to reduce its memory usage. A requirement is that the sum of the probabilities must be one.

Definition at line 223 of file probabilistic_state.h.

◆ size()

template<class STATE , class PROBABILITY >
std::size_t mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::size ( ) const
inline

Gets the number of probabilistic states in the vector representation of this state. If the state is stored as a simple number this size returns 0. So, 0 means that there is one state, which should then be obtained using get(). If the size is larger than 0 the state is stored in a vector, and it must be accessed throught the iterators begin() and n.

Returns
The number of probabilistic states, where 0 means there is one simple state.

Definition at line 247 of file probabilistic_state.h.

◆ swap()

template<class STATE , class PROBABILITY >
void mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::swap ( probabilistic_state< STATE, PROBABILITY > &  other)
inlinenoexcept

Swap this probabilistic state.

Parameters
[in]otherA probabilistic state.

Definition at line 163 of file probabilistic_state.h.

Member Data Documentation

◆ m_probabilistic_state

template<class STATE , class PROBABILITY >
std::vector<state_probability_pair> mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::m_probabilistic_state
protected

Definition at line 63 of file probabilistic_state.h.

◆ m_single_state

template<class STATE , class PROBABILITY >
STATE mcrl2::lts::probabilistic_state< STATE, PROBABILITY >::m_single_state
protected

Definition at line 61 of file probabilistic_state.h.


The documentation for this class was generated from the following file: