American Mathematical Modeling Contest (matlab self-study) of nonlinear programming

Nonlinear Programming

Basics:

rand函数用法:rand(a,b)生成一个行为a列为b的随机矩阵 
zeros函数用法:zeros(a,b)生成一个行为a列为b的零矩阵

Mathematical model of nonlinear programming:

Here Insert Picture Description
Here Insert Picture Description
Example:
Here Insert Picture Description
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
Released two original articles · won praise 0 · Views 37

Guess you like

Origin blog.csdn.net/weixin_44544406/article/details/104021176