-Modify luksan code (e.g. luksan/plis.c) to use full NLopt stopping
-criteria, and in particular the absolute tolerances and maxtime.
-
Python interface.
SLSQP routine from scipy.
void luksan_pyadc0__(int *nf, int *n, double *x,
int *ix, double *xl, double *xu, int *inew);
void luksan_pyfut1__(int *n, double *f, double *
- fo, double *umax, double *gmax, double *dmax__,
- double *tolx, double *tolf, double *tolb, double *
- tolg, int *kd, int *nit, int *kit, int *mit, int *
- nfv, int *mfv, int *nfg, int *mfg, int *ntesx,
+ fo, double *umax, double *gmax,
+ int xstop, const nlopt_stopping *stop,
+ double *tolg, int *kd, int *nit, int *kit, int *mit,
+ int *nfg, int *mfg, int *ntesx,
int *mtesx, int *ntesf, int *mtesf, int *ites,
int *ires1, int *ires2, int *irest, int *iters,
int *iterm);
double eps8, eps9;
int meta, mred, nred, iold;
double maxf, dmax__;
+ int xstop = 0;
int inew;
double told;
int ites;
++stat_1->nfg;
L11120:
luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
- luksan_pyfut1__(nf, f, &fo, &umax, gmax, &dmax__, tolx, tolf, tolb, tolg,
- &kd, &stat_1->nit, &kit, mit, &stop->nevals, mfv, &stat_1->nfg, &mfg,
+ luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg,
+ &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, &mfg,
&ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
iters, iterm);
if (*iterm != 0) {
luksan_mxuneg__(nf, &go[1], &s[1], &ix[1], &kbf);
luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+ xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
luksan_mxucop__(nf, &gf[1], &so[1], &ix[1], &kbf);
if (nn < *mf) {
luksan_pulsp3__(nf, &nn, mf, &xm[1], &gr[1], &xo[1], &go[1], &r__, &
double eps8, eps9;
int mred, iold, nred;
double maxf, dmax__;
+ int xstop = 0;
int inew;
double told;
int ites;
++stat_1->nfg;
L11120:
luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
- luksan_pyfut1__(nf, f, &fo, &umax, gmax, &dmax__, tolx, tolf, tolb, tolg,
- &kd, &stat_1->nit, &kit, mit, &stop->nevals, mfv, &stat_1->nfg, &mfg,
+ luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg,
+ &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, &mfg,
&ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
iters, iterm);
if (*iterm != 0) {
}
luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+ xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
L11175:
if (kbf > 0) {
luksan_mxvine__(nf, &ix[1]);
double rho1, rho2, eps8, eps9;
int mred, iold, nred;
double maxf, dmax__;
+ int xstop = 0;
int inew;
double told;
int ites;
L11020:
luksan_pytrcg__(nf, nf, &ix[1], &gf[1], &umax, gmax, &kbf, &iold);
luksan_mxvcop__(nf, &gf[1], &gn[1]);
- luksan_pyfut1__(nf, f, &fo, &umax, gmax, &dmax__, tolx, tolf, tolb, tolg,
- &kd, &stat_1->nit, &kit, mit, &stop->nevals, mfv, &stat_1->nfg, mfg, &
+ luksan_pyfut1__(nf, f, &fo, &umax, gmax, xstop, stop, tolg,
+ &kd, &stat_1->nit, &kit, mit, &stat_1->nfg, mfg, &
ntesx, &mtesx, &ntesf, &mtesf, &ites, &ires1, &ires2, &irest, &
iters, iterm);
if (*iterm != 0) {
}
luksan_pytrcd__(nf, &x[1], &ix[1], &xo[1], &gf[1], &go[1], &r__, f, &fo, &
p, &po, &dmax__, &kbf, &kd, &ld, &iters);
+ xstop = nlopt_stop_dx(stop, &x[1], &xo[1]);
if (*mos2 > 1) {
/* Computing MIN */
i__1 = mx + 1;
* ITERATIONS. ITERM=12-TERMINATION AFTER MAXIMUM NUMBER OF
* COMPUTED FUNCTION VALUES.
*/
-void luksan_pyfut1__(int *n, double *f, double *
- fo, double *umax, double *gmax, double *dmax__,
- double *tolx, double *tolf, double *tolb, double *
- tolg, int *kd, int *nit, int *kit, int *mit, int *
- nfv, int *mfv, int *nfg, int *mfg, int *ntesx,
+void luksan_pyfut1__(int *n, double *f, double *fo, double *umax,
+ double *gmax, int xstop, /* double *dmax__, */
+ const nlopt_stopping *stop,
+ double *tolg, int *kd, int *nit, int *kit, int *mit,
+ int *nfg, int *mfg, int *ntesx,
int *mtesx, int *ntesf, int *mtesf, int *ites,
int *ires1, int *ires2, int *irest, int *iters,
int *iterm)
/* Builtin functions */
- /* Local variables */
- double temp;
-
if (*iterm < 0) {
return;
}
d__1 = sqrt((fabs(*f))), d__2 = fabs(*f) / 10.;
*fo = *f + min(d__1,d__2);
}
- if (*f <= *tolb) {
+ if (*f <= stop->minf_max /* *tolb */) {
*iterm = 3;
return;
}
*ntesx = 0;
*ntesf = 0;
}
- if (*dmax__ <= *tolx) {
+ if (xstop) /* (*dmax__ <= *tolx) */ {
*iterm = 1;
++(*ntesx);
if (*ntesx >= *mtesx) {
} else {
*ntesx = 0;
}
-/* Computing MAX */
- d__2 = fabs(*f);
- temp = (d__1 = *fo - *f, fabs(d__1)) / max(d__2,1.);
- if (temp <= *tolf) {
+ if (nlopt_stop_ftol(stop, *f, *fo)) {
*iterm = 2;
++(*ntesf);
if (*ntesf >= *mtesf) {
*iterm = 11;
return;
}
- if (*nfv >= *mfv) {
+ if (nlopt_stop_evals(stop)) /* (*nfv >= *mfv) */ {
*iterm = 12;
return;
}
extern int nlopt_stop_ftol(const nlopt_stopping *stop, double f, double oldf);
extern int nlopt_stop_x(const nlopt_stopping *stop,
const double *x, const double *oldx);
+extern int nlopt_stop_dx(const nlopt_stopping *stop,
+ const double *x, const double *dx);
extern int nlopt_stop_xs(const nlopt_stopping *stop,
const double *xs, const double *oldxs,
const double *scale_min, const double *scale_max);
return 1;
}
+int nlopt_stop_dx(const nlopt_stopping *s, const double *x, const double *dx)
+{
+ int i;
+ for (i = 0; i < s->n; ++i)
+ if (!relstop(x[i] - dx[i], x[i], s->xtol_rel, s->xtol_abs[i]))
+ return 0;
+ return 1;
+}
+
static double sc(double x, double smin, double smax)
{
return smin + x * (smax - smin);