A highly effective reinforcement learning control system (Truell and Gruenstein) */
| 7 | |
| 8 | /** A highly effective reinforcement learning control system (Truell and Gruenstein) */ |
| 9 | class FidoControlSystem : public WireFitQLearn { |
| 10 | public: |
| 11 | /** Initializes a FidoControlSystem |
| 12 | * |
| 13 | * \param stateDimensions the number of dimensions of the state being fed to the control system (aka. number of elements in the state vector) |
| 14 | * \param minAction the minimum possible action (e.g. a vector of doubles) that the control system may output |
| 15 | * \param maxAction the maximum possible action (e.g. a vector of doubles) that the control system may output |
| 16 | * \param baseOfDimensions the number of possible descrete values in each dimension. Ex. if baseOfDimensions=2, minAction={0, 0}, maxAction={1, 1}, possibleActions={{0, 0}, {0, 1}, {1, 0}, {1, 1}}. |
| 17 | */ |
| 18 | FidoControlSystem(int stateDimensions, Action minAction, Action maxAction, int baseOfDimensions); |
| 19 | |
| 20 | std::vector<double> chooseBoltzmanActionDynamic(State state); |
| 21 | |
| 22 | /** Update the control system's model, by giving it reward for its last action. |
| 23 | * |
| 24 | * \param reward the reward associated with the control system's last action |
| 25 | * \param newState the new state vector (needed because states may change after performing an action) |
| 26 | */ |
| 27 | void applyReinforcementToLastAction(double reward, State newState); |
| 28 | |
| 29 | /** Reverts the control system to a newely initialized state |
| 30 | * |
| 31 | * Reset's the control system's model and wipes the system's memory of past actions, states, and rewards. |
| 32 | */ |
| 33 | void reset(); |
| 34 | |
| 35 | const double initialExploration = 1; |
| 36 | const unsigned int samplesOfHistory = 100; |
| 37 | double explorationLevel; |
| 38 | double lastUncertainty; |
| 39 | |
| 40 | protected: |
| 41 | |
| 42 | struct History { |
| 43 | State initialState, newState; |
| 44 | Action action; |
| 45 | double reward; |
| 46 | |
| 47 | History(State initialState_, State newState_, Action action_, double reward_) { |
| 48 | initialState = initialState_; |
| 49 | newState = newState_; |
| 50 | action = action_; |
| 51 | reward = reward_; |
| 52 | } |
| 53 | |
| 54 | bool operator==(const History& other) { |
| 55 | return initialState == other.initialState && newState == other.newState && action == other.action && reward == other.reward; |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | std::vector<History> histories; |
| 60 | |
| 61 | std::vector<FidoControlSystem::History> selectHistories(); |
| 62 | double trainOnHistories(std::vector<FidoControlSystem::History> selectedHistories, double allowedError, unsigned int maxIterations); |
| 63 | void adjustExploration(double uncertainty); |
| 64 | double getError(std::vector<double> input, std::vector<double> correctOutput); |
| 65 | std::vector<Wire> newControlWiresForHistory(History history); |
| 66 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected