Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2013-04-13
帖子: 1
声望力: 0 ![]() |
![]()
老师给的一个m文件
function [StepSize info perf] = ... search(ObjFun, Point, Step, Rule, varargin) %Find the answer to problem P: a = argmin f(x+a*d) % % This function will use exact or inexact line search to solve the problem. % When doing inexact line search, you can choose Armijo-Goldstein, Wolfe, % strong Wolfe or you own criterion. % Record g as the gradient of f. % % Call % [StepSize err] = bolinesearch(ObjFun, Point, Step) % [StepSize err] = bolinesearch(ObjFun, Point, Step, Rule) % [StepSize err] = bolinesearch(ObjFun, Point, Step, Rule, p1,p2,...) % [StepSize err perf] = bolinesearch(......) % % Input % ObjFun: f & g in P, function_handle % The function should be declared as a M-function % [F g] = f(x, p1,p2,...) % F is a scalar, along with g an n-vector. % Point: x in P, n-vector % Step: d in P, n-vector % Rule: option & method & criterion to solve P, struct % Rule.crtr: criterion, function_handle % The function should be declared as a M-function % Judge = criterion(Step, StepSize, Data0, Data, flag) % Judge is a logical number with 1 perfect, and Step is just % as metioned above StepSize below, and Data0 & Data are % structs including possible fields F g, flag is a array % including several parameters in the criterion. % choice: boarmgld, bowlf, bostwlf % Rule.mthd: method to get new point, function_handle % The function shoule be declared as a M-function % [NewSize New] = method(ObjFun, Point, Step, StepSize, % Data, p1,p2,...) % notice here StepSize & NewSize can be a scalar array(to % make coding easy), but only the 1st element is just needed % actually. And in that situation the Data & New will be % struct arrays. % choice: bointrplt22, bointrplt33 % Rule.opt: options of iteration, scalar array % opt(1): 0 - exact line search, use .618 method % else - inexact, need crtr & mthd % (2): upper bound of a % (3): maximum of iterations % (4:5): criterion flag, but also can be .618 method flag which % have one element e with default 1e-3 % default: bostwlf - bointrplt33 - [1 10 10 0.95 0.05] % or [0 10 25 1e-4] (if opt(1) = 0) % 请问在使用函数时输入的参数格式是怎样的,又是函数句柄又是结构体我总是输不对 |
![]() |
![]() |