F77_SET(local_optimizer, LOCAL_OPTIMIZER, nlopt_opt)
F77_GETSET(population, POPULATION, unsigned)
+F77_GETSET(subspace_dim, SUBSPACE_DIM, unsigned)
F77_SETA(default_initial_step, DEFAULT_INITIAL_STEP, double)
F77_SETA(initial_step, INITIAL_STEP, double)
}
NLOPT_GETSET(unsigned, population)
+ NLOPT_GETSET(unsigned, subspace_dim)
NLOPT_GETSET_VEC(initial_step)
void set_default_initial_step(const std::vector<double> &x) {
nlopt_opt local_opt; /* local optimizer */
unsigned stochastic_population; /* population size for stochastic algs */
double *dx; /* initial step sizes (length n) for nonderivative algs */
+ unsigned subspace_dim; /* max subspace dimension (0 for default) */
double *work; /* algorithm-specific workspace during optimization */
};
NLOPT_EXTERN(nlopt_result) nlopt_set_population(nlopt_opt opt, unsigned pop);
NLOPT_EXTERN(unsigned) nlopt_get_population(const nlopt_opt opt);
+NLOPT_EXTERN(nlopt_result) nlopt_set_subspace_dim(nlopt_opt opt, unsigned dim);
+NLOPT_EXTERN(unsigned) nlopt_get_subspace_dim(const nlopt_opt opt);
+
NLOPT_EXTERN(nlopt_result) nlopt_set_default_initial_step(nlopt_opt opt,
const double *x);
NLOPT_EXTERN(nlopt_result) nlopt_set_initial_step(nlopt_opt opt,
#endif
case NLOPT_LD_LBFGS:
- return luksan_plis(ni, f, f_data, lb, ub, x, minf, &stop);
+ return luksan_plis(ni, f, f_data, lb, ub, x, minf,
+ &stop, opt->subspace_dim);
case NLOPT_LD_VAR1:
case NLOPT_LD_VAR2:
- return luksan_plip(ni, f, f_data, lb, ub, x, minf, &stop,
- algorithm == NLOPT_LD_VAR1 ? 1 : 2);
+ return luksan_plip(ni, f, f_data, lb, ub, x, minf,
+ &stop, opt->subspace_dim,
+ algorithm == NLOPT_LD_VAR1 ? 1 : 2);
case NLOPT_LD_TNEWTON:
case NLOPT_LD_TNEWTON_RESTART:
case NLOPT_LD_TNEWTON_PRECOND:
case NLOPT_LD_TNEWTON_PRECOND_RESTART:
- return luksan_pnet(ni, f, f_data, lb, ub, x, minf, &stop,
+ return luksan_pnet(ni, f, f_data, lb, ub, x, minf,
+ &stop, opt->subspace_dim,
1 + (algorithm - NLOPT_LD_TNEWTON) % 2,
1 + (algorithm - NLOPT_LD_TNEWTON) / 2);
opt->local_opt = NULL;
opt->stochastic_population = 0;
+ opt->subspace_dim = 0;
opt->dx = NULL;
opt->work = NULL;
/*************************************************************************/
GETSET(population, unsigned, stochastic_population)
+GETSET(subspace_dim, unsigned, subspace_dim)
/*************************************************************************/
const double *lb, const double *ub, /* bounds */
double *x, /* in: initial guess, out: minimizer */
double *minf,
- nlopt_stopping *stop);
+ nlopt_stopping *stop,
+ int mf);
nlopt_result luksan_plip(int n, nlopt_func f, void *f_data,
const double *lb, const double *ub, /* bounds */
double *x, /* in: initial guess, out: minimizer */
double *minf,
nlopt_stopping *stop,
+ int mf,
int method);
nlopt_result luksan_pnet(int n, nlopt_func f, void *f_data,
double *x, /* in: initial guess, out: minimizer */
double *minf,
nlopt_stopping *stop,
+ int mf,
int mos1, int mos2);
/***************************** internal routines *************************/
double *x, /* in: initial guess, out: minimizer */
double *minf,
nlopt_stopping *stop,
+ int mf, /* subspace dimension (0 for default) */
int method) /* 1 or 2, see below */
{
int i, *ix, nb = 1;
int mfv = stop->maxeval;
stat_common stat;
int iterm;
- int mf;
ix = (int*) malloc(sizeof(int) * n);
if (!ix) return NLOPT_OUT_OF_MEMORY;
and we'll assume that the main limiting factor is the memory.
We'll assume that at least MEMAVAIL memory, or 4*n memory, whichever
is bigger, is available. */
- mf = MAX2(MEMAVAIL/n, 4);
- if (stop->maxeval && stop->maxeval <= mf)
- mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ if (mf <= 0) {
+ mf = MAX2(MEMAVAIL/n, 4);
+ if (stop->maxeval && stop->maxeval <= mf)
+ mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ }
retry_alloc:
work = (double*) malloc(sizeof(double) * (n * 7 + MAX2(n,n*mf) +
const double *lb, const double *ub, /* bounds */
double *x, /* in: initial guess, out: minimizer */
double *minf,
- nlopt_stopping *stop)
+ nlopt_stopping *stop,
+ int mf) /* subspace dimension, 0 for default */
{
int i, *ix, nb = 1;
double *work, *xl, *xu, *xo, *gf, *s, *go, *uo, *vo;
int mfv = stop->maxeval;
stat_common stat;
int iterm;
- int mf;
ix = (int*) malloc(sizeof(int) * n);
if (!ix) return NLOPT_OUT_OF_MEMORY;
and we'll assume that the main limiting factor is the memory.
We'll assume that at least MEMAVAIL memory, or 4*n memory, whichever
is bigger, is available. */
- mf = MAX2(MEMAVAIL/n, 4);
- if (stop->maxeval && stop->maxeval <= mf)
- mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ if (mf <= 0) {
+ mf = MAX2(MEMAVAIL/n, 4);
+ if (stop->maxeval && stop->maxeval <= mf)
+ mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ }
retry_alloc:
work = (double*) malloc(sizeof(double) * (n * 4 + MAX2(n,n*mf)*2 +
double *x, /* in: initial guess, out: minimizer */
double *minf,
nlopt_stopping *stop,
+ int mf, /* subspace dimension (0 for default) */
int mos1, int mos2) /* 1 or 2 */
{
int i, *ix, nb = 1;
int mfv = stop->maxeval;
stat_common stat;
int iterm;
- int mf;
ix = (int*) malloc(sizeof(int) * n);
if (!ix) return NLOPT_OUT_OF_MEMORY;
and we'll assume that the main limiting factor is the memory.
We'll assume that at least MEMAVAIL memory, or 4*n memory, whichever
is bigger, is available. */
- mf = MAX2(MEMAVAIL/n, 4);
- if (stop->maxeval && stop->maxeval <= mf)
- mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ if (mf <= 0) {
+ mf = MAX2(MEMAVAIL/n, 4);
+ if (stop->maxeval && stop->maxeval <= mf)
+ mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ }
retry_alloc:
work = (double*) malloc(sizeof(double) * (n * 9 + MAX2(n,n*mf)*2 +
nlopt_set_maxtime(opt, struct_val_default(opts, "maxtime", 0.0));
nlopt_set_population(opt, struct_val_default(opts, "population", 0));
+ nlopt_set_subspace_dim(opt, struct_val_default(opts, "subspace_dim", 0));
if (struct_arrval(opts, "initial_step", n, NULL))
nlopt_set_initial_step(opt,
nlopt_set_maxtime(opt, struct_val_default(opts, "maxtime", 0.0));
nlopt_set_population(opt, struct_val_default(opts, "population", 0));
+ nlopt_set_subspace_dim(opt, struct_val_default(opts, "subspace_dim", 0));
if (opts.contains("initial_step")) {
Matrix zeros(1, n, 0.0);
%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_local_optimizer(const opt &lo);
-GETSET_EXCEPT(local_population, unsigned)
+GETSET_EXCEPT(population, unsigned)
+GETSET_EXCEPT(subspace_dim, unsigned)
GETSETVEC_EXCEPT(initial_step)
%catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_default_initial_step(const std::vector<double> &x);