clear;close all;
options=[];
fun1 = '46.971-5.094*x(1)-80.234*x(2)+0.173*x(1)^2+46.994*x(2)^2+3.695e-5*x(3)^2+3.056*x(1)*x(2)-0.001*x(1)*x(3)';
fun2 = '-12.665-18.738*x(1)-7.984*x(1)^2-2.520E-5*x(2)^2+0.055*x(1)*x(2)';
% fun2 = '12.665+18.738*x(1)+7.984*x(1)^2+2.520E-5*x(2)^2-0.055*x(1)*x(2)';
% fun3 = '32.088-0.060*x(3)+8.380e-5*x(3)^2-0.416*x(1)*x(2) +0.001*x(1)*x(3)';
fun3 = '-32.088+0.060*x(3)-8.380e-5*x(3)^2+0.416*x(1)*x(2) -0.001*x(1)*x(3)';
fun31 = '9.803-0.8*x(1)-20.476*x(2)+0.033*x(1)^2-3.157E-5*x(3)^2+0.053*x(2)*x(3) ';
fun4 = '-0.972+6.115*x(1)^2 +1.571E-5*x(2)^2-0.021*x(1)*x(2) ';
num = 234;
num1 = 11;% 提高x1
num2 = 0.41;%降低x2
x10=[num1,num2,num];lb1=[num1,num2,num];ub1=[14,0.41,450];
[x1,fval1]=fmincon(fun1,x10,[],[],[],[],lb1,ub1,options);
x20=[0.4,300];lb2=[0.4,300];ub2=[0.55,350];
[x2,fval2]=fmincon(fun2,x20,[],[],[],[],lb2,ub2,options);
x30=[8,0.4,400];lb3=[8,0.4,400];ub3=[10,0.55,475];
[x3,fval3]=fmincon(fun3,x30,[],[],[],[],lb3,ub3,options);
[x31,fval31]=fmincon(fun31,x30,[],[],[],[],lb3,ub3,options);
x40=[0,400];lb4=[0,400];ub4=[0.25,475];
[x4,fval4]=fmincon(fun4,x40,[],[],[],[],lb4,ub4,options);
disp(['Y1函数的极小值为 ',num2str(fval1)])
disp('对应函数的极小值的x变量值分别为')
disp(['x1 = ',num2str(x1(1)),'; ','x2 = ',num2str(x1(2)),'; ','x3 = ',num2str(x1(3)),'; '])
disp(['Y2函数的极大值为 ',num2str(abs(fval2))])
disp('对应函数的极大值的x变量值分别为')
disp(['x2 = ',num2str(x2(1)),'; ','x3 = ',num2str(x2(2)),'; '])
disp(['Y3函数的极大值为 ',num2str(abs(fval3))])
disp('对应函数的极大值的x变量值分别为')
disp(['x1 = ',num2str(x3(1)),'; ','x2 = ',num2str(x3(2)),'; ','x3 = ',num2str(x3(3)),'; '])
disp(['Y31函数的极小值为 ',num2str(fval31)])
disp('对应函数的极小值的x变量值分别为')
disp(['x1 = ',num2str(x31(1)),'; ','x2 = ',num2str(x31(2)),'; ','x3 = ',num2str(x31(3)),'; '])
disp(['Y4函数的极小值为 ',num2str(fval4)])
disp('对应函数的极小值的x变量值分别为')
disp(['x2 = ',num2str(x4(1)),'; ','x3 = ',num2str(x4(2)),'; '])