Choosing the best algorithm for fmincon
5 views (last 30 days)
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
% 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 on 19 Jul 2022
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.