Constraining Function in fmincon
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
Accepted Answer
More Answers (1)
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)
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!