35 throw std::invalid_argument(
"Cannot set value of std::monostate");
46 throw std::invalid_argument(
47 "Invalid value '" + std::string(s.
value) +
48 "' for type 'bool' in '" + std::string(s.
full_key) +
50 "possible values are: '0', '1', 'true', 'false'");
66 requires((std::floating_point<T> || std::integral<T>) &&
67 !std::is_enum_v<T> && !std::is_same_v<T, bool>)
72 if (res.ec != std::errc())
73 throw std::invalid_argument(
74 "Invalid value '" + std::string(s.
value) +
"' for type '" +
76 "': " + std::make_error_code(res.ec).message());
78 throw std::invalid_argument(
79 "Invalid suffix '" + std::string(res.ptr,
val_end) +
84#ifdef ALPAQA_WITH_QUAD_PRECISION
95 v.resize(std::count(s.
value.begin(), s.
value.end(),
',') + 1);
106 if (s.
value.starts_with(
'@')) {
108 std::ifstream f(
fpath);
110 throw std::invalid_argument(
"Unable to open file '" +
fpath +
111 "' in '" + std::string(s.
full_key) +
114 auto r = alpaqa::csv::read_row_std_vector<real_t<config_t>>(f);
116 if (
v.expected_size >= 0 &&
r_size !=
v.expected_size)
117 throw std::invalid_argument(
118 "Incorrect size in '" + std::string(s.
full_key) +
119 "' (expected " + std::to_string(
v.expected_size) +
120 ", but got " + std::to_string(r.size()) +
')');
123 throw std::invalid_argument(
124 "Unable to read from file '" +
fpath +
"' in '" +
126 "': alpaqa::csv::read_error: " + e.what());
130 if (
v.expected_size >= 0 &&
v.value->size() !=
v.expected_size)
131 throw std::invalid_argument(
132 "Incorrect size in '" + std::string(s.
full_key) +
133 "' (expected " + std::to_string(
v.expected_size) +
134 ", but got " + std::to_string(
v.value->size()) +
')');
140template <
class Rep,
class Period>
143template <
class Duration>
151 "Invalid value '" + std::string(s.
value) +
"' for type '" +
153 std::string(std::string_view(s.
value.data(), e.
result.ptr)));
155 throw invalid_param(
"Invalid units '" + std::string(e.units) +
158 std::string(s.
value) +
"'");
173template <
class... Ts>
176#define ALPAQA_SET_PARAM_INST(...) \
177 template void ALPAQA_EXPORT set_param( \
178 util::possible_alias_t<__VA_ARGS__> &, ParamString)
199#define ALPAQA_SET_PARAM_INST_INT(...) \
200 ALPAQA_SET_PARAM_INST(__VA_ARGS__, int8_t, uint8_t, int16_t, uint16_t, \
201 int32_t, int64_t, uint32_t, uint64_t)
214 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 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.
void set_param_default(T &t, const json &j)
constexpr bool is_duration
std::string_view full_key
Full key string, used for diagnostics.
auto split_key(std::string_view full, char tok='.')
Split the string full on the first occurrence of tok.
void set_param(T &, const json &j)
Update/overwrite the first argument based on the JSON object j.
std::string_view value
The value of the parameter to store.
Represents a parameter value encoded as a string in the format abc.def.key=value.
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.
std::from_chars_result from_chars(const char *first, const char *last, T &value, std::chars_format fmt=std::chars_format::general)
typename Conf::length_t length_t
typename Conf::cmvec cmvec
LBFGSStepSize
Which method to use to select the L-BFGS step size.
#define ALPAQA_SET_PARAM_INST(...)
#define ALPAQA_SET_PARAM_INST_INT(...)
Flags to be passed to dlopen.
Parameters for the StructuredLBFGSDirection class.
Custom parameter parsing exception.
std::from_chars_result result