Commit 519345c8 authored by Patrick Schmidt's avatar Patrick Schmidt

Added max_linesearch_iters option to NewtonSolver.

parent 9edeb026
......@@ -174,7 +174,7 @@ int NewtonSolver::solve(NProblemInterface* _problem, const SMatrixD& _A,
double t = t_max;
bool x_ok = false;
for (int i = 0; i < 10; ++i < 3 ? t *= 0.95 : t /= 2)
for (int i = 0; i < max_linesearch_iters_; ++i < 3 ? t *= 0.95 : t /= 2)
{// clamp back t very mildly the first 3 steps and then aggressively (/ 2)
x = x0 + dx.head(n) * t;
fx = _problem->eval_f(x.data());
......@@ -324,7 +324,7 @@ double NewtonSolver::backtracking_line_search(NProblemInterface* _problem,
double t = _t_start;
// backtracking (stable in case of NAN and with max 100 iterations)
for(int i=0; i<100; ++i)
for(int i = 0; i < max_linesearch_iters_; ++i)
{
// current update
x_ls_ = _x + _dx.head(n)*t;
......
......@@ -57,8 +57,8 @@ public:
typedef Eigen::Triplet<double> Triplet;
/// Default constructor
NewtonSolver(const double _eps = 1e-6, const double _eps_line_search = 1e-9, const int _max_iters = 200, const double _alpha_ls=0.2, const double _beta_ls = 0.6)
: eps_(_eps), eps_ls_(_eps_line_search), max_iters_(_max_iters), alpha_ls_(_alpha_ls), beta_ls_(_beta_ls), solver_type_(LS_EigenLU), constant_hessian_structure_(false)
NewtonSolver(const double _eps = 1e-6, const double _eps_line_search = 1e-9, const int _max_iters = 200, const int _max_linesearch_iters = 100, const double _alpha_ls=0.2, const double _beta_ls = 0.6)
: eps_(_eps), eps_ls_(_eps_line_search), max_iters_(_max_iters), max_linesearch_iters_(_max_linesearch_iters), alpha_ls_(_alpha_ls), beta_ls_(_beta_ls), solver_type_(LS_EigenLU), constant_hessian_structure_(false)
{
//#if COMISO_SUITESPARSE_AVAILABLE
// solver_type_ = LS_Umfpack;
......@@ -133,6 +133,7 @@ private:
double eps_;
double eps_ls_;
int max_iters_;
int max_linesearch_iters_;
// double accelerate_;
double alpha_ls_;
double beta_ls_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment