37 throw std::invalid_argument(
38 "Invalid value '" + std::string(s.
value) +
39 "' for type 'bool' in '" + std::string(s.
full_key) +
41 "possible values are: '0', '1', 'true', 'false'");
57 requires((std::floating_point<T> || std::integral<T>) &&
58 !std::is_enum_v<T> && !std::is_same_v<T, bool>)
63 if (
res.ec != std::errc())
64 throw std::invalid_argument(
65 "Invalid value '" + std::string(s.
value) +
"' for type '" +
67 "': " + std::make_error_code(
res.ec).message());
69 throw std::invalid_argument(
70 "Invalid suffix '" + std::string(
res.ptr,
val_end) +
75#ifdef ALPAQA_WITH_QUAD_PRECISION
86 v.resize(std::count(s.
value.begin(), s.
value.end(),
',') + 1);
97 if (s.
value.starts_with(
'@')) {
99 std::ifstream f(
fpath);
101 throw std::invalid_argument(
"Unable to open file '" +
fpath +
102 "' in '" + std::string(s.
full_key) +
105 auto r = alpaqa::csv::read_row_std_vector<real_t<config_t>>(f);
107 if (
v.expected_size >= 0 &&
r_size !=
v.expected_size)
108 throw std::invalid_argument(
109 "Incorrect size in '" + std::string(s.
full_key) +
110 "' (expected " + std::to_string(
v.expected_size) +
111 ", but got " + std::to_string(r.size()) +
')');
114 throw std::invalid_argument(
115 "Unable to read from file '" +
fpath +
"' in '" +
117 "': alpaqa::csv::read_error: " + e.what());
121 if (
v.expected_size >= 0 &&
v.value->size() !=
v.expected_size)
122 throw std::invalid_argument(
123 "Incorrect size in '" + std::string(s.
full_key) +
124 "' (expected " + std::to_string(
v.expected_size) +
125 ", but got " + std::to_string(
v.value->size()) +
')');
131template <
class Rep,
class Period>
134template <
class Duration>
142 "Invalid value '" + std::string(s.
value) +
"' for type '" +
144 std::string(std::string_view(s.
value.data(), e.
result.ptr)));
146 throw invalid_param(
"Invalid units '" + std::string(e.units) +
149 std::string(s.
value) +
"'");
155 if (s.
value ==
"BasedOnExternalStepSize")
157 else if (s.
value ==
"BasedOnCurvature")
160 throw std::invalid_argument(
"Invalid value '" + std::string(s.
value) +
161 "' for type 'LBFGSStepSize' in '" +
167 if (s.
value ==
"ApproxKKT")
169 else if (s.
value ==
"ApproxKKT2")
171 else if (s.
value ==
"ProjGradNorm")
173 else if (s.
value ==
"ProjGradNorm2")
175 else if (s.
value ==
"ProjGradUnitNorm")
177 else if (s.
value ==
"ProjGradUnitNorm2")
179 else if (s.
value ==
"FPRNorm")
181 else if (s.
value ==
"FPRNorm2")
183 else if (s.
value ==
"Ipopt")
185 else if (s.
value ==
"LBFGSBpp")
188 throw std::invalid_argument(
"Invalid value '" + std::string(s.
value) +
189 "' for type 'PANOCStopCrit' in '" +
195template <
class... Ts>
198#define ALPAQA_SET_PARAM_INST(...) \
199 template void ALPAQA_EXPORT set_param( \
200 util::possible_alias_t<__VA_ARGS__> &, ParamString)
221#define ALPAQA_SET_PARAM_INST_INT(...) \
222 ALPAQA_SET_PARAM_INST(__VA_ARGS__, int8_t, uint8_t, int16_t, uint16_t, \
223 int32_t, int64_t, uint32_t, uint64_t)
236 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 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.
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.
std::string_view value
The value of the parameter to store.
void set_param(T &t, const json &j)
Update/overwrite the first argument based on the JSON object j.
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)
@ LBFGSBpp
The stopping criterion used by LBFGS++, see https://lbfgspp.statr.me/doc/classLBFGSpp_1_1LBFGSBParam....
@ ProjGradUnitNorm
∞-norm of the projected gradient with unit step size:
@ ProjGradNorm
∞-norm of the projected gradient with step size γ:
@ Ipopt
The stopping criterion used by Ipopt, see https://link.springer.com/article/10.1007/s10107-004-0559-y...
@ FPRNorm2
2-norm of fixed point residual:
@ ProjGradNorm2
2-norm of the projected gradient with step size γ:
@ ApproxKKT
Find an ε-approximate KKT point in the ∞-norm:
@ FPRNorm
∞-norm of fixed point residual:
@ ApproxKKT2
Find an ε-approximate KKT point in the 2-norm:
@ ProjGradUnitNorm2
2-norm of the projected gradient with unit step size:
typename Conf::length_t length_t
typename Conf::cmvec cmvec
LBFGSStepSize
Which method to use to select the L-BFGS step size.
@ BasedOnCurvature
Initial inverse Hessian approximation is set to .
@ BasedOnExternalStepSize
Initial inverse Hessian approximation is set to , where is the forward-backward splitting 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