| 34 | } |
| 35 | |
| 36 | void ModelReusableAgent::computeAlphaValue() { |
| 37 | if (nullptr != this->_newState) { |
| 38 | /// actually, the following part of computing alpha could be extracted and treated as a single method |
| 39 | const GraphPtr &graphRef = this->_model.lock()->getGraph(); // won't this cause null pointer issue? since the lock of weak_ptr could be null? |
| 40 | long totalVisitCount = graphRef->getTotalDistri(); // get the total count of visited states |
| 41 | double movingAlpha = 0.5; |
| 42 | if (totalVisitCount > |
| 43 | 20000) // if the total count of visited states is too much, reduce the alpha. |
| 44 | { |
| 45 | movingAlpha -= 0.1; |
| 46 | } |
| 47 | if (totalVisitCount > 50000) { |
| 48 | movingAlpha -= 0.1; |
| 49 | } |
| 50 | if (totalVisitCount > 100000) { |
| 51 | movingAlpha -= 0.1; |
| 52 | } |
| 53 | if (totalVisitCount > 250000) { |
| 54 | movingAlpha -= 0.1; |
| 55 | } |
| 56 | // after reducing, the possible minimal alpha is 0.1 |
| 57 | // but the actually possible minimal alpha is 0.2, the same as SarsaRLDefaultAlpha |
| 58 | this->_alpha = std::max(SarsaRLDefaultAlpha, movingAlpha); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #define SarsaNStep 5 |
| 63 |
no test coverage detected