非线性规划

发布时间 2023-05-03 22:04:25作者: 5hithin

非线性规划

数学模型

Ax<=B
Aeq x=Beq
C(x)<=0
Ceq(x)=0
min F(X) subject to: AX <= B, AeqX = Beq (linear constraints)
C(X) <= 0, Ceq(X) = 0 (nonlinear constraints)
LB <= X <= UB (bounds)

Matlab的命令

X = fmincon(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS) 

minimizes with the default optimization parameters replaced by values in OPTIONS, an argument created with the OPTIMOPTIONS function. See OPTIMOPTIONS for details. For a list of options accepted by fmincon refer to the documentation.
NONLCON 是用M文件定义的非线性向量函数C(X),Ceq(x)

报错

Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.

原因

(猜测)使用fmincon函数的时候将nonlcon的参数传入[],然而这个函数的设置的最初目的就是为了实现非线性规划,所以nonlcon不能为空

心得

  • 判断是否要使用非线性规划函数的依据:
    目标函数是否为非线性函数;
  • 若使用了fmincon,则nonlcon不能为空
  • 注意Fun默认的是求最小值,如果要求最大值,记得在前面加个负号
  • 线性规划函数linprog中变量和函数大部分都使用矩阵来标记,而非线性规划函数fmincon中目标函数和非线性函数不能使用矩阵,要单独用m文件编写函数