Skip to content
This repository was archived by the owner on Nov 23, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bisection.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ package optimize

import "math"

const (
defaultBisectionCurvature = 0.9
)

// Bisection is a Linesearcher that uses a bisection to find a point that
// satisfies the strong Wolfe conditions with the given curvature factor and
// sufficient decrease factor of zero.
// a decrease factor of zero.
type Bisection struct {
// CurvatureFactor is the constant factor in the curvature condition.
// Smaller values result in a more exact line search.
Expand Down Expand Up @@ -39,7 +43,7 @@ func (b *Bisection) Init(f, g float64, step float64) Operation {
}

if b.CurvatureFactor == 0 {
b.CurvatureFactor = 0.9
b.CurvatureFactor = defaultBisectionCurvature
}
if b.CurvatureFactor <= 0 || b.CurvatureFactor >= 1 {
panic("bisection: CurvatureFactor not between 0 and 1")
Expand Down Expand Up @@ -75,7 +79,7 @@ func (b *Bisection) Iterate(f, g float64) (Operation, float64, error) {
// See if the function value is good enough to make progress. If it is,
// evaluate the gradient. If not, set it to the upper bound if the bound
// has not yet been found, otherwise iterate toward the minimum location.
if f <= b.minF {
if f <= minF {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is the correct condition but please check.

b.lastF = f
b.lastOp = GradEvaluation
return b.lastOp, b.currStep, nil
Expand Down