Constraining Function in fmincon
1 view (last 30 days)
Show older comments
I'm attempting to optimize the design of a structure using fmincon. I have x(1) and x(2) as the base and height of an I-Beam, and am trying to find the smallest dimensions to meet all constraints. The problem I'm running into is that there isn't a way to place a constraint on the function itself. I have calculated the smallest area needed to ensure the structure is able to withstand the loads applied to it, but am having trouble applying this constraint. Below is my code, I have tried applying the constraint to be in A, but due to the way the area of an Ibeam is calculated, I haven't been able to figure out placing that in there.
% Variables
%hI and wI (Design Goals) x1 and x2 respectively
x0 = [0, 0];
A_f = [];
B_f = [];
Aeq = [];
Beq = [];
lb = [0.14, 0.14];
ub = [4.5, 4.5];
xout = fmincon(@IBEAMOP,x0,A_f,B_f,Aeq,Beq,lb,ub)
weight = IBEAMOP(xout)
function [xsectionarea] = IBEAMOP(x)
%% I-Beam Optimization
syms P A
sig = P/A;
% Variables
%hI and wI (Design Goals) x1 and x2 respectively
t =.140; %in
P = 118371;
%Material Parameters
E_Ti = 15.5*(10^6); %pside
sig_Y = 110*(10^3) ; %psi
sig_U = 115*(10^3) ; %psi
rho = .162; %lb/(in^3)
nu = .33;
A =(2*x(2)*t+(x(1)-2*t)*t);
xsectionarea = (2*x(2)*t+(x(1)-2*t)*t);
end
end
0 Comments
Accepted Answer
Matt J
on 27 Jan 2020
Edited: Matt J
on 27 Jan 2020
It sounds like you need to apply a nonlinear constraint. If so, you need to use fmincon with 9 or more input arguments specified,
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
5 Comments
Matt J
on 27 Jan 2020
Edited: Matt J
on 27 Jan 2020
It's still not very clear to me, but if you are trying to minimize IBEAMOP subject also to a lower bound minArea on the output of IBEAMOP, you would provide the nonlcon function as follows,
lb = [0.14, 0.14];
ub = [4.5, 4.5];
xout = fmincon(@IBEAMOP,x0,[],[],[],[],lb,ub,@nonlcon)
function [c,ceq]=nonlcon(x)
ceq=[];
c=minArea - IBEAMOP(x);
end
function [xsectionarea] = IBEAMOP(x)
%% I-Beam Optimization
% Variables
%hI and wI (Design Goals) x1 and x2 respectively
t =.140; %in
P = 118371;
%Material Parameters
E_Ti = 15.5*(10^6); %pside
sig_Y = 110*(10^3) ; %psi
sig_U = 115*(10^3) ; %psi
rho = .162; %lb/(in^3)
nu = .33;
xsectionarea = (2*x(2)*t+(x(1)-2*t)*t);
end
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!