Skip to content
Snippets Groups Projects
Commit dd30d41d authored by Franck Dary's avatar Franck Dary
Browse files

Fixed backtracking

parent d5c41a02
No related branches found
No related tags found
No related merge requests found
......@@ -175,6 +175,7 @@ void applyActionAndTakeTransition(TransitionMachine & tm, const std::string & ac
Action * action = tm.getCurrentClassifier()->getAction(actionName);
TransitionMachine::Transition * transition = tm.getTransition(actionName);
action->setInfos(transition->headMvt, tm.getCurrentState());
config.addToActionsHistory(config.getCurrentStateName(), actionName, tm.getCurrentClassifier()->getActionCost(config, actionName));
action->apply(config);
tm.takeTransition(transition);
}
......
......@@ -135,6 +135,8 @@ void Trainer::computeScoreOnDev()
TransitionMachine::Transition * transition = tm.getTransition(actionName);
action->setInfos(transition->headMvt, tm.getCurrentState());
devConfig->addToActionsHistory(devConfig->getCurrentStateName(), actionName, tm.getCurrentClassifier()->getActionCost(*devConfig, actionName));
action->apply(*devConfig);
tm.takeTransition(transition);
......
......@@ -348,7 +348,7 @@ class Config
///
/// @param index Index of the column to print.
void printColumnInfos(unsigned int index);
void addToActionsHistory(std::string & state, std::string & action, int cost);
void addToActionsHistory(std::string & state, const std::string & action, int cost);
std::vector< std::pair<std::string, int> > & getActionsHistory(std::string & state);
};
......
......@@ -615,7 +615,7 @@ void Config::printColumnInfos(unsigned int index)
fprintf(stderr, "\n");
}
void Config::addToActionsHistory(std::string & state, std::string & action, int cost)
void Config::addToActionsHistory(std::string & state, const std::string & action, int cost)
{
actionsHistory[state+"_"+std::to_string(head)].emplace_back(action, cost);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment