STAMINA/STORM 0.1
Infinite state-space truncator which generates a probability within a window
ExplorationThread.h
1
8#ifndef STAMINA_BUILDER_THREADS_EXPLORATIONTHREAD_H
9#define STAMINA_BUILDER_THREADS_EXPLORATIONTHREAD_H
10
11#include "BaseThread.h"
12#include "ControlThread.h"
13
14#include "util/StateIndexArray.h"
15#include "builder/ProbabilityState.h"
16
17namespace stamina {
18 namespace builder {
19 namespace threads {
20
21 template <typename StateType, typename RewardModelType, typename ValueType>
22 class ExplorationThread : public BaseThread<StateType, RewardModelType, ValueType> {
23 public:
24// typedef std::pair<CompressedState &, std::shared_ptr<StaminaModelBuilder<ValueType, RewardModelType, StateType>>> StateAndProbability;
26 CompressedState & state;
27 StateType index;
28 double deltaPi;
29 };
30
32 CompressedState & state;
33 StateType index;
34 uint8_t threadIndex;
35 };
47 , uint8_t threadIndex
49 , uint32_t stateSize
51 , std::shared_ptr<storm::generator::PrismNextStateGenerator<ValueType, StateType>> const& generator
52 , std::function<StateType (CompressedState const&)> stateToIdCallback
53 );
54 uint8_t getIndex();
55 uint32_t getNumberOfOwnedStates();
56 bool isIdling();
57 void setIsCtmc(bool isCtmc);
66 void requestCrossExploration(CompressedState & state, double deltaPi);
67 void requestCrossExploration(StateType stateIndex, double deltaPi);
71 virtual void mainLoop() override; // doExploration
72 protected:
73 virtual void exploreStates() = 0;
74 virtual void exploreState(StateAndProbability & stateProbability) = 0;
75 virtual void enqueueSuccessors(CompressedState & state) = 0; // stateToIdCallback
76 // Weak priority on crossExplorationQueue (superseded by mutex lock)
77 std::shared_mutex crossExplorationQueueMutex;
78 std::deque<std::pair<CompressedState, double>> crossExplorationQueue;
79 std::deque<StateAndProbability> mainExplorationQueue;
80 uint32_t numberOfOwnedStates;
81 bool idling;
84 storm::storage::sparse::StateStorage<StateType> & stateStorage;
85 std::shared_ptr<storm::generator::PrismNextStateGenerator<ValueType, StateType>> const& generator;
86 std::deque<StateAndProbability> statesTerminatedLastIteration;
87 std::function<StateType (CompressedState const&)> stateToIdCallback;
88 // The states we should request cross exploration from
89 std::deque<StateIndexAndThread> statesToRequestCrossExploration;
90 private:
91 const uint8_t threadIndex;
92 };
93 } // namespace threads
94 } // namespace builder
95} // namespace stamina
96
97#endif // STAMINA_BUILDER_THREADS_EXPLORATIONTHREAD_H
Definition: ProbabilityState.h:11
Definition: BaseThread.h:28
Definition: ControlThread.h:30
Definition: ExplorationThread.h:22
void requestCrossExploration(CompressedState &state, double deltaPi)
Definition: ExplorationThread.cpp:55
ExplorationThread(StaminaModelBuilder< ValueType, RewardModelType, StateType > *parent, uint8_t threadIndex, ControlThread< StateType, RewardModelType, ValueType > &controlThread, uint32_t stateSize, util::StateIndexArray< StateType, ProbabilityState< StateType > > *stateMap, std::shared_ptr< storm::generator::PrismNextStateGenerator< ValueType, StateType > > const &generator, std::function< StateType(CompressedState const &)> stateToIdCallback)
Definition: ExplorationThread.cpp:10
virtual void mainLoop() override
Definition: ExplorationThread.cpp:65
Definition: StateIndexArray.h:27
Definition: ExplicitTruncatedModelBuilder.cpp:40