最优化——FR共轭梯度法matlab程序

这是一个使用Matlab实现的FR共轭梯度法求解优化问题的程序。程序包括了初始化、搜索方向形成、线性搜索、新点计算等步骤,并在示例函数f1上进行了测试,展示了如何调用该方法进行优化求解。
摘要由CSDN通过智能技术生成

%  cg.m

function [x, output] = cg(fun, dfun, x0)
% fun: character variable, the name of function computing objective function
% dfun: character variable, the name of function computing the gradient of objective function
% x0: real vector, input initial point
% x :real vector, output solution
% output: structure variable, output the value of f, the number ofiteration, the number of function evaluations and the norm of gradient at last point x
%
% Step 1: initialization
%
epsi = 1.0e-3; % termination tolenrence
k = 0; % the number of iteration
funcN = 0; % the number of function evaluation
rho = 0.01; l = 0.15; u = 0.85;
x = x0;
f = feval(fun, x);
funcN = funcN + 1;
n = length(x0);
%
% Step 2: check convergence condition
%
g = feval(dfun, x);
while norm(g) > epsi & k <= 150
%

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值