alpaqa 1.0.0a8
Nonconvex constrained optimization
Loading...
Searching...
No Matches
lbfgsb-driver.cpp
Go to the documentation of this file.
1#if WITH_LBFGSB
2
5
6#include "alm-driver.hpp"
7#include "cancel.hpp"
8#include "lbfgsb-driver.hpp"
9#include "solver-driver.hpp"
10#include "util.hpp"
11
12namespace {
13
14using InnerLBFGSBSolver = alpaqa::lbfgsb::LBFGSBSolver;
15
16auto make_inner_lbfgsb_solver(Options &opts) {
17 // Settings for the solver
18 InnerLBFGSBSolver::Params solver_param;
19 solver_param.max_iter = 50'000;
20 solver_param.print_interval = 0;
21 solver_param.stop_crit = alpaqa::PANOCStopCrit::ProjGradUnitNorm;
22 set_params(solver_param, "solver", opts);
23 return InnerLBFGSBSolver{solver_param};
24}
25
26} // namespace
27
28solver_func_t make_lbfgsb_driver(std::string_view direction, Options &opts) {
30 if (!direction.empty())
31 throw std::invalid_argument(
32 "L-BFGS-B solver does not support any directions");
33 auto inner_solver = make_inner_lbfgsb_solver(opts);
34 auto solver = make_alm_solver(std::move(inner_solver), opts);
35 unsigned N_exp = 0;
36 set_params(N_exp, "num_exp", opts);
37 return [solver{std::move(solver)},
38 N_exp](LoadedProblem &problem,
39 std::ostream &os) mutable -> SolverResults {
40 static std::atomic<decltype(solver) *> solver_to_stop;
41 auto cancel = attach_cancellation<solver_to_stop>(solver);
42 return run_alm_solver(problem, solver, os, N_exp);
43 };
44}
45
47
48#else
49
50#include "solver-driver.hpp"
51
53 throw std::invalid_argument(
54 "This version of alpaqa was compiled without L-BFGS-B support.");
55}
56
57#endif
SolverResults run_alm_solver(LoadedProblem &problem, Solver &solver, std::ostream &os, unsigned N_exp)
Definition: alm-driver.hpp:56
auto make_alm_solver(InnerSolver &&inner_solver, Options &opts)
Definition: alm-driver.hpp:12
Augmented Lagrangian Method solver.
Definition: alm.hpp:96
#define USING_ALPAQA_CONFIG(Conf)
Definition: config.hpp:42
solver_func_t make_lbfgsb_driver(std::string_view, Options &)
@ ProjGradUnitNorm
∞-norm of the projected gradient with unit step size:
decltype(auto) set_params(T &t, std::string_view prefix, Options &opts)
Definition: options.hpp:29
std::function< solver_free_func_t > solver_func_t