54 SEARCH_EACH_ITERATION,
56 ONE_STEP_PER_ITERATION
94 template<
class M,
class F,
class VALUES>
95 static IterationResult Iterate(
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);
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);
166 result.f_error = f.error(x_d);
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;
180 const double rho = fabs(f_error - result.f_error) < 1e-15 || fabs(M_error - new_M_error) < 1e-15 ?
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(fabs(newDelta - delta) < 1e-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;
241 result.dx_d.setZero();
242 result.f_error = f_error;
250 result.delta = delta;
This class contains the implementation of the Dogleg algorithm.
Definition: DoglegOptimizerImpl.h:32
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)
Compute the update point for one iteration of the Dogleg algorithm, given an initial trust region rad...
Definition: DoglegOptimizerImpl.h:138
static VectorValues Zero(const VectorValues &other)
Create a VectorValues with the same structure as other, but filled with zeros.
Definition: VectorValues.cpp:69
Variable ordering for the elimination algorithm.
TrustRegionAdaptationMode
Specifies how the trust region is adapted at each Dogleg iteration.
Definition: DoglegOptimizerImpl.h:53
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:73
Definition: DoglegOptimizerImpl.h:34
static VectorValues ComputeDoglegPoint(double delta, const VectorValues &dx_u, const VectorValues &dx_n, const bool verbose=false)
Compute the dogleg point given a trust region radius .
Definition: DoglegOptimizerImpl.cpp:25
Global functions in a separate testing namespace.
Definition: chartTesting.h:28