Choosing the best algorithm for fmincon

18 次查看(过去 30 天)
I am using fmincon to optimize a variable given the constraints of other variables in a complex system of equations.
The actual math doesn't matter so much as if it is possible to compare first order optimality of fmincon based on different function options without having to do it manually.
It's pretty easy to visually look and see which algorithm performed the best in any given circumstance, but I'd like the code to choose out of the three algorithms used, which one performed the best given the conditions.
I haven't seen anywhere the ability to assign first-order optimality to a variable. If I could do that, comparison and choice would be trivial.
All of the fmincons are identical except which algorithm they use.
Here is an example of one fmincon function:
O.RPMoptim1 = optimproblem;
O.objective1 = @(x) x(1); % Set objective as minimizing variable x(1) which we have defined to be rpm
O.x01 = [D.rpm/5000 D.theta_n D.Vinfm D.r_hm D.r_tm D.T]; % Initial guess as defined above for rpm, theta, and any other ranged variable
O.A1 = []; % There are no Matrix Linear inequality constraints
O.b1 = []; % There are no Vector Linear inequality constraints
O.Aeq1 = []; % There are no Matrix Linear equality constraints
O.beq1 = []; % There are no Vector Linear equality constraints
O.lb1 = [zeros(1,D.n+2) B.Vinflb B.r_hlb B.r_tlb D.T]; % Lower bounds for rpm, theta, and any other ranged variable
O.ub1 = [ones(1,D.n+2)*100 B.Vinfub B.r_hub B.r_tub B.Tub]; % Upper bounds for rpm, theta, and any other ranged variable
O.nonlincon1 = @nlcon; % Non-linear constraints for info see nlcon file
O.options1=optimoptions('fmincon','Algorithm','interior-point','Display','iter-detailed','StepTolerance',1.0000e-10,'OptimalityTolerance',1.0000e-10);
% Options for the fmincon: Algorithm is set to interior point.
% It is set to iteratively display all the details of each iteration.
% It has a step tolerance of 1.0e-10 and an optimality tolerance also of 1.0e-10
x1 = fmincon(O.objective1,O.x01,O.A1,O.b1,O.Aeq1,O.beq1,O.lb1,O.ub1,O.nonlincon1,O.options1);

采纳的回答

Steven Lord
Steven Lord 2022-7-19
I haven't seen anywhere the ability to assign first-order optimality to a variable.
Take a look at the documentation for the output argument named output on the documentation page for the fmincon function, specifically its field named firstorderopt.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver-Based Nonlinear Optimization 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by