37template <
class Rep,
class Period>
40template <
class Duration>
45 "Invalid value " +
to_string(
j) +
" for type '" +
47 std::string value =
j;
52 "Invalid value '" + value +
"' for type '" +
54 std::string(std::string_view(value.data(), e.
result.ptr)));
57 "Invalid units '" + std::string(e.units) +
"' for type '" +
62template <
class Duration>
65 namespace chr = std::chrono;
68 if (
dur.count() == 0) {
72 result += std::to_string(d.count()) +
"h";
76 result += std::to_string(d.count()) +
"min";
80 result += std::to_string(d.count()) +
"s";
84 result += std::to_string(d.count()) +
"ms";
88 result += std::to_string(d.count()) +
"µs";
92 result += std::to_string(d.count()) +
"ns";
96 s = std::move(result);
104 "' (expected an array, but got " +
105 j.type_name() +
')');
110 }
catch (json::exception &e) {
112 " (expected a number, but got " +
113 j.type_name() +
"): " + e.what());
116 std::ranges::transform(
j,
v.begin(),
convert);
123 std::ifstream f(
fpath);
129 auto r = alpaqa::csv::read_row_std_vector<real_t<config_t>>(f);
131 if (
v.expected_size >= 0 &&
r_size !=
v.expected_size)
133 "Incorrect size in '" +
fpath +
"' (expected " +
134 std::to_string(
v.expected_size) +
", but got " +
135 std::to_string(r.size()) +
")");
139 "': alpaqa::csv::read_error: " + e.what());
141 }
else if (
j.is_array()) {
143 if (
v.expected_size >= 0 &&
v.value->size() !=
v.expected_size)
145 "Incorrect size in " +
to_string(
j) +
"' (expected " +
146 std::to_string(
v.expected_size) +
", but got " +
147 std::to_string(
v.value->size()) +
')');
151 "' (expected string or array, but got " +
152 j.type_name() +
')');
166 "' (expected boolean, but got " +
167 j.type_name() +
')');
168 t =
static_cast<bool>(
j);
176 "' (expected string, but got " +
177 j.type_name() +
')');
178 t =
static_cast<std::string
>(
j);
181template <std::
integral T>
182 requires(!std::same_as<T, bool>)
184 if (std::unsigned_integral<T> && !
j.is_number_unsigned())
187 "' (expected unsigned integer, but got " +
188 j.type_name() +
')');
189 if (!
j.is_number_integer())
192 "' (expected integer, but got " +
193 j.type_name() +
')');
194 t =
static_cast<T>(
j);
197template <std::
floating_po
int T>
201 t = std::numeric_limits<T>::quiet_NaN();
202 }
else if (
j ==
"inf" ||
j ==
"+inf") {
203 t = std::numeric_limits<T>::infinity();
204 }
else if (
j ==
"-inf") {
205 t = -std::numeric_limits<T>::infinity();
210 "' (expected number or any of "
211 "\"nan\", \"inf\", \"+inf\", \"-inf\")");
213 }
else if (
j.is_number()) {
214 t =
static_cast<T>(
j);
218 "' (expected number, but got " +
219 j.type_name() +
')');
224 requires(std::integral<T> || std::same_as<T, bool> ||
225 std::same_as<T, std::string>)
230template <std::
floating_po
int T>
234 else if (t == +std::numeric_limits<T>::infinity())
236 else if (t == -std::numeric_limits<T>::infinity())
257template <
class... Ts>
259template <
class... Ts>
262#define ALPAQA_GET_PARAM_INST(...) \
263 template void ALPAQA_EXPORT get_param( \
264 const util::possible_alias_t<__VA_ARGS__> &, json &)
265#define ALPAQA_GETSET_PARAM_INST(...) \
266 template void ALPAQA_EXPORT set_param( \
267 util::possible_alias_t<__VA_ARGS__> &, const json &); \
268 template void ALPAQA_EXPORT get_param( \
269 const util::possible_alias_t<__VA_ARGS__> &, json &)
294#define ALPAQA_GETSET_PARAM_INST_INT(...) \
295 ALPAQA_GETSET_PARAM_INST(__VA_ARGS__, int8_t, uint8_t, int16_t, uint16_t, \
296 int32_t, int64_t, uint32_t, uint64_t)
309 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.
Parameters for the ConvexNewtonDirection class.
Parameters for the ConvexNewtonDirection 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(...)
void get_param(const T &, json &j)
Get the first argument as a JSON object j.
void get_param_default(const T &t, json &j)
void set_param_default(T &t, const json &j)
constexpr bool is_duration
void set_param(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.
Flags to be passed to dlopen.
Parameters for the StructuredLBFGSDirection class.
Custom parameter parsing exception.
std::from_chars_result result