简体   繁体   中英

Multiple constrain to fmincon? MATLAB

I'm not sure that fmincon is the best solution for optimization with multiple parameters.

I want to optimize two parameters: inp_1 with allowed values between 1 and 2 for which I used this code

inp_1 = 1
Ub= 2*inp_1 ; Lb= 0.5*inp_1;
options = optimoptions('fmincon',...
         'FiniteDifferenceType','central',...
         'DiffMaxChange',0.5,...
         'DiffMinChange',1e-1,...
         'MaxIter',20,...
         'MaxFunEvals',200,...
         'Display','iter',...  % 'iter'
         'OptimalityTolerance',1e-13);
[param,distance,exitflag,output,lambda,grad,hessian]  = fmincon(@optimization_func,inp_1 ,[],[],[],[],[],Lb,Ub,options);

and everything works fine. If I want to add another dependecy, like inp_2 with allowed values between 0 to 360 , I can set a vector x as x(1) = inp_1; and x(2) = inp_2 and pass x to fmincon.

In this way options are not correct anymore, since I need to set other options, especially for DiffMinChange and DiffMaxChange . Which is the best solution here for multiple-different constrains?

As far as I know, the options DiffMinChange and DiffMaxChange always apply to the whole vector and cannot be tuned per-element.

What you could do is normalize all your variables to be in the unit [0,1] interval so that you are fine with a global setting in DiffMinChange and DiffMaxChange . Then apply denormalization inside your cost function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM