Constraining Function in fmincon

조회 수: 3 (최근 30일)
Kip Risch-Andrews
Kip Risch-Andrews 2020년 1월 27일
편집: Matt J 2020년 1월 27일
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

채택된 답변

Matt J
Matt J 2020년 1월 27일
편집: Matt J 2020년 1월 27일
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
Matt J
Matt J 2020년 1월 27일
편집: Matt J 2020년 1월 27일
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 2020년 1월 27일
That worked perfectly, thank you for the help! Sorry for being a bit unclear with the problem statement.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2020년 1월 27일
편집: Matt J 2020년 1월 27일
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)

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by