MATLAB中非线性规划的数学模型标准形式:

clip_image001

Matlab命令为:

X = fmincon(fun, x0, A, B, Aeq, Beq, LB, UB, nonlcon, options)

例如:

clip_image002

其对应代码为:

fun1.m:

function f = fun1(x)

f = x(1)^2 + x(2)^2 +8;

fun2.m:

function [g,h] = fun2(x) % 等式约束

g = -x(1)^2 + x(2);

h = -x(1) – x(2)^2 +2

主程序:

options = optimset;

[x ,y] = fmincon(‘fun1′, rand(2, 1), [], [], [], [], zeros(2, 1), [],…

‘fun2′, options)

运行结果:

clip_image003

Comments are closed.

Post Navigation