MCPcopy Create free account
hub / github.com/FidoProject/Fido / applyReinforcementToLastAction

Method applyReinforcementToLastAction

src/QLearn.cpp:78–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void QLearn::applyReinforcementToLastAction(double reward, State newState) {
79 if(lastState.size() == 0) {
80 std::cout << "Called applyReinforcementToLastAction before an action had been selected! Because of this, this function call will be ignored.";
81 }
82
83 double lr = lastModel.network->getOutput(lastState)[0];
84 double targetValueForLastState = lr + learningRate*(reward+(devaluationFactor*getHighestReward(newState))-lr);
85
86 trainer->train(lastModel.network, {lastState}, {{targetValueForLastState}});
87}
88
89void QLearn::reset() {
90 std::for_each(models.begin(), models.end(), [&](Model model) {

Callers 1

trainFunction · 0.45

Calls 3

trainMethod · 0.80
sizeMethod · 0.45
getOutputMethod · 0.45

Tested by

no test coverage detected