第三章 非线性规划

注意:请安装 TeX All The Things 这款Chrome浏览器插件才能正确显示公式。

链接如下:https://chrome.google.com/webstore/detail/tex-all-the-things/cbimabofgmfdkicghcadidpemeenbffn

 


 3.1 非线性规划的Matlab解法

Matlab中非线性规划的数学模型:

\[\begin{gathered}
\begin{array}{*{20}{c}}
{}
\end{array}\begin{array}{*{20}{c}}
{}
\end{array}\min \begin{array}{*{20}{c}}
{}
\end{array}f(x) \hfill \\
s.t.\left\{ \begin{gathered}
A \cdot x \leqslant b, \hfill \\
Aeq \cdot x = beq, \hfill \\
c(x) \leqslant 0, \hfill \\
ceq(x) = 0, \hfill \\
lb \leqslant x \leqslant ub. \hfill \\
\end{gathered} \right. \hfill \\
\end{gathered} \]

 

Matlab中的命令是:

[x,fval]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)

 

例 求下列非线性规划:

\[\begin{gathered}
\begin{array}{*{20}{c}}
{}
\end{array}\begin{array}{*{20}{c}}
{}
\end{array}\min \begin{array}{*{20}{c}}
{}
\end{array}f(x) = x_1^2 + x_2^2 + x_3^2 + 8, \hfill \\
s.t.\left\{ \begin{gathered}
x_1^2 - {x_2} + x_3^2 \geqslant 0, \hfill \\
{x_1} + x_2^2 + x_3^2 \leqslant 20, \hfill \\
- {x_1} - x_2^2 + 2 = 0, \hfill \\
{x_2} + 2x_3^2 = 3, \hfill \\
{x_1},{x_2},{x_3} \geqslant 0. \hfill \\
\end{gathered} \right. \hfill \\
\end{gathered} \]

 

Matlab 编程如下:

共分为三部分:

子函数1:

function f=fun1(x);
f=sum(x.^2)+8;

子函数2:

function [g,h]=fun2(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]; %非线性等式约束

主函数:

[x,y]=fmincon('fun1',rand(3,1),[],[],[],[],zeros(3,1),[],'fun2')

 


 

3.2约束极值问题


 

3.2.1二次规划

\[\begin{gathered}
\min \begin{array}{*{20}{c}}
{}
\end{array}\frac{1}{2}{{\mathbf{x}}^T}{\mathbf{Hx}} + {f^T}{\mathbf{x}} \hfill \\
s.t.\left\{ \begin{gathered}
{\mathbf{Ax}} \leqslant b, \hfill \\
Aeq \cdot {\mathbf{x}} = beq, \hfill \\
lb \leqslant {\mathbf{x}} \leqslant ub. \hfill \\
\end{gathered} \right. \hfill \\
\end{gathered} \]

Matlab中求解二次规划的命令是:

[x,fval]=quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)

  

例子:

\[\begin{gathered}
\begin{array}{*{20}{c}}
{}
\end{array}\begin{array}{*{20}{c}}
{}
\end{array}\min f(x) = 2x_1^2 - 4{x_1}{x_2} + 4x_2^2 - 6{x_1} - 3{x_2} \hfill \\
s.t.\left\{ \begin{gathered}
{x_1} + {x_2} \leqslant 3, \hfill \\
4{x_1} + {x_2} \leqslant 9, \hfill \\
{x_1},{x_2} \geqslant 0. \hfill \\
\end{gathered} \right. \hfill \\
\end{gathered} \]

 

解:程序如下

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))

  

 

 

  

posted @ 2019-07-25 18:59  WhoDreamsSky  阅读(334)  评论(0编辑  收藏  举报