34template <
class Rep,
class Period>
37template <
class Duration>
42 "Invalid value " +
to_string(
j) +
" for type '" +
44 std::string value =
j;
49 "Invalid value '" + value +
"' for type '" +
51 std::string(std::string_view(value.data(), e.
result.ptr)));
54 "Invalid units '" + std::string(e.units) +
"' for type '" +
59template <
class Duration>
62 namespace chr = std::chrono;
65 if (
dur.count() == 0) {
69 result += std::to_string(d.count()) +
"h";
73 result += std::to_string(d.count()) +
"min";
77 result += std::to_string(d.count()) +
"s";
81 result += std::to_string(d.count()) +
"ms";
85 result += std::to_string(d.count()) +
"µs";
89 result += std::to_string(d.count()) +
"ns";
93 s = std::move(result);
101 "' (expected an array, but got " +
102 j.type_name() +
')');
107 }
catch (json::exception &e) {
109 " (expected a number, but got " +
110 j.type_name() +
"): " + e.what());
113 std::ranges::transform(
j,
v.begin(),
convert);
120 std::ifstream f(
fpath);
126 auto r = alpaqa::csv::read_row_std_vector<real_t<config_t>>(f);
128 if (
v.expected_size >= 0 &&
r_size !=
v.expected_size)
130 "Incorrect size in '" +
fpath +
"' (expected " +
131 std::to_string(
v.expected_size) +
", but got " +
132 std::to_string(r.size()) +
")");
136 "': alpaqa::csv::read_error: " + e.what());
138 }
else if (
j.is_array()) {
140 if (
v.expected_size >= 0 &&
v.value->size() !=
v.expected_size)
142 "Incorrect size in " +
to_string(
j) +
"' (expected " +
143 std::to_string(
v.expected_size) +
", but got " +
144 std::to_string(
v.value->size()) +
')');
148 "' (expected string or array, but got " +
149 j.type_name() +
')');
158 "' (expected boolean, but got " +
159 j.type_name() +
')');
168 "' (expected string, but got " +
169 j.type_name() +
')');
173template <std::
integral T>
174 requires(!std::same_as<T, bool>)
176 if (std::unsigned_integral<T> && !
j.is_number_unsigned())
179 "' (expected unsigned integer, but got " +
180 j.type_name() +
')');
181 if (!
j.is_number_integer())
184 "' (expected integer, but got " +
185 j.type_name() +
')');
189template <std::
floating_po
int T>
193 t = std::numeric_limits<T>::quiet_NaN();
194 }
else if (
j ==
"inf" ||
j ==
"+inf") {
195 t = std::numeric_limits<T>::infinity();
196 }
else if (
j ==
"-inf") {
197 t = -std::numeric_limits<T>::infinity();
202 "' (expected number or any of "
203 "\"nan\", \"inf\", \"+inf\", \"-inf\")");
205 }
else if (
j.is_number()) {
210 "' (expected number, but got " +
211 j.type_name() +
')');
216 requires(std::integral<T> || std::same_as<T, bool> ||
217 std::same_as<T, std::string>)
222template <std::
floating_po
int T>
226 else if (t == +std::numeric_limits<T>::infinity())
228 else if (t == -std::numeric_limits<T>::infinity())
236template <
class... Ts>
238template <
class... Ts>
241#define ALPAQA_GET_PARAM_INST(...) \
242 template void ALPAQA_EXPORT get_param( \
243 const util::possible_alias_t<__VA_ARGS__> &, json &)
244#define ALPAQA_GETSET_PARAM_INST(...) \
245 template void ALPAQA_EXPORT set_param( \
246 util::possible_alias_t<__VA_ARGS__> &, const json &); \
247 template void ALPAQA_EXPORT get_param( \
248 const util::possible_alias_t<__VA_ARGS__> &, json &)
273#define ALPAQA_GETSET_PARAM_INST_INT(...) \
274 ALPAQA_GETSET_PARAM_INST(__VA_ARGS__, int8_t, uint8_t, int16_t, uint16_t, \
275 int32_t, int64_t, uint32_t, uint64_t)
288 unsigned int,
unsigned short);
std::string demangled_typename(const std::type_info &t)
Get the pretty name of the given type as a string.
Parameters for the Augmented Lagrangian solver.
Parameters for the AndersonAccel class.
Parameters for the AndersonDirection class.
Tuning parameters for the FISTA algorithm.
Parameters for the LBFGSDirection class.
Parameters for the LBFGS class.
Parameters for the estimation of the Lipschitz constant of the gradient of the smooth term of the cos...
Parameters for the NewtonTRDirection class.
Tuning parameters for the PANOC algorithm.
Tuning parameters for the PANOC algorithm.
Tuning parameters for the PANTR algorithm.
Parameters for SteihaugCG.
Parameters for the StructuredNewtonDirection class.
Parameters for the StructuredNewtonDirection class.
Tuning parameters for the ZeroFPR algorithm.
#define ALPAQA_GETSET_PARAM_INST(...)
#define ALPAQA_GETSET_PARAM_INST_INT(...)
#define ALPAQA_GET_PARAM_INST(...)
constexpr bool is_duration
void get_param(const T &t, json &j)
Get the first argument as a JSON object j.
void set_param(T &t, const json &j)
Update/overwrite the first argument based on the JSON object j.
Unused unique type tag for template specializations that were rejected because some types were not di...
void parse_duration(std::chrono::duration< Rep, Period > &t, std::string_view s)
Adds the sum of the durations in the string s to the duration t.
typename Conf::real_t real_t
typename Conf::length_t length_t
typename Conf::cmvec cmvec
LBFGSStepSize
Which method to use to select the L-BFGS step size.
Parameters for the StructuredLBFGSDirection class.
Custom parameter parsing exception.
std::from_chars_result result