59 Scalar
run(
const std::function<Scalar(Scalar)> &phi,
const Scalar phi0,
60 const Scalar dphi0, Scalar &alpha_try) {
73 }
catch (
const std::runtime_error &e) {
75 if (alpha_try <=
options_.alpha_min) {
82 if (std::abs(dphi0) <
options_.dphi_thresh) {
86 for (std::size_t i = 0; i <
options_.max_num_steps; i++) {
88 const Scalar dM = latest.phi - phi0;
89 if (dM <=
options_.armijo_c1 * alpha_try * dphi0) {
111 if (previous.valid) {
118 "Unrecognized interpolation type in this context.\n");
123 strat,
options_.contraction_min * alpha_try,
124 options_.contraction_max * alpha_try);
127 if (std::isnan(alpha_try)) {
129 alpha_try =
options_.contraction_min * previous.alpha;
131 alpha_try = std::max(alpha_try,
options_.alpha_min);
137 }
catch (
const std::runtime_error &e) {
141 if (alpha_try <=
options_.alpha_min) {
145 alpha_try = std::max(alpha_try,
options_.alpha_min);
151 Scalar max_step_size) {
157 const Scalar &phi0 = lower_bound.phi;
158 const Scalar &dphi0 = lower_bound.dphi;
168 Scalar a = (cand0.phi - phi0 - cand0.alpha * dphi0) /
169 (cand0.alpha * cand0.alpha);
170 coeffs.conservativeResize(3);
171 coeffs << a, dphi0, phi0;
173 anext = -dphi0 / (2. * a);
180 const Scalar &a0 = cand0.alpha;
181 const Scalar &a1 = cand1.alpha;
185 alph_mat(0, 0) = a0 * a0 * a0;
186 alph_mat(0, 1) = a0 * a0;
187 alph_mat(1, 0) = a1 * a1 * a1;
188 alph_mat(1, 1) = a1 * a1;
190 Vector2s alph_rhs{cand1.phi - phi0 - dphi0 * a1,
191 cand0.phi - phi0 - dphi0 * a0};
193 Eigen::HouseholderQR<Matrix2s> decomp(alph_mat);
194 coeffs_cubic_interpolant = decomp.solve(alph_rhs);
196 const Scalar c3 = coeffs_cubic_interpolant(0);
197 const Scalar c2 = coeffs_cubic_interpolant(1);
198 coeffs.conservativeResize(4);
199 coeffs << c3, c2, dphi0, phi0;
203 anext = (-c2 + std::sqrt(c2 * c2 - 3.0 * c3 * dphi0)) / (3.0 * c3);
210 if ((anext > max_step_size) || (anext < min_step_size)) {
212 Scalar pleft =
interpolant.evaluate(min_step_size);
213 Scalar pright =
interpolant.evaluate(max_step_size);
214 if (pleft < pright) {
215 anext = min_step_size;
217 anext = max_step_size;