56 ONE_STEP_PER_ITERATION
94 template<
class M,
class F,
class VALUES>
97 const M&
Rd,
const F&
f,
const VALUES&
x0,
const double f_error,
const bool verbose=
false);
137 template<
class M,
class F,
class VALUES>
140 const M&
Rd,
const F&
f,
const VALUES&
x0,
const double f_error,
const bool verbose)
150 enum { NONE, INCREASED_DELTA, DECREASED_DELTA } lastAction = NONE;
152 gttic(Dog_leg_point);
154 result.
dx_d = ComputeDoglegPoint(delta, dx_u, dx_n, verbose);
155 gttoc(Dog_leg_point);
157 if(verbose) std::cout <<
"delta = " << delta <<
", dx_d_norm = " << result.
dx_d.
norm() << std::endl;
161 const VALUES x_d(x0.retract(result.
dx_d));
164 gttic(decrease_in_f);
167 gttoc(decrease_in_f);
171 const double new_M_error = Rd.error(result.
dx_d);
174 if(verbose) std::cout << std::setprecision(15) <<
"f error: " << f_error <<
" -> " << result.
f_error << std::endl;
175 if(verbose) std::cout << std::setprecision(15) <<
"M error: " << M_error <<
" -> " << new_M_error << std::endl;
182 (f_error - result.
f_error) / (M_error - new_M_error);
184 if(verbose) std::cout << std::setprecision(15) <<
"rho = " << rho << std::endl;
188 const double dx_d_norm = result.
dx_d.
norm();
189 const double newDelta =
std::max(delta, 3.0 * dx_d_norm);
191 if(mode == ONE_STEP_PER_ITERATION || mode == SEARCH_REDUCE_ONLY)
193 else if(mode == SEARCH_EACH_ITERATION) {
194 if(
std::abs(newDelta - delta) < 1
e-15 || lastAction == DECREASED_DELTA)
198 lastAction = INCREASED_DELTA;
205 }
else if(0.75 > rho && rho >= 0.25) {
209 }
else if(0.25 > rho && rho >= 0.0) {
212 bool hitMinimumDelta;
214 newDelta = 0.5 *
delta;
215 hitMinimumDelta =
false;
218 hitMinimumDelta =
true;
220 if(mode == ONE_STEP_PER_ITERATION || lastAction == INCREASED_DELTA || hitMinimumDelta)
222 else if(mode == SEARCH_EACH_ITERATION || mode == SEARCH_REDUCE_ONLY) {
224 lastAction = DECREASED_DELTA;
238 lastAction = DECREASED_DELTA;
240 if(verbose) std::cout <<
"Warning: Dog leg stopping because cannot decrease error with minimum delta" << std::endl;
Matrix< RealScalar, Dynamic, Dynamic > M
static IterationResult Iterate(double delta, TrustRegionAdaptationMode mode, const VectorValues &dx_u, const VectorValues &dx_n, const M &Rd, const F &f, const VALUES &x0, const double f_error, const bool verbose=false)
static VectorValues Zero(const VectorValues &other)
TrustRegionAdaptationMode
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)