# Using min() and max() in the nonlinear constraints of fmincon and ga

4 views (last 30 days)
Elie Hatem on 8 Jun 2021
Edited: Elie Hatem on 8 Jun 2021
Hello,
I read somewhere that I should not use min() and max() in the objective function of fmincon (I am not sure if it can be used in the objective function of ga either) because they may result in discontinuities in the solution vector.
However, is it possible to use them in the nonlinear inequality constraits of an optimization problem?
For example, after computing my trajectory along y, z and the trajectory of my roll angle phi, I have the following inequality constraints:
(Please note that z1, z2 and z3 are the different parts of the full trajectory along . And phid represents which is the trajectory of the angular velocity).
c = [ max(z1)-z1_max; % upper bound on the reaching phase
-min(z1)+z1_min; % lower bound on the reaching phase
max(z2)-z2_max; % upper bound on the flipping phase
-min(z2)+z2_min; % lower bound on the flipping phase
max(z3)-z3_max; % upper bound on the recovery phase
-min(z3)+z3_min; % lower bound on the recovery phase
-min(phi); % lower bound on phi (phi>phi_min)
max(phi)-2*pi; % upper bound on phi (phi<2*pi)
-4*pi-min(phid); % lower bound on thetad (thetad >= thetad_min) (angular velocity for aggressive maneuvers is around 720 deg/s)
max(phid)-4*pi; % upper bound on thetad (thetad <= thetad_max) (angular velocity for aggressive maneuvers is around 720 deg/s)
-min(u1)+u1_min; % lower bound on u1 (u1>=0)
max(u1)-u1_max; % upper bound on u1 (u1<=u1 max)
-min(u2)+u2_min; % lower bound on u2 (u2>=-u2_max)
max(u2)-u2_max;] % upper bound on u2 (u2<=u2_max)
Do the inequality constraints seem correct to you?
Is there a way to check each element of each vector to see if the constraint is satisfied? (I am not sure if this is necessary since I am using lower and upper bounds on 4 waypoints for z along the trajectory and 2 waypoints for phi along the trajectory and at the end of the trajectory, phi=2*pi)
I am asking because I cannot find a feasible solution with both fmincon and ga.
Thank you

R2020a

### Community Treasure Hunt

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

Start Hunting!