22 static constexpr real_t
NaN = alpaqa::NaN<config_t>;
34 using any_stat_t = std::variant<index_t, real_t, std::string, bool, vec,
36 std::vector<std::pair<std::string, any_stat_t>>
extra{};
41 static constexpr real_t
NaN = alpaqa::NaN<config_t>;
47 std::span<const std::string_view>
options;
52 auto rnd = std::uniform_int_distribution<uint32_t>()(rng);
53 auto rnd_str = std::string(8,
'0');
54 std::to_chars(rnd_str.data() + std::countl_zero(rnd) / 4,
55 rnd_str.data() + rnd_str.size(), rnd, 16);
61 using ms = std::chrono::milliseconds;
62 auto now = Clk::now();
63 auto now_ms = std::chrono::duration_cast<ms>(now.time_since_epoch());
69 auto dict_elem = [&os](std::string_view name,
const auto &value) {
70 os << name <<
": " << value <<
'\n';
72#define EVAL(name) dict_elem(#name, evals.name)
74 EVAL(proj_multipliers);
80 EVAL(grad_f_grad_g_prod);
97 auto dict_elem = [&os](std::string_view name,
const auto &value) {
98 os << name <<
": " << value <<
'\n';
100#define EVAL(name) dict_elem(#name, evals.name)
114 EVAL(add_R_prod_masked);
115 EVAL(add_S_prod_masked);
118 EVAL(grad_constr_prod);
119 EVAL(grad_constr_prod_N);
120 EVAL(add_gn_hess_constr);
121 EVAL(add_gn_hess_constr_N);
126template <
class... Ts>
128 using Ts::operator()...;
130template <
class... Ts>
138 const auto &kkterr = results.
error;
139 auto time_s = std::chrono::duration<double>(solstats.duration);
141 << solstats.evals <<
'\n'
142 <<
"solver: " << solstats.solver <<
'\n'
143 <<
"problem: " << results.
problem.
path.filename().c_str() <<
" (from "
144 << results.
problem.
path.parent_path() <<
")" <<
'\n'
145 <<
"status: " << (solstats.success ?
"\033[0;32m" :
"\033[0;31m")
146 << solstats.status <<
"\033[0m" <<
'\n'
149 <<
"ε = " << float_to_str(solstats.ε) <<
'\n'
150 <<
"δ = " << float_to_str(solstats.δ) <<
'\n'
151 <<
"final step size = " << float_to_str(solstats.γ) <<
'\n'
152 <<
"penalty norm = " << float_to_str(solstats.Σ) <<
'\n'
153 <<
"nonsmooth objective = " << float_to_str(solstats.h) <<
'\n'
154 <<
"smooth objective = " << float_to_str(results.
objective) <<
'\n'
155 <<
"objective = " << float_to_str(results.
objective) <<
'\n'
156 <<
"stationarity = " << float_to_str(kkterr.stationarity) <<
'\n'
157 <<
"violation = " << float_to_str(kkterr.constr_violation) <<
'\n'
158 <<
"complementarity = " << float_to_str(kkterr.complementarity) <<
'\n'
159 <<
"time: " << float_to_str(time_s.count(), 3) <<
" s\n"
160 <<
"outer iter: " << std::setw(6) << solstats.outer_iter <<
'\n'
161 <<
"iter: " << std::setw(6) << solstats.inner_iter <<
'\n'
163 for (
const auto &[key, value] : solstats.extra) {
164 auto print_key = [&os, k{key}](
const auto &v) {
165 os << k <<
": " << v <<
'\n';
168 [&print_key](
const auto &v) { print_key(v); },
169 [&print_key](real_t v) { print_key(float_to_str(v)); },
170 [&print_key](
bool v) { print_key(v ?
"yes" :
"no"); },
171 [](
const std::vector<real_t> &) {},
174 std::visit(print, value);
length_t get_n() const
[Required] Number of decision variables.
length_t get_m() const
[Required] Number of constraints.
#define USING_ALPAQA_CONFIG(Conf)
std::string float_to_str(F value, int precision)
alpaqa::TypeErasedProblem< config_t > problem
void write_results(std::ostream &os, const BenchmarkResults &results)
std::string random_hex_string(auto &&rng)
void write_evaluations(std::ostream &os, const alpaqa::EvalCounter &evals)
void print_results(std::ostream &os, const BenchmarkResults &results)
static constexpr real_t NaN
alpaqa::KKTError< config_t > error
SolverResults solver_results
std::span< const std::string_view > options
std::vector< std::pair< std::string, any_stat_t > > extra
static constexpr real_t NaN
std::chrono::nanoseconds duration
std::variant< index_t, real_t, std::string, bool, vec, std::vector< real_t > > any_stat_t
alpaqa::EvalCounter evals