一.非线性规划模型
1.概念:

如果目标函数或约束条件中包含非线性函数,就称该规划问题为非线性规划问题.一般来说,求解非线性规划问题要比求解线性规划问题困难得多,也不像线性规划问题那样有单纯形法这一通用方法,各个方法都有自己的适用范围

注意:如果线性规划的最优解存在,则其最优解只可能在其可行域的边界上(特别是顶点上);而如果非线性规划的最优解存在,其最优解可能在其可行域的任意位置

2.一般形式:

非线性规划问题的一般形式为: m i n f ( x ) s . t . { h j ( x ) ≤ 0 ( j = 1 , 2... q ) g i ( x ) = 0 ( i = 1 , 2... p ) ( 3.1 ) min\,\:f(x)\\s.t.\begin{cases}h_j(x)≤0\,(j=1,2...q)\\g_i(x)=0\,(i=1,2...p)\end{cases}\qquad(3.1) minf(x)s.t.{hj​(x)≤0(j=1,2...q)gi​(x)=0(i=1,2...p)​(3.1)其中 x = [ x 1 , x 2 . . . x n ] T x=[x_1,x_2...x_n]^T x=[x1​,x2​...xn​]T称为模型式 ( 3.1 ) (3.1) (3.1)的决策变量, f f f为目标函数, g i , h j g_i,h_j gi​,hj​为约束函数, g i ( x ) = 0 g_i(x)=0 gi​(x)=0为等式约束, h j ( x ) ≤ 0 h_j(x)≤0 hj​(x)≤0为不等式约束,目标函数和所有约束函数中至少有1个为非线性函数

某企业有 n n n个项目可供选择投资,且至少要投资其中的1个项目.已知该企业的总资金为 A A A,投资于第 i i i个项目需花费的资金为 a i a_i ai​,并预计收益为 b i b_i bi​.请给出最佳的投资方案
设投资决策变量为 x i = { 1 , 投 资 第 i 个 项 目 0 , 不 投 资 第 i 个 项 目 x_i=\begin{cases}1,投资第i个项目\\0,不投资第i个项目\end{cases} xi​={1,投资第i个项目0,不投资第i个项目​则投资总额为 ∑ i = 1 n a i x i \displaystyle\sum_{i=1}^na_ix_i i=1∑n​ai​xi​,总收益为 ∑ i = 1 n b i x i \displaystyle\sum_{i=1}^nb_ix_i i=1∑n​bi​xi​.由于至少要投资1个项目,且总资金为 A A A,故 0 < ∑ i = 1 n a i x i ≤ A 0<\displaystyle\sum_{i=1}^na_ix_i≤A 0<i=1∑n​ai​xi​≤A另外,由于 x i x_i xi​只能取 0 0 0或 1 1 1,故 x i ( 1 − x i ) = 0 x_i(1-x_i)=0 xi​(1−xi​)=0最佳方案应使投资额尽可能小而总收益尽可能大,故该问题的数学模型为 m a x Q = ∑ i = 1 n b i x i ∑ i = 1 n a i x i s . t . { 0 < ∑ i = 1 n a i x i ≤ A x i ( 1 − x i ) = 0 max\,\:Q=\frac{\displaystyle\sum_{i=1}^nb_ix_i}{\displaystyle\sum_{i=1}^na_ix_i}\\s.t.\begin{cases}0<\displaystyle\sum_{i=1}^na_ix_i≤A\\x_i(1-x_i)=0\end{cases} maxQ=i=1∑n​ai​xi​i=1∑n​bi​xi​​s.t.⎩⎪⎨⎪⎧​0<i=1∑n​ai​xi​≤Axi​(1−xi​)=0​

3.MATLAB解法
(1)标准形式:

MATLAB中非线性规划的数学模型的标准形式为 m i n f ( x ) s . t . { A x ≤ b A e q ⋅ x = b e q c ( x ) ≤ 0 c e q ( x ) = 0 l b ≤ x ≤ u b ( 3.1 ) min\,\:f(x)\\s.t.\begin{cases}Ax≤b\\Aeq·x=beq\\c(x)≤0\\ceq(x)=0\\lb≤x≤ub\end{cases}\qquad(3.1) minf(x)s.t.⎩⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎧​Ax≤bAeq⋅x=beqc(x)≤0ceq(x)=0lb≤x≤ub​(3.1)其中 f ( x ) f(x) f(x)为标量函数, A , b , A e q , b e q , l b , u b A,b,Aeq,beq,lb,ub A,b,Aeq,beq,lb,ub为相应维数的矩阵和向量, c ( x ) , c e q ( x ) c(x),ceq(x) c(x),ceq(x)为非线性向量函数

(2)求解:

MATLAB中使用[x,fval]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,option)求解非线性规划问题.例如求解下述问题: m i n f ( x ) = x 1 2 + x 2 2 + x 3 2 + 8 s . t . { x 1 2 − x 2 + x 3 2 ≥ 0 x 1 + x 2 2 + x 3 3 ≤ 20 − x 1 − x 2 2 + 2 = 0 x 2 + 2 x 3 2 = 3 x 1 , x 2 , x 3 ≥ 0 min\,\:f(x)=x_1^2+x_2^2+x_3^2+8\\s.t.\begin{cases}x_1^2-x_2+x_3^2≥0\\x_1+x_2^2+x_3^3≤20\\-x_1-x_2^2+2=0\\x_2+2x_3^2=3\\x_1,x_2,x_3≥0\end{cases} minf(x)=x12​+x22​+x32​+8s.t.⎩⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎧​x12​−x2​+x32​≥0x1​+x22​+x33​≤20−x1​−x22​+2=0x2​+2x32​=3x1​,x2​,x3​≥0​计算代码为:

#func.mlx中:
function f=func(x);
f=sum(x.^2)+8;
end#nonlcon.mlx中:
function [g,h]=nonlcon(x);
g=[-x(1)^2+x(2)-x(3)^2 x(1)+x(2)^2+x(3)^3-20]%非线性不等式约束
h=[-x(1)-x(2)^2+2 x(2)+2*x(3)^2-3]%非线性等式约束
end#命令行中:
>> [x,y]=fmincon('func',rand(3,1),[],[],[],[],zeros(3,1),[],'nonlcon');
>> x,yx =0.55221.20330.9478y =10.6511

二.无约束问题
1.无约束极值问题
(1)符号解:

求多元函数 f ( x , y ) = x 3 − y 3 + 3 x 2 + 3 y 2 − 9 x f(x,y)=x^3-y^3+3x^2+3y^2-9x f(x,y)=x3−y3+3x2+3y2−9x的极值.计算代码为:

>> syms x y
>> f=x^3-y^3+3*x^2+3*y^2-9*x;
>> df=jacobian(f);%求1阶偏导数
>> d2f=jacobian(df);%求2阶偏导数
>> [xx,yy]=solve(df);%求驻点
>> xx=double(xx);
>> yy=double(yy);
>> for i=1:length(xx)
a=subs(d2f,{x,y},{xx(i),yy(i)});
b=eig(a);%求矩阵的特征值
r=subs(f,{x,y},{xx(i),yy(i)});
r=double(r);
if all(b>0)
fprintf('极小值点(%f,%f),极小值%f\n',xx(i),yy(i),r);
elseif all(b<0)
fprintf('极大值点(%f,%f),极大值%f\n',xx(i),yy(i),r);
elseif any(b>0)&any(b<0)
fprintf('(%f,%f)非极值点\n',xx(i),yy(i));
else
fprintf('无法判断(%f,%f)\n',xx(i),yy(i))
end
end
极小值点(1.000000,0.000000),极小值-5.000000
(-3.000000,0.000000)非极值点
(1.000000,2.000000)非极值点
极大值点(-3.000000,2.000000),极大值31.000000

(2)数值解:

在MATLAB中,使用[x,fval]=fminunc(fun,x0,options)[x,fval]=fminsearch(fun,x0,options)来求函数的极小值

求多元函数 f ( x , y ) = x 3 − y 3 + 3 x 2 + 3 y 2 − 9 x f(x,y)=x^3-y^3+3x^2+3y^2-9x f(x,y)=x3−y3+3x2+3y2−9x的极值.计算代码为:

>> f=@(x) x(1)^3-x(2)^3+3*x(1)^2+3*x(2)^2-9*x(1);
>> g=@(x) -f(x);
>> [xy1,z1]=fminunc(f,rand(2,1))Local minimum found.Optimization completed because the size of the gradient is less than
the default value of the optimality tolerance.<stopping criteria details>xy1 =1.0000-0.0000z1 =-5.0000>> [xy2,z2]=fminsearch(g,rand(2,1));
>> xy2,-z2xy2 =-3.00002.0000ans =31.0000

求函数 f ( x ) = 100 ( x 2 − x 1 2 ) 2 + ( 1 − x 1 ) 2 f(x)=100(x_2-x_1^2)^2+(1-x_1)^2 f(x)=100(x2​−x12​)2+(1−x1​)2的极小值.计算代码为:

#fun.mlx中:
function [f,g]=fun(x);
f=100*(x(2)-x(1)^2)^2+(1-x(1))^2;
g=[-400*x(1)*(x(2)-x(1)^2)-2*(1-x(1));200*(x(2)-x(1)^2)];%返回梯度向量
end
#命令行中:
>> options=optimset('GradObj','on');
>> [x,y]=fminunc('fun',rand(1,2),options)Local minimum found.Optimization completed because the size of the gradient is less than
the default value of the optimality tolerance.<stopping criteria details>x =1.0000    1.0000y =7.3005e-17

求函数 f ( x ) = sin ⁡ ( x ) + 3 f(x)=\sin{(x)}+3 f(x)=sin(x)+3的极小值.计算代码为:

>> f=@(x) sin(x)+3;
>> [x,y]=fminsearch(f,2)x =4.7124y =2.0000

2.函数的零点:

求多项式 f ( x ) = x 3 − x 2 + 2 x − 3 f(x)=x^3-x^2+2x-3 f(x)=x3−x2+2x−3的零点.计算代码为:

>> a=[1,-1,2,-3];
>> x0=roots(a)x0 =-0.1378 + 1.5273i-0.1378 - 1.5273i1.2757 + 0.0000i################################################################################################################################>> syms x
>> x0=solve(x^3-x^2+2*x-3)%求零点的符号解x0 =root(z^3 - z^2 + 2*z - 3, z, 1)root(z^3 - z^2 + 2*z - 3, z, 2)root(z^3 - z^2 + 2*z - 3, z, 3)>> x0=vpa(x0,5)%转换为小鼠格式x0 =1.2757- 0.13784 + 1.5273i- 0.13784 - 1.5273i################################################################################################################################>> y=@(x) x^3-x^2+2*x-3;
>> x=fsolve(y,rand)%求给定值附近的1个解Equation solved.fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.<stopping criteria details>x =1.2757

3.方程组的解:

如如下方程组的解: { x 2 + y − 6 = 0 y 2 + x − 6 = 0 \begin{cases}x^2+y-6=0\\y^2+x-6=0\end{cases} {x2+y−6=0y2+x−6=0​计算代码为:

>> syms x y
>> [x,y]=solve(x^2+y-6,y^2+x-6)x =2-321^(1/2)/2 + 1/21/2 - 21^(1/2)/2y =2-31/2 - 21^(1/2)/221^(1/2)/2 + 1/2################################################################################################################################>> f=@(x) [x(1)^2+x(2)-6,x(2)^2+x(1)-6];
>> xy=fsolve(f,rand(2,1))Equation solved.fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.<stopping criteria details>xy =2.00002.0000

三.约束极值问题
1.概念:

带有约束条件的极值问题称为约束极值问题,也叫规划问题.求解约束极值问题要比求解无约束极值问题困难得多,通常采用将约束问题转换为无约束问题,非线性规划问题转换为线性规划问题的方法进行简化
库恩·塔克条件是非线性规划领域中的重要理论成果,是确定某点为最优点的必要条件(对凸规划,也是充分条件)

2.二次规划
(1)概念:

若某非线性规划的目标函数为二次函数,且约束条件均为线性约束条件,就称该规划为二次规划

(2)MATLAB中的标准形式:

MATLAB中二次规划问题的标准形式为: m i n 1 2 x T H x + f T x s . t . { A x ≤ b A e q ⋅ x = b e q l b ≤ x ≤ u b min\,\:\frac{1}{2}x^THx_+f^Tx\\s.t.\begin{cases}Ax≤b\\Aeq\,·x=beq\\lb≤x≤ub\end{cases} min21​xTHx+​fTxs.t.⎩⎪⎨⎪⎧​Ax≤bAeq⋅x=beqlb≤x≤ub​其中 H H H为实对称矩阵, f , b , b e q , l b , u b f,b,beq,lb,ub f,b,beq,lb,ub为列向量, A , A e q A,Aeq A,Aeq为相应维数的矩阵

(3)求解:

MATLAB中使用[x,fval]=quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)求解二次规划问题

求解下述二次规划问题: m i n f ( x ) = 2 x 1 2 − 4 x 1 x 2 + 4 x 2 2 − 6 x 1 − 3 x 2 s . t . { x 1 + x 2 ≤ 3 4 x 1 + x 2 ≤ 9 x 1 , x 2 ≥ 0 min\,\:f(x)=2x_1^2-4x_1x_2+4x_2^2-6x_1-3x_2\\s.t.\begin{cases}x_1+x_2≤3\\4x_1+x_2≤9\\x_1,x_2≥0\end{cases} minf(x)=2x12​−4x1​x2​+4x22​−6x1​−3x2​s.t.⎩⎪⎨⎪⎧​x1​+x2​≤34x1​+x2​≤9x1​,x2​≥0​

>> h=[4,-4;-4,8];
>> f=[-6;-3];
>> a=[1,1;4,1];
>> b=[3;9];
>> [x,value]=quadprog(h,f,a,b,[],[],zeros(2,1))Minimum found that satisfies the constraints.Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.<stopping criteria details>x =1.95001.0500value =-11.0250

3.罚函数法
(1)概念:

罚函数法又称序列无约束最小化技术(Sequential Unconstrained Minization Technique;SUMT).其基本思想是利用问题中的约束函数作出适当的罚函数,由此构造出带参数的增广目标函数,从而把问题转化为无约束非线性规划问题.该方法又分为外罚函数法和内罚函数法

(2)求解:

考虑问题 m i n f ( x ) s . t . { g i ( x ) ≤ 0 ( i = 1 , 2... r ) h j ( x ) ≥ 0 ( j = 1 , 2... s ) k m ( x ) = 0 ( m = 1 , 2... t ) min\,\:f(x)\\s.t.\begin{cases}g_i(x)≤0\,(i=1,2...r)\\h_j(x)≥0\,(j=1,2...s)\\k_m(x)=0\,(m=1,2...t)\end{cases} minf(x)s.t.⎩⎪⎨⎪⎧​gi​(x)≤0(i=1,2...r)hj​(x)≥0(j=1,2...s)km​(x)=0(m=1,2...t)​取1个充分大的数 M > 0 M>0 M>0,构造函数 P ( x , M ) = f ( x ) + M ∑ i = 1 r m a x ( g i ( x ) , 0 ) − M ∑ j = 1 s m i n ( h j ( x ) , 0 ) + M ∑ m = 1 t ∣ k m ( x ) ∣ P(x,M)=f(x)+M\displaystyle\sum_{i=1}^rmax(g_i(x),0)-M\displaystyle\sum_{j=1}^smin(h_j(x),0)+M\displaystyle\sum_{m=1}^t|\,k_m(x)\,| P(x,M)=f(x)+Mi=1∑r​max(gi​(x),0)−Mj=1∑s​min(hj​(x),0)+Mm=1∑t​∣km​(x)∣则以增广目标函数 P ( x , M ) P(x,M) P(x,M)为目标函数的无约束极值问题 m i n P ( x , M ) min\,\:P(x,M) minP(x,M)的最优解也是原问题的最优解

求解下述非线性规划问题 m i n f ( x ) = x 1 2 + x 2 2 + 8 s . t . { x 1 2 − x 2 ≥ 0 − x 1 − x 2 2 + 2 = 0 x 1 , x 2 ≥ 0 min\,\:f(x)=x_1^2+x_2^2+8\\s.t.\begin{cases}x_1^2-x_2≥0\\-x_1-x_2^2+2=0\\x_1,x_2≥0\end{cases} minf(x)=x12​+x22​+8s.t.⎩⎪⎨⎪⎧​x12​−x2​≥0−x1​−x22​+2=0x1​,x2​≥0​

#test.mlx中:
function g=test(x);
M=50000;
f=x(1)^2+x(2)^2+8;
g=f-M*min(x(1),0)-M*min(x(2),0)-M*min(x(1)^2-x(2),0)+M*abs(-x(1)-x(2)^2+2);
end
#命令行中:
>> [x,y]=fminsearch('test',rand(2,1))x =1.99910.0296y =11.9977由于是非线性问题,很难求得全局最优解,只能求得1个局部最优解,且每次结果均不同

(3)适用:

①如果要求实时算法,可使用罚函数法,但精度较低
②如果不要求实时算法,但要求高精度,可使用Lingo或MATLAB中的fmincon()求解

3.其他方法
(1)有限区间上单变量非线性函数的最小值:

MATLAB使用[x,fval]=fminbnd(fun,x1,x2,options)来求解这类问题

求 f ( x ) = ( x − 3 ) 2 − 1 ( 0 ≤ x ≤ 5 ) f(x)=(x-3)^2-1\,(0≤x≤5) f(x)=(x−3)2−1(0≤x≤5)的最小值

#fun.mlx中:
function f=fun(x);
f=(x-3)^2-1
end
#命令行中:
>> [x,y]=fminbnd('fun',0,5)f =0.1885f =-0.9919f =-0.3282f =-1f =-1.0000f =-1.0000x =3y =-1

(2)存在非线性约束:

MATLAB中的标准形式为 m i n f ( x ) s . t . { A x ≤ b A e q ⋅ x = b e q l b ≤ x ≤ u b c ( x ) ≤ 0 c e q ( x ) = 0 K i ( x , w i ) ≤ 0 ( 1 ≤ i ≤ n ) min\,\:f(x)\\s.t.\begin{cases}Ax≤b\\Aeq\,·x=beq\\lb≤x≤ub\\c(x)≤0\\ceq(x)=0\\K_i(x,w_i)≤0\,(1≤i≤n)\end{cases} minf(x)s.t.⎩⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎧​Ax≤bAeq⋅x=beqlb≤x≤ubc(x)≤0ceq(x)=0Ki​(x,wi​)≤0(1≤i≤n)​其中 x , b , b e q , l b , u b x,b,beq,lb,ub x,b,beq,lb,ub为向量, A , A e q A,Aeq A,Aeq为矩阵, c ( x ) , c e q ( x ) c(x),ceq(x) c(x),ceq(x)为向量函数, K ( x , w i ) K(x,w_i) K(x,wi​)为标量函数, w i w_i wi​为附加的变量

MATLAB中使用[x,fval]=fseminf(fun,x,ntheta,seminfcon,A,b,Aeq,beq,lb,ub)进行求解

求 f ( x ) = ( x 1 − 0.5 ) 2 + ( x 2 − 0.5 ) 2 + ( x 3 − 0.5 ) 2 f(x)=(x_1-0.5)^2+(x_2-0.5)^2+(x_3-0.5)^2 f(x)=(x1​−0.5)2+(x2​−0.5)2+(x3​−0.5)2的最小值,约束为 K 1 ( x , w 1 ) = sin ⁡ ( w 1 x 1 ) cos ⁡ ( w 1 x 2 ) − ( w 1 − 50 ) 2 1000 − sin ⁡ ( w 1 x 3 ) − x 3 ≤ 1 ( 1 ≤ w 1 ≤ 100 ) K 2 ( x , w 2 ) = sin ⁡ ( w 2 x 2 ) cos ⁡ ( w 2 x 1 ) − ( w 2 − 50 ) 2 1000 − sin ⁡ ( w 2 x 3 ) − x 3 ≤ 1 ( 1 ≤ w 2 ≤ 100 ) K_1(x,w_1)=\sin{(w_1x_1)}\cos{(w_1x_2)}-\frac{(w_1-50)^2}{1000}-\sin{(w_1x_3)}-x_3≤1\,(1≤w_1≤100)\\K_2(x,w_2)=\sin{(w_2x_2)}\cos{(w_2x_1)}-\frac{(w_2-50)^2}{1000}-\sin{(w_2x_3)}-x_3≤1\,(1≤w_2≤100) K1​(x,w1​)=sin(w1​x1​)cos(w1​x2​)−1000(w1​−50)2​−sin(w1​x3​)−x3​≤1(1≤w1​≤100)K2​(x,w2​)=sin(w2​x2​)cos(w2​x1​)−1000(w2​−50)2​−sin(w2​x3​)−x3​≤1(1≤w2​≤100)

#fun.mlx中:
function f=fun(x,s);
f=sum((x-0.5).^2);
end
#fun2.mlx中:
function [c,ceq,k1,k2,s]=fun2(x,s);
c=[];
ceq=[];
if isnan(s(1,1))s=[0.2,0;0.2,0];
end
w1=1:s(1,1):100;
w2=1:s(2,1):100;
k1=sin(w1*x(1)).*cos(w1*x(2))-((w1-50).^2)/1000-sin(w1*x(3))-x(3)-1;
k2=sin(w2*x(2)).*cos(w2*x(1))-((w2-50).^2)/1000-sin(w2*x(3))-x(3)-1;
plot(w1,k1,'-',w2,k2,'+');#见下图
end
#命令行中:
>> [x,y]=fseminf(@fun,x0,2,@fun2)Local minimum possible. Constraints satisfied.fseminf stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.<stopping criteria details>x =0.66750.30120.4022y =0.0771


(3)双重最值:

求解 m i n x m a x i F i ( x ) s . t . { A x ≤ b A e q ⋅ x = b e q c ( x ) ≤ 0 c e q ( x ) = 0 l b ≤ x ≤ u b \underset{x}{min}\,\underset{i}{max}\,F_i(x)\\s.t.\begin{cases}Ax≤b\\Aeq\,·x=beq\\c(x)≤0\\ceq(x)=0\\lb≤x≤ub\end{cases} xmin​imax​Fi​(x)s.t.⎩⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎧​Ax≤bAeq⋅x=beqc(x)≤0ceq(x)=0lb≤x≤ub​的MATLAB命令为[x,fval]=fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)

求函数族 { f 1 ( x ) , f 2 ( x ) , f 3 ( x ) , f 4 ( x ) , f 5 ( x ) } \{f_1(x),f_2(x),f_3(x),f_4(x),f_5(x)\} {f1​(x),f2​(x),f3​(x),f4​(x),f5​(x)}取极小-极大值时的 x x x值 { f 1 ( x ) = 2 x 1 2 + x 2 2 − 48 x 1 − 40 x 2 + 304 f 2 ( x ) = − x 1 2 − 3 x 2 2 f 3 ( x ) = x 1 + 3 x 2 − 18 f 4 ( x ) = − x 1 − x 2 f 5 ( x ) = x 1 + x 2 − 8 \begin{cases}f_1(x)=2x_1^2+x_2^2-48x_1-40x_2+304\\f_2(x)=-x_1^2-3x_2^2\\f_3(x)=x_1+3x_2-18\\f_4(x)=-x_1-x_2\\f_5(x)=x_1+x_2-8\end{cases} ⎩⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎧​f1​(x)=2x12​+x22​−48x1​−40x2​+304f2​(x)=−x12​−3x22​f3​(x)=x1​+3x2​−18f4​(x)=−x1​−x2​f5​(x)=x1​+x2​−8​

#fun.mlx中:
function f=fun(x);
f=[2*x(1)^2+x(2)^2-48*x(1)-40*x(2)+304-x(1)^2-3*x(2)^2x(1)+3*x(2)-18-x(1)-x(2)x(1)+x(2)-8];
end
#命令行中:
>> [x,y]=fminimax(@fun,rand(2,1))Local minimum possible. Constraints satisfied.fminimax stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.<stopping criteria details>x =4.00004.0000y =0.0000-64.0000-2.0000-8.0000-0.0000

(4)利用梯度求解约束优化问题:

已知 f ( x ) = e x 1 ( 4 x 1 2 + 2 x 2 2 + 4 x 1 x 2 + 2 x 2 + 1 ) f(x)=e^{x_1}(4x_1^2+2x_2^2+4x_1x_2+2x_2+1) f(x)=ex1​(4x12​+2x22​+4x1​x2​+2x2​+1),求 m i n f ( x ) s . t . { x 1 x 2 − x 1 − x 2 ≤ − 1.5 x 1 x 2 ≥ − 10 min\,\:f(x)\\s.t.\begin{cases}x_1x_2-x_1-x_2≤-1.5\\x_1x_2≥-10\end{cases} minf(x)s.t.{x1​x2​−x1​−x2​≤−1.5x1​x2​≥−10​

#fun.mlx中:
function [f,df]=fun(x);
f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);
df=[exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+8*x(1)+6*x(2)+1);exp(x(1))*(4*x(2)+4*x(1)+2)];%梯度
end
#fun2.mlx中:
function [c,ceq,dc,dceq]=fun2(x);
c=[x(1)*x(2)-x(1)-x(2)+1.5;-x(1)*x(2)-10];
dc=[x(2)-1,-x(2);x(1)-1,-x(1)];%不等式约束条件的梯度
ceq=[];
dceq=[];%等式约束条件的梯度
end
#命令行中:
>> options=optimset('GradObj','on','GradConstr','on');
>> [x,y]=fmincon(@fun,rand(2,1),[],[],[],[],[],[],@fun2,options)Local minimum found that satisfies the constraints.Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.<stopping criteria details>x =-9.54741.0474y =0.0236

四.飞行管理问题
1.问题叙述:

在 10 k m 10km 10km高空处某边长为 D = 160 k m D=160km D=160km的正方形区域(记为 Ω Ω Ω)中,经常有若干架飞机作水平飞行.当1架欲进入该区域的飞机到达区域边缘时,应立即记录其位置及速度,并判断其是否会与区域内其他飞机发生碰撞.如果会发生碰撞,则应计算如何调整各架飞机飞行的方向角(即飞行方向与x轴之间的夹角;记为 θ i 0 θ_i^0 θi0​)以避免碰撞.要求如下:
①不碰撞的标准为任意2架飞机的距离均大于 8 k m 8km 8km
②飞机飞行的方向角调整的幅度(记为 Δ θ i Δθ_i Δθi​)不应超过 30 ° 30° 30°,新方向角记为 θ i θ_i θi​
③所有飞机的速度均为 a = 800 k m / h a=800km/h a=800km/h
④进入该区域的飞机在到达区域边缘时,与区域内飞机的距离应大于 60 k m 60km 60km
⑤最多考虑6架飞机
⑥不必考虑飞机离开此区域后的状况
⑦该区域的4个顶点的坐标分别为 ( 0 , 0 ) , ( 160 , 0 ) , ( 160 , 160 ) , ( 0 , 160 ) (0,0),(160,0),(160,160),(0,160) (0,0),(160,0),(160,160),(0,160)
⑧即第 i i i架飞机的初始位置为 ( x i 0 , y i 0 ) (x_i^0,y_i^0) (xi0​,yi0​),在 t t t时刻的位置为 ( x i ( t ) , y i ( t ) ) (x_i(t),y_i(t)) (xi​(t),yi​(t))
⑨初始飞行数据如下表:

飞机编号 横坐标 x i 0 x_i^0 xi0​ 纵坐标 y i 0 y_i^0 yi0​ 方向角 / °
1 150 140 243
2 85 85 236
3 150 155 220.5
4 145 50 159
5 130 150 230
6(新进入) 0 0 52

2.模型1:

数学建模 非线性规划相关推荐

  1. 数学建模——非线性规划

    目录 基本概念 凸规划 判别定理 二次规划模型 非线性规划的求解 无约束极值问题 有约束极值问题 基于求解器的解法 基于问题的求解 其他 非线性规划:描述目标函数或约束条件条件的数学表达式中,至少有一 ...

  2. 数学建模 非线性规划原理的应用与编程实现

    非线性规划模型NP 包含非线性函数:不是直线而是曲线.曲面.或不确定的属性,叫非线性. 如:x^2 线性函数:一次函数,ax+b 列1-投资决策问题 解答: 设置决策变量: 1)投资某个项目达到收益最 ...

  3. 【数学建模】非线性规划模型与01规划模型(最优化)

    文章目录 一.算法介绍 1. 01规划模型 二.适用问题 三.算法总结 四.应用场景举例 1.非线性规划模型 2.01规划模型 五.LINGO代码 1.非线性规划模型 2.01规划模型 六.实际案例 ...

  4. 数学建模、运筹学之非线性规划

    数学建模.运筹学之非线性规划 一.最优化问题理论体系 二.梯度下降法--无约束非线性规划 三.牛顿法--无约束非线性规划 四.只包含等值约束的拉格朗日乘子法 五.不等值约束非线性规划与KKT条件 一. ...

  5. 【数学建模】(十):Lingo使用:线性规划+非线性规划+整数规划

    [数学建模](十):Lingo使用:线性规划+非线性规划+整数规划 线性规划 运输问题 整数规划 非线性规划 线性规划 设x1x_1x1​桶牛奶生产A1A_1A1​, x2x_2x2​桶牛奶生产A2A ...

  6. 【数学建模】算法模型(一)|线性规划 整数规划 非线性规划 层次分析模型 灰色关联分析

    文章目录 1.线性规划 Linear Programming (LP) 1.1线性规划的matlab标准形式及软件求解 1.2 投资的收益和风险 2. 整数规划 2.1 整数规划和线性规划的关系 2. ...

  7. 数学建模整理-线性规划、整数规划、非线性规划

    数学建模整理 线性规划 整数规划 整数规划特点 求解方法分类 (1)分枝定界法 (2) 割平面法 (3) 隐枚举法("0-1"整数规划) (4) 匈牙利法 (5) 蒙特卡洛法(随机 ...

  8. 数学建模学习笔记(二):非线性规划模型例题与灵敏度分析

    文章目录 前言 一.一个简单的非线性规划模型 二.问题的求解 1.模型的建立与求解 2.得出结论 三.灵敏度分析 总结 参考书目 前言 数学建模解决问题的过程一般分为五个步骤,称为五步方法,五个步骤如 ...

  9. Python小白的数学建模课-12.非线性规划

    非线性规划是指目标函数或约束条件中包含非线性函数的规划问题,实际就是非线性最优化问题. 从线性规划到非线性规划,不仅是数学方法的差异,更是解决问题的思想方法的转变. 非线性规划问题没有统一的通用方法, ...

最新文章

  1. 成功解决OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor
  2. 【struts2】名为dispatcher的ResultType
  3. Web 文件管理器elFinder 的漏洞链分析
  4. MyBatis 实际使用案例-dataSource
  5. 打造轻量级可视化数据爬取工具-菩提
  6. python字典和集合双向索引_Python字典和集合
  7. 软件工程概论个人作业02(四则运算2)
  8. leetcode239. 滑动窗口最大值
  9. AndroidTelephony学习大纲
  10. C#与Matlab混合编程中遇到的“MathWorks.MATLAB.NET.Arrays.MWNumericArray”的类型初始值设定项引发异常。
  11. java学习(六)多线程 下
  12. 使用Vim/Neovim编辑二进制文件
  13. 计算机am3代表,拨开重重迷雾 AMD处理器历代接口解谜
  14. 修改UEditor编辑器上传图片大小限制
  15. 谷歌插件学习必备准备知识代码提示插件调试
  16. 泾阳县副县长崔巍领导一行莅临秦储指导交流
  17. 复古传奇服务器维护时间,复古传奇手游刷怪时间
  18. 七牛云被攻击偷跑流量
  19. vscode - 史上最优秀的 IDE ?
  20. 我是一只IT小小鸟(转)

热门文章

  1. 用ubuntu的使用习惯使用windows (by quqi99)
  2. 利用Hexo+github搭建博客,零成本、无需域名、服务器
  3. MMS - 什么是MMS?
  4. 2021年软件测试入门到进阶全套学习内容
  5. java+mysql crm客户关系区块链毕业管理系统设计与论文
  6. oneAPI 、DPC++ 学习篇章
  7. Smart Contract Vulnerabilities:Vulnerable Does Not Imply Exploited总结
  8. 微信小程序-优化接口代码-提取公共接口路径
  9. mysql8.0字符集排序规则_MySQL 的字符集与排序规则
  10. 贪财好色,做个俗人。