STAMINA/STORM 0.1
Infinite state-space truncator which generates a probability within a window
Classes | Public Types | Public Member Functions | List of all members
stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType > Class Template Reference
Inheritance diagram for stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >:
stamina::builder::threads::BaseThread< StateType, RewardModelType, ValueType >

Classes

class  LockableDeque
 
struct  StateAndThreadIndex
 

Public Types

typedef ExplorationThread< StateType, RewardModelType, ValueType >::StateAndProbability StateAndProbability
 

Public Member Functions

 ControlThread (StaminaModelBuilder< ValueType, RewardModelType, StateType > *parent, uint8_t numberExplorationThreads)
 
std::pair< uint8_t, StateType > requestOwnership (CompressedState &state, uint8_t threadIndex, StateType requestedId=0)
 
uint8_t whoOwns (CompressedState &state)
 
StateType whatIsIndex (CompressedState &state)
 
void requestInsertTransition (uint8_t thread, StateType from, StateType to, double rate)
 
void requestCrossExplorationFromThread (StateAndProbability stateAndProbability, double threadIndex)
 
virtual void mainLoop () override
 
storm::storage::sparse::StateStorage< StateAndThreadIndex > & getStateStorage ()
 
void terminate ()
 
- Public Member Functions inherited from stamina::builder::threads::BaseThread< StateType, RewardModelType, ValueType >
 BaseThread (StaminaModelBuilder< ValueType, RewardModelType, StateType > *parent)
 
virtual void mainLoop ()=0
 
void startThread ()
 
const StaminaModelBuilder< ValueType, RewardModelType, StateType > * getParent ()
 
void join ()
 
void terminate ()
 

Additional Inherited Members

- Protected Attributes inherited from stamina::builder::threads::BaseThread< StateType, RewardModelType, ValueType >
bool finished
 

Constructor & Destructor Documentation

◆ ControlThread()

template<typename StateType , typename RewardModelType , typename ValueType >
stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::ControlThread ( StaminaModelBuilder< ValueType, RewardModelType, StateType > *  parent,
uint8_t  numberExplorationThreads 
)

Constructor for ControlThread. Primarily just calls super class constructor

Parameters
parentThe model builder who owns this thread
numberExplorationThreadsThe number of exploration threads who will be using this worker thread.

Member Function Documentation

◆ mainLoop()

template<typename StateType , typename RewardModelType , typename ValueType >
void stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::mainLoop
overridevirtual

This thread lives for the duration of all exploration threads. It waits for the exploration threads to all emit a "finished" signal, and then tells each exploration thread to die.

The main loop for this thread also flushes things to the parents' transitionsToAdd, which is not locked or mutex'ed because there is only one worker thread to do that.

Implements stamina::builder::threads::BaseThread< StateType, RewardModelType, ValueType >.

◆ requestCrossExplorationFromThread()

template<typename StateType , typename RewardModelType , typename ValueType >
void stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::requestCrossExplorationFromThread ( StateAndProbability  stateAndProbability,
double  threadIndex 
)

Requests cross exploration from a

Parameters
stateAndProbabilityA datastructure containing: state The state to cross explore deltaPi The difference in probability to add stateIndex The state index we found
threadIndexThread index to request cross exploration from

◆ requestInsertTransition()

template<typename StateType , typename RewardModelType , typename ValueType >
void stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::requestInsertTransition ( uint8_t  thread,
StateType  from,
StateType  to,
double  rate 
)

Requests a transition to be inserted (not necessarily in order). These transitions are requested by the exploration threads and are flushed to the model builder's data structure on a "when available" basis, meaning that when this thread idles, it transfers these transitions. Additionally, it maintains mutexes for each thread and only locks the mutex for that particular thread to prevent mutex collisions on the different threads requesting transition insertion.

Parameters
threadThe index of the thread making the request
fromThe index of the state we are transitioning from
toThe index of the state we are transitioning to
rateThe transition rate (if CTMC) or transition probability (if DTMC)

◆ requestOwnership()

template<typename StateType , typename RewardModelType , typename ValueType >
std::pair< uint8_t, StateType > stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::requestOwnership ( CompressedState &  state,
uint8_t  threadIndex,
StateType  requestedId = 0 
)

Requests ownership of a state for a particular thread. This is intended to be called by the thread whose index matches the second parameter in this function. This function locks the mutex and so it should not be used if we just wish to ask who owns a particular state.

If request ownership is successful, the return value is equal to the index of the state requesting ownership of the state. However, if it is not successful, then the return value gives the thread which potentially locked the mutex and got ownership first.

Parameters
stateThe state to request ownership for
threadIndexThe thread who wants ownership of the state.
requestedIdThe (new) stateId that a thread can request we assign a state to
Returns
The thread who owns the state and the new state index

◆ whatIsIndex()

template<typename StateType , typename RewardModelType , typename ValueType >
StateType stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::whatIsIndex ( CompressedState &  state)

Gets the index of a state which already exists. If the state does not exist, returns 0.

Parameters
stateThe state to look up
Returns
The state index

◆ whoOwns()

template<typename StateType , typename RewardModelType , typename ValueType >
uint8_t stamina::builder::threads::ControlThread< StateType, RewardModelType, ValueType >::whoOwns ( CompressedState &  state)

Gets the owning thread of a particular state without locking the mutex. This allows for threads to use the many-read, one-write idea put forth in the paper.

Parameters
stateThe state who we wonder if owns
Returns
The thread who owns state

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