Hold a stateful solver#
Geometry hosts such as eOn call Optimizer::step() once per outer
iteration. rgmin_minimize is a full solve. The session type
rgmin_solver_t (Rust Solver) is the matching handle: create once,
step many times, free at the end.
Rust#
use eindir_core::objectives::Rosenbrock;
use ndarray::array;
use rgmin::{Accept, Control, Method, QnStep, Solver};
let obj = Rosenbrock::<2>::new();
let mut x = array![-1.2, 1.0];
let mut solver = Solver::new(Method::lbfgs(), Control::default(), 2)
.with_gtol(1e-8);
solver.set_qn_step(QnStep::Newton);
solver.set_accept(Accept::None);
let report = solver.step(&obj, &mut x).unwrap();
step is one outer iteration. step_hess / step_hess_fg take a
host Hessian. forget drops pair history, conjugacy, and moments.
set_atom_maxmove is the eOn per-atom clip.
set_project_rigid projects translations and rotations on isolated
clusters.
C#
#include "xts.h"
rgmin_control_t ctrl = { .maxiter = 200, .gtol = 1e-8, .istep = 1.0, .memory = 8 };
rgmin_solver_t *s = rgmin_solver_create(RGMIN_LBFGS, &ctrl, n);
rgmin_report_t report;
while (!done) {
rgmin_solver_set_maxmove(s, max_move);
rgmin_solver_set_qn_step(s, RGMIN_QN_NEWTON);
rgmin_solver_set_accept(s, RGMIN_ACCEPT_NONE);
rgmin_solver_step_hess_fg(s, evalgrad, hess, user, x, &report);
}
rgmin_solver_free(s);
Callbacks are arguments of each step, not stored on the handle.
rgmin_solver_step_fg / rgmin_solver_step_hess_fg take one fused
(f, g) callback so a host that already bills energy and forces
together is not asked twice.
Setters#
Setter |
Role |
|---|---|
|
Two-loop, Newton, or RFO when a host Hessian is present |
|
|
|
Per-atom clip (preferred over a Euclidean cap) |
|
Drop rigid modes on isolated clusters |
|
Al-Baali extra L-BFGS pairs |
|
Li–Fukushima pair filter |
|
Feasible-set QP; returns 1 without |
|
Embedded geometry; |
|
Per-atom masses for |
When to use rgmin_minimize instead#
Scripts that want a cold-start solve to gtol still call
rgmin_minimize / minimize_method. Hopping chains that own the
pair history hold Lbfgs directly (see
embed in anneal).