+static int inequality_ok(nlopt_algorithm algorithm) {
+ /* nonlinear constraints are only supported with some algorithms */
+ return (algorithm == NLOPT_LD_MMA
+ || algorithm == NLOPT_LN_COBYLA
+ || AUGLAG_ALG(algorithm)
+ || algorithm == NLOPT_GN_ISRES
+ || algorithm == NLOPT_GN_ORIG_DIRECT
+ || algorithm == NLOPT_GN_ORIG_DIRECT_L);
+}
+
+nlopt_result
+NLOPT_STDCALL nlopt_add_inequality_mconstraint(nlopt_opt opt, unsigned m,
+ nlopt_mfunc fc, void *fc_data,
+ const double *tol)
+{
+ if (!m) return NLOPT_SUCCESS; /* empty constraints are always ok */
+ if (!opt || !inequality_ok(opt->algorithm)) return NLOPT_INVALID_ARGS;
+ return add_constraint(&opt->m, &opt->m_alloc, &opt->fc,
+ m, NULL, fc, fc_data, tol);
+}
+