Moved logging to start of iteration.

release/4.3a0
Frank Dellaert 2013-10-31 19:14:18 +00:00
parent 302880fbe3
commit a1d78150ad
1 changed files with 20 additions and 20 deletions

View File

@ -78,18 +78,6 @@ GaussianFactorGraph::shared_ptr LevenbergMarquardtOptimizer::linearize() const {
/* ************************************************************************* */ /* ************************************************************************* */
void LevenbergMarquardtOptimizer::iterate() { void LevenbergMarquardtOptimizer::iterate() {
// Log current error/lambda to file
if (!params_.logFile.empty()) {
ofstream os(params_.logFile.c_str(), ios::app);
timeval rawtime;
gettimeofday(&rawtime, NULL);
double currentTime = rawtime.tv_sec + rawtime.tv_usec / 1000000.0;
os << state_.iterations << "," << currentTime-state_.startTime << ","
<< state_.error << "," << state_.lambda << endl;
}
gttic (LM_iterate); gttic (LM_iterate);
// Linearize graph // Linearize graph
@ -126,6 +114,18 @@ void LevenbergMarquardtOptimizer::iterate() {
// Try solving // Try solving
try { try {
// Log current error/lambda to file
if (!params_.logFile.empty()) {
ofstream os(params_.logFile.c_str(), ios::app);
timeval rawtime;
gettimeofday(&rawtime, NULL);
double currentTime = rawtime.tv_sec + rawtime.tv_usec / 1000000.0;
os << state_.iterations << "," << currentTime - state_.startTime << ","
<< state_.error << "," << state_.lambda << endl;
}
// Solve Damped Gaussian Factor Graph // Solve Damped Gaussian Factor Graph
const VectorValues delta = solve(dampedSystem, state_.values, params_); const VectorValues delta = solve(dampedSystem, state_.values, params_);