modified verbosity levels

release/4.3a0
Luca 2014-02-18 14:39:12 -05:00
parent fbfa287d4b
commit 92834a8ed7
3 changed files with 19 additions and 5 deletions

View File

@ -99,7 +99,7 @@ void LevenbergMarquardtOptimizer::iterate() {
const LevenbergMarquardtParams::VerbosityLM lmVerbosity = params_.verbosityLM; const LevenbergMarquardtParams::VerbosityLM lmVerbosity = params_.verbosityLM;
// Linearize graph // Linearize graph
if(nloVerbosity >= NonlinearOptimizerParams::ERROR) if(lmVerbosity >= LevenbergMarquardtParams::DAMPED)
cout << "linearizing = " << endl; cout << "linearizing = " << endl;
GaussianFactorGraph::shared_ptr linear = linearize(); GaussianFactorGraph::shared_ptr linear = linearize();
@ -172,7 +172,8 @@ void LevenbergMarquardtOptimizer::iterate() {
// create new optimization state with more adventurous lambda // create new optimization state with more adventurous lambda
gttic (compute_error); gttic (compute_error);
if(nloVerbosity >= NonlinearOptimizerParams::ERROR) cout << "calculating error" << endl;
if(lmVerbosity >= LevenbergMarquardtParams::TRYLAMBDA) cout << "calculating error" << endl;
double error = graph_.error(newValues); double error = graph_.error(newValues);
gttoc(compute_error); gttoc(compute_error);
@ -211,11 +212,15 @@ void LevenbergMarquardtOptimizer::iterate() {
increaseLambda(modelFidelity); increaseLambda(modelFidelity);
} }
// bool converged = checkConvergence(_params().relativeErrorTol, _params().absoluteErrorTol, _params().errorTol, state_.error, error);
// cout << " Inner iteration - converged " << converged << endl;
} }
} catch (IndeterminantLinearSystemException& e) { } catch (IndeterminantLinearSystemException& e) {
(void) e; // Prevent unused variable warning (void) e; // Prevent unused variable warning
if(lmVerbosity >= LevenbergMarquardtParams::LAMBDA) if(lmVerbosity >= LevenbergMarquardtParams::LAMBDA)
cout << "Negative matrix, increasing lambda" << endl; cout << "Negative matrix, increasing lambda" << endl;
// cout << "failed to solve current system" << endl;
// Either we're not cautious, or the same lambda was worse than the current error. // Either we're not cautious, or the same lambda was worse than the current error.
// The more adventurous lambda was worse too, so make lambda more conservative // The more adventurous lambda was worse too, so make lambda more conservative
// and keep the same values. // and keep the same values.

View File

@ -55,8 +55,12 @@ void NonlinearOptimizer::defaultOptimize() {
if (params.verbosity >= NonlinearOptimizerParams::ERROR) cout << "Initial error: " << currentError << endl; if (params.verbosity >= NonlinearOptimizerParams::ERROR) cout << "Initial error: " << currentError << endl;
// Return if we already have too many iterations // Return if we already have too many iterations
if(this->iterations() >= params.maxIterations) if(this->iterations() >= params.maxIterations){
if (params.verbosity >= NonlinearOptimizerParams::TERMINATION) {
cout << "iterations: " << this->iterations() << " >? " << params.maxIterations << endl;
}
return; return;
}
// Iterative loop // Iterative loop
do { do {
@ -152,11 +156,16 @@ bool checkConvergence(double relativeErrorTreshold, double absoluteErrorTreshold
} }
bool converged = (relativeErrorTreshold && (relativeDecrease <= relativeErrorTreshold)) bool converged = (relativeErrorTreshold && (relativeDecrease <= relativeErrorTreshold))
|| (absoluteDecrease <= absoluteErrorTreshold); || (absoluteDecrease <= absoluteErrorTreshold);
if (verbosity >= NonlinearOptimizerParams::ERROR && converged) { if (verbosity >= NonlinearOptimizerParams::TERMINATION && converged) {
if(absoluteDecrease >= 0.0) if(absoluteDecrease >= 0.0)
cout << "converged" << endl; cout << "converged" << endl;
else else
cout << "Warning: stopping nonlinear iterations because error increased" << endl; cout << "Warning: stopping nonlinear iterations because error increased" << endl;
cout << "errorThreshold: " << newError << " <? " << errorThreshold << endl;
cout << "absoluteDecrease: " << setprecision(12) << absoluteDecrease << " <? " << absoluteErrorTreshold << endl;
cout << "relativeDecrease: " << setprecision(12) << relativeDecrease << " <? " << relativeErrorTreshold << endl;
} }
return converged; return converged;
} }

View File

@ -34,7 +34,7 @@ class GTSAM_EXPORT NonlinearOptimizerParams {
public: public:
/** See NonlinearOptimizerParams::verbosity */ /** See NonlinearOptimizerParams::verbosity */
enum Verbosity { enum Verbosity {
SILENT, ERROR, VALUES, DELTA, LINEAR SILENT, TERMINATION, ERROR, VALUES, DELTA, LINEAR
}; };
int maxIterations; ///< The maximum iterations to stop iterating (default 100) int maxIterations; ///< The maximum iterations to stop iterating (default 100)