added equals in NonlinearOptimizerParams

release/4.3a0
lcarlone 2020-11-27 12:59:27 -05:00
parent b5d06b5878
commit ff40590fc3
2 changed files with 24 additions and 0 deletions

View File

@ -113,6 +113,17 @@ public:
virtual void print(const std::string& str = "") const;
bool equals(const NonlinearOptimizerParams& other, double tol = 1e-9) const {
return maxIterations == other.getMaxIterations()
&& std::abs(relativeErrorTol - other.getRelativeErrorTol()) <= tol
&& std::abs(absoluteErrorTol - other.getAbsoluteErrorTol()) <= tol
&& std::abs(errorTol - other.getErrorTol()) <= tol
&& verbosityTranslator(verbosity) == other.getVerbosity();
// && orderingType.equals(other.getOrderingType()_;
// && linearSolverType == other.getLinearSolverType();
// TODO: check ordering, iterativeParams, and iterationsHook
}
inline bool isMultifrontal() const {
return (linearSolverType == MULTIFRONTAL_CHOLESKY)
|| (linearSolverType == MULTIFRONTAL_QR);

View File

@ -48,6 +48,19 @@ const double tol = 1e-5;
using symbol_shorthand::X;
using symbol_shorthand::L;
/* ************************************************************************* */
TEST( NonlinearOptimizer, paramsEquals )
{
// default constructors lead to two identical params
GaussNewtonParams gnParams1;
GaussNewtonParams gnParams2;
CHECK(gnParams1.equals(gnParams2));
// but the params become different if we change something in gnParams2
gnParams2.setVerbosity("DELTA");
CHECK(!gnParams1.equals(gnParams2));
}
/* ************************************************************************* */
TEST( NonlinearOptimizer, iterateLM )
{