★
小木虫: 金币+0.5, 给个红包,谢谢回帖
引用回帖:
kubilife at 2016-05-27 23:33:51
看起来乱乱的,感觉最核心的代码是看不到的
...
内置函数的看不到!
这个可以看到啊!
function [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon(FUN,X,A,B,Aeq,Beq,LB,UB,NONLCON,options,varargin)
%FMINCON Finds the constrained minimum of a function of several variables.
% FMINCON solves problems of the form:
% min F(X) subject to: A*X <= B, Aeq*X = Beq (linear constraints)
% X C(X) <= 0, Ceq(X) = 0 (nonlinear constraints)
% LB <= X <= UB
%
% X=FMINCON(FUN,X0,A,B) starts at X0 and finds a minimum X to the function
% FUN, subject to the linear inequalities A*X <= B. FUN accepts input X and
% returns a scalar function value F evaluated at X. X0 may be a scalar,
% vector, or matrix.
%
% X=FMINCON(FUN,X0,A,B,Aeq,Beq) minimizes FUN subject to the linear equalities
% Aeq*X = Beq as well as A*X <= B. (Set A=[] and B=[] if no inequalities exist.)
%
% X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB) defines a set of lower and upper
% bounds on the design variables, X, so that the solution is in
% the range LB <= X <= UB. Use empty matrices for LB and UB
% if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below;
% set UB(i) = Inf if X(i) is unbounded above.
%
% X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON) subjects the minimization to the
% constraints defined in NONLCON. The function NONLCON accepts X and returns
% the vectors C and Ceq, representing the nonlinear inequalities and equalities
% respectively. FMINCON minimizes FUN such that C(X)<=0 and Ceq(X)=0.
% (Set LB=[] and/or UB=[] if no bounds exist.)
%
% X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS) minimizes with the
% default optimization parameters replaced by values in the structure OPTIONS,
% an argument created with the OPTIMSET function. See OPTIMSET for details. Used
% options are Display, TolX, TolFun, TolCon, DerivativeCheck, Diagnostics, GradObj,
% GradConstr, Hessian, MaxFunEvals, MaxIter, DiffMinChange and DiffMaxChange,
% LargeScale, MaxPCGIter, PrecondBandWidth, TolPCG, TypicalX, Hessian, HessMult,
% HessPattern. Use the GradObj option to specify that FUN also returns a second
% output argument G that is the partial derivatives of the function df/dX, at the
% point X. Use the Hessian option to specify that FUN also returns a third output
% argument H that is the 2nd partial derivatives of the function (the Hessian) at the
% point X. The Hessian is only used by the large-scale method, not the
% line-search method. Use the GradConstr option to specify that NONLCON also
% returns third and fourth output arguments GC and GCeq, where GC is the partial
% derivatives of the constraint vector of inequalities C, and GCeq is the partial
% derivatives of the constraint vector of equalities Ceq. Use OPTIONS = [] as a
% place holder if no options are set.
%
% X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS,P1,P2,...) passes the
% problem-dependent parameters P1,P2,... directly to the functions FUN
% and NONLCON: feval(FUN,X,P1,P2,...) and feval(NONLCON,X,P1,P2,...). Pass
% empty matrices for A, B, Aeq, Beq, OPTIONS, LB, UB, and NONLCON to use the
% default values.
%
% [X,FVAL]=FMINCON(FUN,X0,...) returns the value of the objective
% function FUN at the solution X.
%
% [X,FVAL,EXITFLAG]=FMINCON(FUN,X0,...) returns a string EXITFLAG that
% describes the exit condition of FMINCON.
% If EXITFLAG is:
% > 0 then FMINCON converged to a solution X.
% 0 then the maximum number of function evaluations was reached.
% < 0 then FMINCON did not converge to a solution.
%
% [X,FVAL,EXITFLAG,OUTPUT]=FMINCON(FUN,X0,...) returns a structure
% OUTPUT with the number of iterations taken in OUTPUT.iterations, the number
% of function evaluations in OUTPUT.funcCount, the algorithm used in
% OUTPUT.algorithm, the number of CG iterations (if used) in OUTPUT.cgiterations,
% and the first-order optimality (if used) in OUTPUT.firstorderopt.
%
% [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=FMINCON(FUN,X0,...) returns the Lagrange multipliers
% at the solution X: LAMBDA.lower for LB, LAMBDA.upper for UB, LAMBD