我有这个功能:
function f=cost(x)
f=1.10471*x(1)^2*x(2)+0.04811*x(3)*x(4)*(14.0+x(2));
受制于
g(1)=tau-tau_max;
g(2)=sigma-sigma_max;
g(3)=x(1)-x(4);
g(4)=0.10471*x(1)^2+0.04811*x(3)*x(4)*(14+x(2))-5.0;
g(5)=0.125-x(1);
g(6)=delta-delta_max;
g(7)=P-PcX;
所有 g[1..7] 应该 <= 0
我必须将它们中的任何两个保持为常数并绘制 f(x) 的上限和下限分别为 (x1..x4)
LowerBound=[0.125 0.1 0.1 0.125];
UpperBound=[5.0 10.0 10.0 5.0];
提前致谢...
编辑:到目前为止我做了什么:
function [x1,x2,x3,x4]=objFuncPlot
[x2, x3] = meshgrid(0.1:.1:10, 0.1:.1:10);
//x1 and x4 is constant
x1=0.1996;
x4=0.2107;
//calculating constraints
[g1,g2,g3,g4,g5,g6,g7]=constraints(x1,x2,x3,x4);
G1=[g1,g2,g4,g6,g7];
G2=[g3,g5];
infeasible=~all(G1(:)<=0) | ~all(G2(:)<=0);
//objective function
f=1.10471.*x1^2.*x2+0.04811.*x3.*x4.*(14.0+x2);
f(infeasible)=nan;
//plotting surf
surf(x2,x3,f,'LineStyle','none');
view(68,20)
hold on
xlabel('x');ylabel('y');zlabel('z');
hold off
//Constraints & Constants & Equations
function [g1,g2,g3,g4,g5,g6,g7]=constraints(x1,x2,x3,x4)
P=6000;
L=14;
E=30.*10^6;
G=12.*10^6;
tau_max=13600;
sigma_max=30000;
delta_max=0.25;
M=P*(14+x2./2);
R=sqrt(x2^2./4+(x1+x3)^2./4);
J=2.*(x1.*x2.*sqrt(2).*(x2^2/12+(x1+x3)^2/4));
tau_one=P./(sqrt(2).*x1.*x2);
tau_two=(M.*R)./J;
tau=sqrt(tau_one^2+2.*tau_one.*tau_two.*x2./(2.*R)+tau_two^2);
sigma=(6.*P.*L)./(x4.*x3^2);
delta=(4.*P.*L^3)./(30.*10^6.*x4.*x3^3);
PcX=4.013.*E./L^2.*sqrt(x3^2.*x4^6./36).*(1-x3.*sqrt(E./(4.*G))./(2.*L));
g1=tau-tau_max;
g2=sigma-sigma_max;
g3=x1-x4;
g4=0.10471.*x1^2+0.04811.*x3.*x4.*(14+x2)-5.0;
g5=0.125-x1;
g6=delta-delta_max;
g7=P-PcX;