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

LH_SEARCH for MATLAB interface #162

Closed stumarcus314 closed 5 months ago

stumarcus314 commented 5 months ago

I am trying to solve an optimization problem in MATLAB using NOMAD. The problem has 15 discrete variables, an objective, and 4 constraints.

I am trying to use LH_SEARCH (Latin hypercube search) in NOMAD, but I get the error below because I set the intial guess x0 to the empty array []. If I do provide an initial guess, then nomadOpt seems to work, but I don't know if it's using LH_SEARCH or the initial guess. How can I use LH_Search with the NOMAD MATLAB interface? What is the meaning of 0 in the second input of lh_search_str, which is the argument for LH_SEARCH? What are the meanings of p0 and pi in the LH_SEARCH documentation (https://nomad-4-user-guide.readthedocs.io/en/latest/HowToUseNomad.html#algorithmic-parameters)? LH_SEARCH | 2 integers: p0 and pi | LH (Latin-Hypercube) search (p0: initial and pi: iterative)

nvars = 15; xtype_new = strcat('(',repmat('I ',1,nvars),')'); lh_search_str = strcat(num2str(nvars),' 0'); NOMAD_params3 = struct('display_degree','2','bb_output_type','OBJ EB EB EB EB','bb_input_type',xtype_new,'max_bb_eval','500','LH_SEARCH',lh_search_str,'EVAL_OPPORTUNISTIC','false');


[x_nomad3,fval_nomad3,hinf_nomad3,runflag_nomad3,nfval_nomad3] = nomadOpt(mfun2,[],lb,ub,NOMAD_params3); Error using nomadOpt x0 must be a real double column vector!

Error in try_ga (line 138) [x_nomad3,fval_nomad3,hinf_nomad3,runflag_nomad3,nfval_nomad3] = nomadOpt(mfun2,[],lb,ub,NOMAD_params3);

[x_nomad3,fval_nomad3,hinf_nomad3,runflag_nomad3,nfval_nomad3] = nomadOpt(mfun2,x0,lb,ub,NOMAD_params3);

This is NOMAD v4.4.0 Authors: C. Audet, S. Le Digabel, V. Rochon Montplaisir and C. Tribes MEX Interface C. Tribes 2023

Problem Properties:

Decision Variables: 15

Number of Objectives: 1

Number of Nonlinear Constraints: 4


1 -6 A termination criterion is reached: Maximum number of blackbox evaluations (Eval Global)Phase one search did not return a feasible point (Algo) 500

Best feasible solution: Undefined.

Best infeasible solution: Undefined.

Blackbox evaluations: 500 Cache hits: 3864 Total number of evaluations: 4364 NO solution obtained

x_nomad3 =

 6
79
 4
12
 6
22
60
14
38
69
62
68
21
15
56

fval_nomad3 =

 0

hinf_nomad3 =

 1

runflag_nomad3 =

-2
ctribes commented 5 months ago

When using the Nomad with the Matlab interface, X0 is required (unlike the regular Nomad).

If X0 is provided along with 'LH_SEARCH p0 p1' (p0 >0). Both X0 and initial LH points are evaluated non-opportunistically. I modified the example problem provided:

`

fun = @(x) (1-x(1))^2 + 100 *(x(2)-x(1)^2)^2; x0 = [100 100]'; lb = [-5;-1.5]; ub = [100;100];

params = struct('LH_SEARCH','10 0','DISPLAY_DEGREE','2','DISPLAY_ALL_EVAL','yes','MAX_BB_EVAL','100','DISPLAY_STATS','bbe (sol) obj');

[x,fval,hinf,exit_status,nfeval] = nomadOpt(fun,x0,lb,ub,params); `

I obtained the following output. The 10 points generated by the initial LH have many digits. The X0 point is added to these points. The 11 points are sorted lexicographically. The 11 points are evaluated non-opportunistically. From evaluation 12, the Mads algorithm continues.

`


This is NOMAD v4.4.0 Authors: C. Audet, S. Le Digabel, V. Rochon Montplaisir and C. Tribes MEX Interface C. Tribes 2023

.....

1 ( 4.718127 31.429576 ) 8420.6108
2 ( 12.130817 43.482465 ) 1074958.915421 3 ( 26.042984 71.425116 ) 36822693.646252 4 ( 31.087577 -0.381166 ) 93474728.289178 5 ( 38.02607 53.006215 ) 194039530.78291 6 ( 54.472361 13.719585 ) 872330039.575446 7 ( 62.695508 64.38667 ) 1494862369.379277 8 ( 69.215454 88.32244 ) 2211314528.476872 9 ( 81.046044 26.185498 ) 4280143611.157871 10 ( 94.418669 98.951916 ) 7772076356.435029 11 ( 100 100 ) 9801009801
12 ( 24.718127 21.429576 ) 34758217.626641 13 ( -5 51.429576 ) 69888.251117 14 ( -5 41.429576 ) 27029.098223 15 ( 4.718127 21.429576 ) 82.905021 `

ctribes commented 5 months ago

The parameter LH_SEARCH has two arguments: p0 and p1. p0 is the number of initial search points. Those are generated and evaluated before the Mads iterations are started. p1 is the number of points generated by LH at each Search step of Mads. Mads is an iterative algorithm. One iteration consists of a Search and a Poll if the Search is not a success. The Search step has several default methods. LH is optional.

stumarcus314 commented 5 months ago

Thanks for the explanations. LH_SEARCH seems to be working now for my problem using NOMAD's MATLAB interface.