Nonlinear Programming
Basics:
rand函数用法:rand(a,b)生成一个行为a列为b的随机矩阵
zeros函数用法:zeros(a,b)生成一个行为a列为b的零矩阵
Mathematical model of nonlinear programming:
Example:
fun1.m function
function f=fun1(x);
f=sum(x.^2)+8;
fun2.m function
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];
The main program file:
[x,y]=fmincon('fun1',rand(3,1),[],[],[],[],zeros(3,1),[],'fun2')
The results (not the same as on my results and find textbooks do not know why ......):
x =
1.1514 //x1
0.7767 //x2
0.2275 //x3
y =
9.9806 //y