Change Method to localMethod.
Now that Local is gone, unexport the type.
MODIFY
optimize/bfgs.go
optimize/bfgs.go
@@ -54,7 +54,7 @@ func (b *BFGS) RunGlobal(operation chan<- GlobalTask, result <-chan GlobalTask,
return
}
-func (b *BFGS) Init(loc *Location) (Operation, error) {
+func (b *BFGS) initLocal(loc *Location) (Operation, error) {
if b.Linesearcher == nil {
b.Linesearcher = &Bisection{}
}
@@ -67,7 +67,7 @@ func (b *BFGS) Init(loc *Location) (Operation, error) {
return b.ls.Init(loc)
}
-func (b *BFGS) Iterate(loc *Location) (Operation, error) {
+func (b *BFGS) iterateLocal(loc *Location) (Operation, error) {
return b.ls.Iterate(loc)
}

MODIFY
optimize/cg.go
optimize/cg.go
@@ -117,7 +117,7 @@ func (cg *CG) RunGlobal(operation chan<- GlobalTask, result <-chan GlobalTask, t
return
}
-func (cg *CG) Init(loc *Location) (Operation, error) {
+func (cg *CG) initLocal(loc *Location) (Operation, error) {
if cg.IterationRestartFactor < 0 {
panic("cg: IterationRestartFactor is negative")
}
@@ -151,7 +151,7 @@ func (cg *CG) Init(loc *Location) (Operation, error) {
return cg.ls.Init(loc)
}
-func (cg *CG) Iterate(loc *Location) (Operation, error) {
+func (cg *CG) iterateLocal(loc *Location) (Operation, error) {
return cg.ls.Iterate(loc)
}

MODIFY
optimize/gradientdescent.go
optimize/gradientdescent.go
@@ -38,7 +38,7 @@ func (g *GradientDescent) RunGlobal(operation chan<- GlobalTask, result <-chan G
return
}
-func (g *GradientDescent) Init(loc *Location) (Operation, error) {
+func (g *GradientDescent) initLocal(loc *Location) (Operation, error) {
if g.Linesearcher == nil {
g.Linesearcher = &Backtracking{}
}
@@ -55,7 +55,7 @@ func (g *GradientDescent) Init(loc *Location) (Operation, error) {
return g.ls.Init(loc)
}
-func (g *GradientDescent) Iterate(loc *Location) (Operation, error) {
+func (g *GradientDescent) iterateLocal(loc *Location) (Operation, error) {
return g.ls.Iterate(loc)
}

MODIFY
optimize/interfaces.go
optimize/interfaces.go
package optimize
-// A Method can optimize an objective function.
+// A localMethod can optimize an objective function.
//
// It uses a reverse-communication interface between the optimization method
// and the caller. Method acts as a client that asks the caller to perform
@@ -34,15 +34,15 @@ package optimize
// A Method must not return InitIteration and PostIteration operations. These are
// reserved for the clients to be passed to Recorders. A Method must also not
// combine the Evaluation operations with the Iteration operations.
-type Method interface {
+type localMethod interface {
// Init initializes the method based on the initial data in loc, updates it
// and returns the first operation to be carried out by the caller.
// The initial location must be valid as specified by Needs.
- Init(loc *Location) (Operation, error)
+ initLocal(loc *Location) (Operation, error)
// Iterate retrieves data from loc, performs one iteration of the method,
// updates loc and returns the next operation.
- Iterate(loc *Location) (Operation, error)
+ iterateLocal(loc *Location) (Operation, error)
Needser
}

MODIFY
optimize/lbfgs.go
optimize/lbfgs.go
@@ -60,7 +60,7 @@ func (l *LBFGS) RunGlobal(operation chan<- GlobalTask, result <-chan GlobalTask,
return
}
-func (l *LBFGS) Init(loc *Location) (Operation, error) {
+func (l *LBFGS) initLocal(loc *Location) (Operation, error) {
if l.Linesearcher == nil {
l.Linesearcher = &Bisection{}
}
@@ -77,7 +77,7 @@ func (l *LBFGS) Init(loc *Location) (Operation, error) {
return l.ls.Init(loc)
}
-func (l *LBFGS) Iterate(loc *Location) (Operation, error) {
+func (l *LBFGS) iterateLocal(loc *Location) (Operation, error) {
return l.ls.Iterate(loc)
}

MODIFY
optimize/local.go
optimize/local.go
@@ -11,11 +11,11 @@ import (
// localOptimizer is a helper type for running an optimization using a LocalMethod.
type localOptimizer struct{}
-// RunGlobal controls the optimization run for a LocalMethod. The calling method
+// RunGlobal controls the optimization run for a localMethod. The calling method
// must close the operation channel at the conclusion of the optimization. This
// provides a happens before relationship between the return of status and the
// closure of operation, and thus a call to method.Status (if necessary).
-func (l localOptimizer) runGlobal(method Method, operation chan<- GlobalTask, result <-chan GlobalTask, tasks []GlobalTask) (Status, error) {
+func (l localOptimizer) runGlobal(method localMethod, operation chan<- GlobalTask, result <-chan GlobalTask, tasks []GlobalTask) (Status, error) {
// Local methods start with a fully-specified initial location.
task := tasks[0]
task = l.initialLocation(operation, result, task, method)
@@ -38,7 +38,7 @@ func (l localOptimizer) runGlobal(method Method, operation chan<- GlobalTask, re
return NotTerminated, nil
}
- op, err := method.Init(task.Location)
+ op, err := method.initLocal(task.Location)
if err != nil {
l.finishMethodDone(operation, result, task)
return Failure, err
@@ -52,7 +52,7 @@ Loop:
case PostIteration:
break Loop
default:
- op, err := method.Iterate(r.Location)
+ op, err := method.iterateLocal(r.Location)
if err != nil {
l.finishMethodDone(operation, result, r)
return Failure, err

MODIFY
optimize/neldermead.go
optimize/neldermead.go
@@ -101,7 +101,7 @@ func (n *NelderMead) RunGlobal(operation chan<- GlobalTask, result <-chan Global
return
}
-func (n *NelderMead) Init(loc *Location) (Operation, error) {
+func (n *NelderMead) initLocal(loc *Location) (Operation, error) {
dim := len(loc.X)
if cap(n.vertices) < dim+1 {
n.vertices = make([][]float64, dim+1)
@@ -194,7 +194,7 @@ func computeCentroid(vertices [][]float64, centroid []float64) {
}
}
-func (n *NelderMead) Iterate(loc *Location) (Operation, error) {
+func (n *NelderMead) iterateLocal(loc *Location) (Operation, error) {
dim := len(loc.X)
switch n.lastIter {
case nmInitialize:

MODIFY
optimize/newton.go
optimize/newton.go
@@ -72,7 +72,7 @@ func (n *Newton) RunGlobal(operation chan<- GlobalTask, result <-chan GlobalTask
return
}
-func (n *Newton) Init(loc *Location) (Operation, error) {
+func (n *Newton) initLocal(loc *Location) (Operation, error) {
if n.Increase == 0 {
n.Increase = 5
}
@@ -91,7 +91,7 @@ func (n *Newton) Init(loc *Location) (Operation, error) {
return n.ls.Init(loc)
}
-func (n *Newton) Iterate(loc *Location) (Operation, error) {
+func (n *Newton) iterateLocal(loc *Location) (Operation, error) {
return n.ls.Iterate(loc)
}

Change Method to localMethod.

Now that Local is gone, unexport the type.