Constraining Function in fmincon

1 view (last 30 days)
Kip Risch-Andrews
Kip Risch-Andrews on 27 Jan 2020
Edited: Matt J on 27 Jan 2020
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

Accepted Answer

Matt J
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
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
Kip Risch-Andrews
Kip Risch-Andrews on 27 Jan 2020
That worked perfectly, thank you for the help! Sorry for being a bit unclear with the problem statement.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 27 Jan 2020
Edited: Matt J on 27 Jan 2020
Now that the problem is clearer, it appears to me that you could have done the whole thing with linprog,
f=[2,1]*t;
Aineq = -[2,1]*t;
Bineq = -minArea-2*t^2;
lb = [0.14, 0.14];
ub = [4.5, 4.5];
xout=linprog(f,Aineq,Bineq,[],[],lb,ub)

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!