matlab的 fmincg 函数,matlab优化函数(比如fmincon)的具体实现代码能不能看到

本文介绍了MATLAB的fmincon函数,用于解决多变量函数的约束最小化问题。该函数支持线性和非线性约束,并可以处理变量的上下界。文章详细展示了fmincon函数的参数用法,并提供了调用示例,帮助读者理解和应用fmincon解决实际优化问题。
摘要由CSDN通过智能技术生成

小木虫: 金币+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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值