MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / updateReuseModel

Method updateReuseModel

native/agent/ModelReusableAgent.cpp:201–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 }
200
201 void ModelReusableAgent::updateReuseModel() {
202 if (this->_previousActions.empty())
203 return;
204 ActionPtr lastAction = this->_previousActions.back();
205 ActivityNameActionPtr modelAction = std::dynamic_pointer_cast<ActivityNameAction>(
206 lastAction);
207 if (nullptr == modelAction || nullptr == this->_newState)
208 return;
209 auto hash = (uint64_t) modelAction->hash();
210 stringPtr activity = this->_newState->getActivityString(); // mark: use the _newstate as last selected action's target
211 if (activity == nullptr)
212 return;
213 {
214 std::lock_guard<std::mutex> reuseGuard(this->_reuseModelLock);
215 auto iter = this->_reuseModel.find(hash);
216 if (iter == this->_reuseModel.end()) {
217 BDLOG("can not find action %s in reuse map", modelAction->getId().c_str());
218 ReuseEntryM entryMap;
219 entryMap.emplace(std::make_pair(activity, 1));
220 this->_reuseModel[hash] = entryMap;
221 } else {
222 ((*iter).second)[activity] += 1;
223 }
224 auto qValueReuseEntryIter = this->_reuseQValue.find(hash);
225 this->_reuseQValue[hash] = modelAction->getQValue();
226 }
227 }
228
229 ActivityStateActionPtr ModelReusableAgent::selectNewActionEpsilonGreedyRandomly() const {
230 if (this->eGreedy()) {

Callers 1

updateStrategyMethod · 0.95

Calls 7

emptyMethod · 0.80
getActivityStringMethod · 0.80
getIdMethod · 0.80
hashMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
getQValueMethod · 0.45

Tested by

no test coverage detected