bbopt / nomad

NOMAD - A blackbox optimization software
https://nomad-4-user-guide.readthedocs.io/
GNU Lesser General Public License v3.0
110 stars 24 forks source link

Multiple Starting Points for MATLAB interface #170

Open stumarcus314 opened 1 month ago

stumarcus314 commented 1 month ago

Is it possible to provide multiple starting points to NOMAD through the MATLAB interface in the parameter X0? I get the error below when I try to provide 2 starting points, each in its own row of X0.

N = 3; % Number of binary variables. xtype_new = strcat('(',repmat('B ',1,N),')'); NOMAD_params = struct('display_degree','2','display_all_eval','no','bb_output_type','OBJ','bb_input_type',xtype_new); lb = zeros(1,N); % Lower bounds on variables. ub = ones(1,N); % Upper bounds on variables. X0 = randi([0 1],2,N); % A pair of random initial starting points, each in a row of X0. nomadOpt(META_cf,X0,lb,ub,NOMAD_params);

Error using nomadOpt lb is not the same length as x0! Ensure they are both Column Vectors

ctribes commented 1 month ago

You can try

NOMAD_params = struct('display_degree','2','display_all_eval','no','bb_output_type','OBJ','bb_input_type',xtype_new,'X0','x0s.txt');

With x0s.txt a file containing one x0 point per line.

stumarcus314 commented 1 month ago

That seems to work. Thanks. The following MATLAB code writes the matrix of starting points X0 to a text file called 'x0s.txt' with space delimiters.

writematrix(X0,'x0s.txt','Delimiter','space');

stumarcus314 commented 1 month ago

Does NOMAD internally maintain a population of good solutions, or does it only operate on the best known solution? For example, if the starting points in the matrix X0 have already been evaluated in the objective function, maybe it only makes sense to provide NOMAD with the best of the starting points rather than all of them. For a genetic algorithm, it is often beneficial to provide a population of good starting points, from which other candidate points are generated.

ctribes commented 1 month ago

In Nomad we keep all solutions. When several x0s are provided, they are all evaluated. The poll and search steps are centered around the best feasible and infeasible solutions. But Nomad uses all solutions to build quadratic models (used by default). Which can help improving objective function reduction. Also, the good solution around the current bests (feasible and infeasible) are used by the Nelder-Mead search method (used by default).