8void alpaqa_setulb_c(
int n,
int m,
double *x,
const double *l,
const double *u,
9 const int *nbd,
double &f,
double *g,
double factr,
10 double pgtol,
double *wa,
int *iwa,
char *task,
int iprint,
11 char *csave,
bool *lsave,
int *isave,
double *dsave);
34 using std::chrono::nanoseconds;
35 using clock = std::chrono::steady_clock;
37 auto *os =
opts.os ?
opts.os : this->os;
38 auto max_time = params.max_time;
40 max_time = std::min(max_time, *
opts.max_time);
43 if (!problem.provides_get_box_C())
44 throw std::invalid_argument(
"LBFGSBSolver requires box constraints");
46 throw std::invalid_argument(
"LBFGSBSolver only supports "
47 "PANOCStopCrit::ProjGradUnitNorm");
49 const auto n = problem.get_n();
50 const auto m_constr = problem.get_m();
51 const auto &C = problem.get_box_C();
52 const auto mem =
static_cast<length_t>(params.memory);
54 using intvec = Eigen::VectorX<int>;
62 std::array<bool, 4>
lsave{};
67 for (
index_t i = 0; i < n; ++i) {
79 int print = params.print;
90 auto set_task = [&](std::string_view s) {
91 std::fill(std::copy(s.begin(), s.end(),
task.begin()),
task.end(),
' ');
103 *os <<
"┌─[LBFGSB]\n";
105 *os <<
"├─ " << std::setw(6) << k <<
" ──\n";
113 <<
", #J = " << std::setw(6) << nJ
117 *os <<
"└─ " << status <<
" ──"
129 x_solve.data(), C.lowerbound.data(),
130 C.upperbound.data(),
nbd.data(), ψ, grad_ψ.data(),
135 if (
task_sv.starts_with(
"FG")) {
136 ψ = problem.eval_ψ_grad_ψ(
x_solve, y, Σ, grad_ψ, work_n, work_m);
140 "CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL")) {
145 else if (
task_sv.starts_with(
"NEW_X")) {
147 params.print_interval != 0 &&
148 static_cast<unsigned>(
num_iter) % params.print_interval == 0;
155 set_task(
"STOP: projected gradient norm");
157 }
else if (clock::now() -
start_time >= max_time) {
161 }
else if (
static_cast<unsigned>(
num_iter) >= params.max_iter) {
163 set_task(
"STOP: number iterations");
165 }
else if (stop_signal.stop_requested()) {
176 else if (
task_sv.starts_with(
"CONVERGENCE: REL_REDUCTION_OF_F")) {
187 *os <<
"[LBFGSB] Unexpected task: '" <<
task_trimmed <<
"'"
196 else if (params.print_interval != 0)
198 if (params.print_interval != 0)
211 opts.always_overwrite_results) {
214 if (
err_z.size() > 0)
215 err_z = Σ.asDiagonal().inverse() * (
ŷ - y);
std::string get_name() const
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
void alpaqa_setulb_c(int n, int m, double *x, const double *l, const double *u, const int *nbd, double &f, double *g, double factr, double pgtol, double *wa, int *iwa, char *task, int iprint, char *csave, bool *lsave, int *isave, double *dsave)
std::chrono::nanoseconds elapsed_time
@ ProjGradUnitNorm
∞-norm of the projected gradient with unit step size:
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
@ Interrupted
Solver was interrupted by the user.
@ MaxTime
Maximum allowed execution time exceeded.
@ Exception
An unexpected exception was thrown.
@ NoProgress
No progress was made in the last iteration.
@ MaxIter
Maximum number of iterations exceeded.
@ Converged
Converged and reached given tolerance.
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
std::string_view float_to_str_vw(auto &buf, double value, int precision=std::numeric_limits< double >::max_digits10)
typename Conf::crvec crvec