Matlab: syntax of the fmincon with active-set method and only inequality constraints?

混江龙づ霸主 提交于 2019-12-25 06:25:19

问题


I am trying to set up fmincon with the active-set method for the linear constrained minimisation problem where minimising the objective function @fun such that

but the trials firing odd errors more in the history.

Trial 1

[x,fval]=fmincon(@fun, Guess, A, b)

Trial 2

options = optimoptions('fmincon','Algorithm','active-set');
[x,fval]=fmincon(@fun, Guess, A, b, options)

回答1:


You are using the wrong options for the algorithm. MATLAB looks at the parameters you provide and uses an algorithm that uses those parameters. It throws a warning because different algorithms can have different results (and you should never ignore these) 'trust-region-reflective' is the default algorithm for fmincon. From the documentation:

'trust-region-reflective' requires you to provide a gradient, and allows only bounds or linear equality constraints, but not both.

The documentation for your call to fmincon says:

x = fmincon(fun,x0,A,b) starts at x0 and attempts to find a minimizer x of the function described in fun subject to the linear inequalities A*x ≤ b. x0 can be a scalar, vector, or matrix.

You probably intended to use

x = fmincon(fun,x0,A,b,Aeq,beq)

Where you would have A = [], b = [], and Aeq and beq be whatever you had A and b to before (if you want to use trust-region-reflective).

Your second trial did not work because you're actually calling x = fmincon(fun,x0,A,b,Aeq,beq). You instead try to pass an options structure.

This page explains how to set options

EDIT: If you want to pass options, you have to specify all the optional parameters:

[x,fval] = fmincon(@DijIIii,x0, A , b,[], [], [], [],@nonlcon,options);


来源:https://stackoverflow.com/questions/19600062/matlab-syntax-of-the-fmincon-with-active-set-method-and-only-inequality-constra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!