x is the geometry, read and written in place: an L-BFGS history is built from successive iterates, so restarting x at a fixed point would pair curvature across unrelated geometries.
max_move bounds the norm of the displacement, matching what the dimer's max_step_length means; a per-atom bound lets the total exceed it. Non-positive leaves it unbounded.
Returns false and leaves x untouched when the session refuses the step, so the caller can fall back rather than propagate a non-finite geometry. One bounded quasi-Newton step from the gradient at x.
x is the geometry, read and written in place. empty_scale scales the first step taken on empty memory, where the two-loop is plain steepest descent: an unscaled -g overshoots the move bound on every outer and the search cycles instead of settling.
Returns false and leaves x untouched when the direction is unusable, so the caller falls back rather than propagating a non-finite geometry. A refusal after this call pushed a pair forgets the whole session: rgmin cannot pop a single pair, so every stored pair and the previous-point anchor are cleared and the next step starts from empty memory.
objective names the function gradient belongs to. When it differs from the objective of the previous step the curvature history is dropped and no pair is formed, so the history only ever holds pairs whose two gradients are of one objective.
Definition at line 122 of file RgminStep.h.
125 {
126 if (
x.size() <= 0 || gradient.size() !=
x.size())
return false;
127 if (!
x.allFinite() || !gradient.allFinite())
return false;
128 ensure(
static_cast<std::size_t
>(
x.size()));
129 if (solver_ == nullptr) return false;
130 const std::size_t n =
static_cast<std::size_t
>(
x.size());
131
132 if (have_previous_ && previous_objective_ != objective)
forget();
133
134
135
136
137
138
139
140
141 const bool pushed_pair = have_previous_;
142 if (pushed_pair) {
143 const Eigen::VectorXd s_vec =
x - previous_x_;
144 const Eigen::VectorXd y_vec = gradient - previous_g_;
145 rgmin_solver_push_pair(solver_, s_vec.data(), y_vec.data(), n);
147 trace->push_back({previous_objective_, objective});
148 }
149 }
150
151 const auto refuse = [&]() {
152 if (pushed_pair)
forget();
153 return false;
154 };
155
156 Eigen::VectorXd direction(
x.size());
157 const rgmin_status_t st = rgmin_solver_search_direction(
158 solver_, gradient.data(), direction.data(), n);
159 if (st != RGMIN_SUCCESS || !direction.allFinite()) return refuse();
160
161 if (rgmin_solver_pair_count(solver_) == 0) direction *= empty_scale;
162
163
164
165
166 const double length = direction.stableNorm();
167 if (!std::isfinite(length) || !(length > 0.0)) return refuse();
168 if (max_move > 0.0 && length > max_move) {
169 direction *= max_move / length;
170 }
171
172
173
174 const Eigen::VectorXd stepped =
x + direction;
175 if (!stepped.allFinite()) return refuse();
176
178 previous_g_ = gradient;
179 previous_objective_ = objective;
180 have_previous_ = true;
182 return true;
183 }
static std::vector< PairRecord > *& pairTrace() noexcept