60 Scalar
run(
fun_t phi,
const Scalar phi0,
const Scalar dphi0,
74 }
catch (
const std::runtime_error &e) {
76 if (alpha_try <=
options_.alpha_min) {
83 if (std::abs(dphi0) <
options_.dphi_thresh) {
87 for (std::size_t i = 0; i <
options_.max_num_steps; i++) {
89 const Scalar dM = latest.phi - phi0;
90 if (dM <=
options_.armijo_c1 * alpha_try * dphi0) {
112 if (previous.valid) {
119 "Unrecognized interpolation type in this context.\n");
124 strat,
options_.contraction_min * alpha_try,
125 options_.contraction_max * alpha_try);
128 if (std::isnan(alpha_try)) {
130 alpha_try =
options_.contraction_min * previous.alpha;
132 alpha_try = std::max(alpha_try,
options_.alpha_min);
138 }
catch (
const std::runtime_error &e) {
142 if (alpha_try <=
options_.alpha_min) {
146 alpha_try = std::max(alpha_try,
options_.alpha_min);
152 Scalar max_step_size) {
158 const Scalar &phi0 = lower_bound.phi;
159 const Scalar &dphi0 = lower_bound.dphi;
169 Scalar a = (cand0.phi - phi0 - cand0.alpha * dphi0) /
170 (cand0.alpha * cand0.alpha);
171 coeffs.conservativeResize(3);
172 coeffs << a, dphi0, phi0;
174 anext = -dphi0 / (2. * a);
181 const Scalar &a0 = cand0.alpha;
182 const Scalar &a1 = cand1.alpha;
186 alph_mat(0, 0) = a0 * a0 * a0;
187 alph_mat(0, 1) = a0 * a0;
188 alph_mat(1, 0) = a1 * a1 * a1;
189 alph_mat(1, 1) = a1 * a1;
191 Vector2s alph_rhs{cand1.phi - phi0 - dphi0 * a1,
192 cand0.phi - phi0 - dphi0 * a0};
194 Eigen::HouseholderQR<Matrix2s> decomp(alph_mat);
195 coeffs_cubic_interpolant = decomp.solve(alph_rhs);
197 const Scalar c3 = coeffs_cubic_interpolant(0);
198 const Scalar c2 = coeffs_cubic_interpolant(1);
199 coeffs.conservativeResize(4);
200 coeffs << c3, c2, dphi0, phi0;
204 anext = (-c2 + std::sqrt(c2 * c2 - 3.0 * c3 * dphi0)) / (3.0 * c3);
211 if ((anext > max_step_size) || (anext < min_step_size)) {
213 Scalar pleft =
interpolant.evaluate(min_step_size);
214 Scalar pright =
interpolant.evaluate(max_step_size);
215 if (pleft < pright) {
216 anext = min_step_size;
218 anext = max_step_size;