To implement unrelated constraints with a single function, you can do
something like (for example):
double myconstraints(int n, const double *x, double *grad, void *data)
{
int which = *((int *) data);
switch (which) {
case 1:
....do first constraint....
break;
case 2:
...do second constraint....
break;
...
}
}
and then pass it to nlopt via:
int which_constraint[m] = {1, 2, 3, ....};
nlopt_minimize_constrained(.....,
m, myconstraints,
which_constraint, sizeof(int),
....);
On Apr 21, 2010, at 10:18 AM, Erman Terciyanlı wrote:
Hi again,
I have found your answer about that question below. But I am not
sure whether understand true or wrong. I think it may be clear if I
can see an example code…
Erman
This is not necessary; the constraints can be arbitrary. For example,
your state parameter could just be an integer i and you constraint
function could have a switch statement that does something completely
different for each value of i.
Steven
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss