34 throw std::invalid_argument(
"Cannot set value of std::monostate");
45 throw std::invalid_argument(
46 "Invalid value '" + std::string(s.
value) +
47 "' for type 'bool' in '" + std::string(s.
full_key) +
49 "possible values are: '0', '1', 'true', 'false'");
65 requires((std::floating_point<T> || std::integral<T>) &&
66 !std::is_enum_v<T> && !std::is_same_v<T, bool>)
71 if (
res.ec != std::errc())
72 throw std::invalid_argument(
73 "Invalid value '" + std::string(s.
value) +
"' for type '" +
75 "': " + std::make_error_code(
res.ec).message());
77 throw std::invalid_argument(
78 "Invalid suffix '" + std::string(
res.ptr,
val_end) +
83#ifdef ALPAQA_WITH_QUAD_PRECISION
94 v.resize(std::count(s.
value.begin(), s.
value.end(),
',') + 1);
105 if (s.
value.starts_with(
'@')) {
107 std::ifstream f(
fpath);
109 throw std::invalid_argument(
"Unable to open file '" +
fpath +
110 "' in '" + std::string(s.
full_key) +
113 auto r = alpaqa::csv::read_row_std_vector<real_t<config_t>>(f);
115 if (
v.expected_size >= 0 &&
r_size !=
v.expected_size)
116 throw std::invalid_argument(
117 "Incorrect size in '" + std::string(s.
full_key) +
118 "' (expected " + std::to_string(
v.expected_size) +
119 ", but got " + std::to_string(r.size()) +
')');
122 throw std::invalid_argument(
123 "Unable to read from file '" +
fpath +
"' in '" +
125 "': alpaqa::csv::read_error: " + e.what());
129 if (
v.expected_size >= 0 &&
v.value->size() !=
v.expected_size)
130 throw std::invalid_argument(
131 "Incorrect size in '" + std::string(s.
full_key) +
132 "' (expected " + std::to_string(
v.expected_size) +
133 ", but got " + std::to_string(
v.value->size()) +
')');
139template <
class Rep,
class Period>
142template <
class Duration>
150 "Invalid value '" + std::string(s.
value) +
"' for type '" +
152 std::string(std::string_view(s.
value.data(), e.
result.ptr)));
154 throw invalid_param(
"Invalid units '" + std::string(e.units) +
157 std::string(s.
value) +
"'");
172template <
class... Ts>
175#define ALPAQA_SET_PARAM_INST(...) \
176 template void ALPAQA_EXPORT set_param( \
177 util::possible_alias_t<__VA_ARGS__> &, ParamString)
198#define ALPAQA_SET_PARAM_INST_INT(...) \
199 ALPAQA_SET_PARAM_INST(__VA_ARGS__, int8_t, uint8_t, int16_t, uint16_t, \
200 int32_t, int64_t, uint32_t, uint64_t)
213 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(...)
Parameters for the StructuredLBFGSDirection class.
Custom parameter parsing exception.
std::from_chars_result result