Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.

Commit 79d85f7

Browse files
committed
Small clean-up in Bisection
1 parent e731aac commit 79d85f7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bisection.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ package optimize
66

77
import "math"
88

9+
const (
10+
defaultBisectionCurvature = 0.9
11+
)
12+
913
// Bisection is a Linesearcher that uses a bisection to find a point that
1014
// satisfies the strong Wolfe conditions with the given curvature factor and
11-
// sufficient decrease factor of zero.
15+
// a decrease factor of zero.
1216
type Bisection struct {
1317
// CurvatureFactor is the constant factor in the curvature condition.
1418
// Smaller values result in a more exact line search.
@@ -39,7 +43,7 @@ func (b *Bisection) Init(f, g float64, step float64) Operation {
3943
}
4044

4145
if b.CurvatureFactor == 0 {
42-
b.CurvatureFactor = 0.9
46+
b.CurvatureFactor = defaultBisectionCurvature
4347
}
4448
if b.CurvatureFactor <= 0 || b.CurvatureFactor >= 1 {
4549
panic("bisection: CurvatureFactor not between 0 and 1")
@@ -75,7 +79,7 @@ func (b *Bisection) Iterate(f, g float64) (Operation, float64, error) {
7579
// See if the function value is good enough to make progress. If it is,
7680
// evaluate the gradient. If not, set it to the upper bound if the bound
7781
// has not yet been found, otherwise iterate toward the minimum location.
78-
if f <= b.minF {
82+
if f <= minF {
7983
b.lastF = f
8084
b.lastOp = GradEvaluation
8185
return b.lastOp, b.currStep, nil

0 commit comments

Comments
 (0)