libprima / prima

PRIMA is a package for solving general nonlinear optimization problems without using derivatives. It provides the reference implementation for Powell's derivative-free optimization methods, i.e., COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. PRIMA means Reference Implementation for Powell's methods with Modernization and Amelioration, P for Powell.
http://libprima.net
BSD 3-Clause "New" or "Revised" License
292 stars 36 forks source link

Enable the C interface to accept `nlconstr0` and `f0` #99

Closed zaikunzhang closed 8 months ago

zaikunzhang commented 9 months ago

See the discussion at

https://github.com/libprima/PRIMA.jl/issues/14#issuecomment-1770266055

for the reason.

Since C does not support optional inputs (unfortunately), let us do the following:

  1. if the user does not want to input nlconstr0, then it should be set to NULL;
  2. if the user does not want to input f0, then it should be set to NaN;
  3. in cobyla_c.f90, check the values of nlconstr0 and f0 to decide whether to call cobyla with nlconstr0 &f0 or without them (they are optional inputs to cobyla);
  4. (an alternative to 3) in cobyla_c.f90, check the values of nlconstr0 and f0. If nlconstr0 is NULL of f0 is NaN, then call calcfc to evaluate them; afterwards, call cobyla with nlconstr0 and f0.

Thanks.

jschueller commented 9 months ago

optional options could be passed via a pointer to a struct:

prima_options opt;
prima_init_options(&opt);
opt.nlconstr0 = ...
opt.f0 = ...
opt.eta1 = ...
prima_cobyla(..., &opt) // with options
prima_cobyla(..., NULL) // without options