解非线性约束 Matlab

简介

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')
Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/13444433.html