| 76 | } |
| 77 | |
| 78 | void 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 | |
| 89 | void QLearn::reset() { |
| 90 | std::for_each(models.begin(), models.end(), [&](Model model) { |