Code covered by the BSD License

# MIMOtool

### Giampiero Campa (view profile)

12 Nov 2001 (Updated )

Multi Input Multi Output Systems Toolbox

```function [X,OPTIONS,lambda,HESSIAN]=constr(FUN,X,OPTIONS,VLB,VUB,GRADFUN,varargin)

%CONSTR Finds the constrained minimum of a function of several variables.
%   This is a wrapper for FMINCON inside mimotool/jtools
%
%   X=CONSTR('FUN',X0) starts at X0 and finds a constrained minimum to
%   the function which is described in FUN (usually an M-file: FUN.M).
%   The function 'FUN' should return two arguments: a scalar value of the
%   function to be minimized, F, and a matrix of constraints, G:
%   [F,G]=FUN(X). F is minimized such that G <= zeros(size(G)).
%
%   X=CONSTR('FUN',X,OPTIONS) allows a vector of optional parameters to
%
%   X=CONSTR('FUN',X,OPTIONS,VLB,VUB) defines a set of lower and upper
%   bounds on the design variables, X, so that the solution is always in
%   the range VLB <= X <= VUB.
%
%   'GRADFUN' to be entered which returns the partial derivatives of the
%   function and the constraints at X:  [gf,GC] = GRADFUN(X).
%   numeric gradients during the first iteration.
%
%   problem-dependent parameters P1,P2,... directly to the functions FUN
%   empty matrices for OPTIONS, VLB, VUB, and 'GRADFUN' to use the
%   default values.
%
%   [X,OPTIONS]=CONSTR('FUN',X0,...) returns the parameters used in the
%   optimization method.  For example, OPTIONS(10) contains the number
%   of function evaluations used.
%
%   [X,OPTIONS,LAMBDA]=CONSTR('FUN',X0,...) returns the Lagrange multipliers
%   at the solution X in the vector LAMBDA.
%
%   [X,OPTIONS,LAMBDA,HESS]=CONSTR('FUN',X0,...) returns the quasi-Newton
%   approximation to the Hessian matrix at the solution X.
%
%
%   extra parameters, P1, P2, ... to be passed directly to FUN:
%   [F,G]=FUN(X,P1,P2,...). Empty arguments ([]) are ignored.

if nargin < 2, error('constr requires two input arguments'); end
if nargin < 3, OPTIONS=[]; end
if nargin < 4, VLB=[]; end
if nargin < 5, VUB=[]; end
if nargin < 6, GRADFUN=[]; end

if ~isempty(OPTIONS),
options=optimset('MaxIter',OPTIONS(14),'TolX',OPTIONS(2),'TolFun',OPTIONS(3));
if OPTIONS(1),
options=optimset(options,'Display','iter');
end
end