简介
matlab 解 非线性约束 函数 fmincon
QU
[min f(x)=x_{1}^{2}+x_{2}^{2}+x_{3}^{2}+8
]
[left{egin{array}{c}
x_{1}^{2}-x_{2}+x_{3}^{2} geq 0 \
x_{1}+x_{2}^{2}+x_{3}^{3} leq 20 \
-x_{1}-x_{2}^{2}+2=0 \
x_{2}+2 x_{3}^{2}=3 \
x_{1}, x_{2}, x_{3} geq 0
end{array}
ight.]
code
目标函数
function f = fun1(x);
f = sum(x.^2) + 8;
约束函数
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')