I have a set of complicated 100 constraints which can be computed numerically for the given iterative values of the design variables. Once evaluated the lhs of the constraints are available as a vector with all numbers. All the constraints are of the form (number <= 0).
How can I state that each of these elements of the vector should be <= 0 inside NMinimize ?
In the following trivial example I have used a simple constraint function for better communication; but my actual problem is more complicated and has 3 design variables.
f[x_] := -x^2 + 4 x;
const[x_?NumericQ] := Module[{n, xs, j, xval, ret},
n = 100;
xs = Table[j*(x/n), {j, 1, n}];
ret = {-1};
For[j = 1, j <= n, j++,
xval = xs[[j]];
ret = Join[ret, {f[xval]}];
];
Return[ret];
]
The optimization part
NMinimize[x^2 - 28 x, Thread[const[x] <= 0], {x}]
Returns the following error
NMinimize::bcons: The following constraints are not valid:
{const[x]<=0}. Constraints should be equalities, inequalities,
or domain specifications involving the variables. >>