Function: % Nonlinear Inequality Constraints

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

function f = objfun (x)

f = (0.7854*x(1)*(x(2))^2*(3.3333*(x(3))^2+14.9334*(x(3))43.0934))-(1.508*x(1)*((x(6))^2+(x(7))^2))
+(7.477*((x(6))^3+(x(7))^3))+(0.7854*((x(4))*(x(6))^2+
(x(5))*(x(7))^2));
function [c, ceq] = constraints (x)
% Nonlinear inequality constraints
c = [(27*(x(1))^-1*(x(2))^-2*(x(3))^-1)-1;(397.5*(x(1))^1*(x(2))^-2*(x(3))^-2)-1;(1.93*(x(2))^-1*(x(3))^1*(x(4))^3*(x(6))^-4)-1;
(1.93*(x(2))^-1*(x(3))^-1*(x(5))^3*(x(7))^-4)-1;((((745*(x(4)))/
((x(2))*(x(3))))^2+(16.9*(10)^6))^0.5/(0.1*(x(6))^3))-1100;
((((745*(x(5)))/((x(2))*(x(3))))^2+(157.5*(10)^6))^0.5/
(0.1*(x(7))^3))-850;((x(2))*(x(3)))-40;5-((x(1))/(x(2)));((x(1))/
(x(2)))-12;
2.6-(x(1));(x(1))-3.6;0.7-(x(2));(x(2))-0.8;17-(x(3));(x(3))-28;7.3(x(4));(x(4))-8.3;7.3-(x(5));(x(5))-8.3;
2.9-(x(6));(x(6))-3.9;5.0-(x(7));(x(7))-5.5;((1.5*(x(6))
+1.9)*(x(4))^-1)-1;((1.1*(x(7))+1.9)*(x(5))^-1)-1;];
% Nonlinear equality constraints
ceq = [];
clc
clear all
warning of
x0 = [0,0,0,0,0,0,0]; % Starting guess
fprintf ('The values of function value and constraints atstarting
pointn');
f = objfun (x0)
[c, ceq] = constraints (x0)
options = optimset ('LargeScale', 'of');
[x, fval]=fmincon (@objfun, x0, [], [], [], [], [], [],@constraints,
options)
fprintf ('The values of constraints at optimum solutionn');
[c, ceq] = constraints (x)
% Check the constraint values at x

function y= objfun (x)


y= 1.10471*x(1)^2*x(2)+0.04811*x(3)*x(4)*(14.0+x(2));
function [c, ceq] = constraints (x)
% Parameters
P = 6000; L = 14; E = 30e+6; G = 12e+6;
t_max = 13600; s_max = 30000; d_max = 0.25;
M = P*(L+x(2)/2); R = sqrt(0.25*(x(2)^2+(x(1)+x(3))^2));
J = 2/sqrt(2)*x(1)*x(2)*(x(2)^2/12+0.25*(x(1)+x(3))^2);
P_c = (((0.6688333*sqrt(E*G)*x(3)*x(4)^3)/(L^2))((0.167208333*x(3)^2*x(4)^3*E)/(L^3)));
t1 = P/(sqrt(2)*x(1)*x(2)); t2 = M*R/J;
t = sqrt(t1^2+t1*t2*x(2)/R+t2^2);
s = 6*P*L/(x(4)*x(3)^2);
d = 4*P*L^3/(E*x(4)*x(3)^3);
% Nonlinear inequality constraints
c = [t-t_max;s-s_max;x(1)x(4);0.10471*x(1)^2+0.04811*x(3)*x(4)*(14.0+x(2))-5.0;d-d_max;P-P_c;x(1)+0.125;0.1-x(1);x(1)-2.0;0.1-x(4);x(4)-2.0;0.1-x(2);x(2)-10.0;0.1x(3);x(3)-10.0;];
% Nonlinear equality constraints
ceq = [];

clc
clear all
warning of
x0 = [0.4,6.0,9.0,0.5]; % Starting guess
fprintf ('The values of function value and constraints atstarting pointn');
y = objfun (x0)
[c, ceq] = constraints (x0)
options = optimset ('LargeScale', 'of');
[x, yval]=fmincon (@objfun, x0, [], [], [], [], [], [],@constraints, options)
fprintf ('The values of constraints at optimum solutionn');
[c, ceq] = constraints (x)
% Check the constraint values at x

You might also like