📄 linesearch.java
字号:
package com.tdunning.nr;
import com.tdunning.math.RealFunction;
import Jama.Matrix;
/**
* Encodes a line-search operation on a single function.
* @author Ted Dunning
* Based loosely on the Numerical Recipes function called linsrch defined in section 9.7 of the 2nd Edition.
*/
public class LineSearch {
private static final double ALF = 1.0e-4; // Ensures sufficient decrease in function value.
private static final double TOLX = 1.0e-7; // Convergence criterion on ?x.
private double stpmax;
private RealFunction func;
private Matrix x;
private double f;
/**
* Set up to do line minimizations for a function.
*
* @param stpmax limits the length of the steps so that you do not try to
* evaluate the function in regions where it is undefined or subject to overflow.
* @param func The function to minimize.
*/
public LineSearch(double stpmax, RealFunction func) {
this.stpmax = stpmax;
this.func = func;
}
/**
* Given an n-dimensional point xold[1..n], the value of the function and gradient there, fold
* and g[1..n], and a direction p[1..n], finds a new point x[1..n] along the direction p from
* xold where the function func has decreased 搒ufficiently.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -