Hello,
I have just started using NLopt, with GNU Octave, and I have a strange problem, in that I have to force the starting vector and bounds to be real (even if they are already real, according to isreal() ), but only when using the global optimization (*_GN_*)routines.
When I use the local optimization (*_LN_*) routines everything works fine...
Maybe I'm missing something obvious or maybe my Octave installation is broken or... Could please someone check if they see the same behavior with the code below?
I'm using NLopt 2.2.4 and Octave 3.4.3 .

Thanks,
  Claudio

8<--------8<--------8<--------8<--------

# Prevent Octave from thinking that this
# is a function file
1;

nvar = 11;

apar = ones(1, nvar);
# need to force apar to be real, otherwise I get an 'x must be real vector'
#  when using global optimizaton routines
#apar = real(apar);


# simple function for testibg
function [val, gradient] = nlopt_func(apar)
  if (nargout > 1)
    gradient = 0;
  end

  val = apar*apar';
endfunction


opt.lower_bounds = -10 * ones(size(apar));
opt.upper_bounds = 10.0 * ones(size(apar));

# need to force the bounds to be real, otherwise I get a '-2' (Invalid arguments) return code
#  when using global optimizaton routines
#opt.lower_bounds = real(opt.lower_bounds);
#opt.upper_bounds = real(opt.upper_bounds);


## global algos
opt.algorithm = NLOPT_GN_DIRECT_L;
#opt.algorithm = NLOPT_GN_ORIG_DIRECT_L;
#opt.algorithm = NLOPT_GN_CRS2_LM;
#opt.algorithm = NLOPT_GN_ISRES;
## local algos
#opt.algorithm = NLOPT_LN_COBYLA;
#opt.algorithm = NLOPT_LN_BOBYQA;

opt.min_objective = @nlopt_func;
opt.xtol_rel = 1e-4;
opt.verbose = 1;
opt.maxeval = 10000;

[a, fmin, retcode] = nlopt_optimize(opt, apar)

8<--------8<--------8<--------8<--------

_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to