Commit cff7a3fb authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Add assertion for NLOptNoGrad [ci skip]

parent 913e03a8
......@@ -116,6 +116,14 @@ namespace limbo {
template <typename F>
Eigen::VectorXd operator()(const F& f, const Eigen::VectorXd& init, bool bounded) const
{
// Assert that the algorithm is gradient-based
// clang-format off
static_assert(Algorithm == nlopt::LD_MMA || Algorithm == nlopt::LD_SLSQP ||
Algorithm == nlopt::LD_LBFGS || Algorithm == nlopt::LD_TNEWTON_PRECOND_RESTART ||
Algorithm == nlopt::LD_TNEWTON_PRECOND || Algorithm == nlopt::LD_TNEWTON_RESTART ||
Algorithm == nlopt::LD_TNEWTON || Algorithm == nlopt::LD_VAR2 ||
Algorithm == nlopt::LD_VAR1, "NLOptGrad accepts gradient-based nlopt algorithms only");
// clang-format on
int dim = init.size();
nlopt::opt opt(Algorithm, dim);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment