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

Commit 3818273

Browse files
committed
Drop () from FuncName() in comments
1 parent e616c70 commit 3818273

8 files changed

+29
-29
lines changed

cg.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type CGVariant interface {
4040
// - The angle between the gradients at two consecutive iterations ∇f_k and
4141
// ∇f_{k+1} is too large.
4242
// - The direction d_{k+1} is not a descent direction.
43-
// - β_k given by CGVariant.Beta() is equal to zero.
43+
// - β_k returned from CGVariant.Beta is equal to zero.
4444
//
4545
// The line search for CG must yield step sizes that satisfy the strong Wolfe
4646
// conditions at every iteration, otherwise the generated search direction

functions/minsurf_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func TestMinimalSurface(t *testing.T) {
3232
}
3333

3434
// Test that the gradient at the minimum is small enough.
35-
// In some sense this test is not completely correct because ExactX()
36-
// is the exact solution to the continuous problem projected on the
35+
// In some sense this test is not completely correct because ExactX
36+
// returns the exact solution to the continuous problem projected on the
3737
// grid, not the exact solution to the discrete problem which we are
3838
// solving. This is the reason why a relatively loose tolerance 1e-4
3939
// must be used.

interfaces.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ package optimize
3131
type Method interface {
3232
// Init initializes the method based on the initial data in loc, updates it
3333
// and returns the first operation to be carried out by the caller.
34-
// The initial location must be valid as specified by Needs().
34+
// The initial location must be valid as specified by Needs.
3535
Init(loc *Location) (Operation, error)
3636

3737
// Iterate retrieves data from loc, performs one iteration of the method,
3838
// updates loc and returns the next operation.
3939
// TODO(vladimir-ch): When decided, say something whether the contents of
40-
// Location is preserved between calls to Iterate().
40+
// Location is preserved between calls to Iterate.
4141
Iterate(loc *Location) (Operation, error)
4242

4343
// Needs specifies information about the objective function needed by the
4444
// optimizer beyond just the function value. The information is used
4545
// internally for initialization and must match evaluation types returned
46-
// by Init() and Iterate() during the optimization process.
46+
// by Init and Iterate during the optimization process.
4747
Needs() struct {
4848
Gradient bool
4949
Hessian bool
@@ -52,7 +52,7 @@ type Method interface {
5252

5353
// Statuser can report the status and any error. It is intended for methods as
5454
// an additional error reporting mechanism apart from the errors returned from
55-
// Init() and Iterate().
55+
// Init and Iterate.
5656
type Statuser interface {
5757
Status() (Status, error)
5858
}

linesearch.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ type LinesearchMethod struct {
2222
dir []float64 // Search direction for the current iteration.
2323

2424
first bool // Indicator of the first iteration.
25-
nextMajor bool // Indicates that MajorIteration must be requested at the next call to Iterate().
25+
nextMajor bool // Indicates that MajorIteration must be requested at the next call to Iterate.
2626

2727
loc Location // Storage for intermediate locations.
2828
eval Operation // Indicator of valid fields in loc.
2929

30-
lastStep float64 // Step taken from x in the previous call to Iterate().
31-
lastOp Operation // Operation returned from the previous call to Iterate().
30+
lastStep float64 // Step taken from x in the previous call to Iterate.
31+
lastOp Operation // Operation returned from the previous call to Iterate.
3232
}
3333

3434
func (ls *LinesearchMethod) Init(loc *Location) (Operation, error) {
@@ -60,7 +60,7 @@ func (ls *LinesearchMethod) Iterate(loc *Location) (Operation, error) {
6060
switch ls.lastOp {
6161
case NoOperation:
6262
// TODO(vladimir-ch): We have previously returned with an error and
63-
// Init() was not called. What to do? What about ls's internal state?
63+
// Init was not called. What to do? What about ls's internal state?
6464

6565
case MajorIteration:
6666
// We previously requested MajorIteration but since we're here, the

local.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
// routines that evaluate the objective function, gradient, and other
2222
// quantities related to the problem. The objective function, p.Func, must not
2323
// be nil. The optimization method used may require other fields to be non-nil
24-
// as specified by method.Needs(). Local will panic if these are not met. The
24+
// as specified by method.Needs. Local will panic if these are not met. The
2525
// method can be determined automatically from the supplied problem which is
2626
// described below.
2727
//
@@ -34,7 +34,7 @@ import (
3434
// problem dimension.
3535
//
3636
// The third argument contains the settings for the minimization. It is here that
37-
// gradient tolerance, etc. are specified. The DefaultSettings() function
37+
// gradient tolerance, etc. are specified. The DefaultSettings function
3838
// can be called for a Settings struct with the default values initialized.
3939
// If settings == nil, the default settings are used. See the documentation
4040
// for the Settings structure for more information. The optimization Method used
@@ -50,8 +50,8 @@ import (
5050
// in the method will be populated with default values. The methods are also
5151
// designed such that they can be reused in future calls to Local.
5252
//
53-
// If method implements Statuser, method.Status() is called before every call
54-
// to method.Iterate(). If the returned Status is not NotTerminated or the
53+
// If method implements Statuser, method.Status is called before every call
54+
// to method.Iterate. If the returned Status is not NotTerminated or the
5555
// error is non-nil, the optimization run is terminated.
5656
//
5757
// Local returns a Result struct and any error that occurred. See the
@@ -151,7 +151,7 @@ func minimize(p *Problem, method Method, settings *Settings, stats *Stats, optLo
151151
}
152152

153153
for {
154-
// Sequentially call method.Iterate(), performing the operations it has
154+
// Sequentially call method.Iterate, performing the operations it has
155155
// requested, until convergence.
156156

157157
switch op {
@@ -311,7 +311,7 @@ func getStartingLocation(p *Problem, method Method, initX []float64, stats *Stat
311311
// checkConvergence returns NotTerminated if the Location does not satisfy the
312312
// convergence criteria given by settings. Otherwise a corresponding status is
313313
// returned.
314-
// Unlike checkLimits, it is called by Local() only at MajorIterations.
314+
// Unlike checkLimits, checkConvergence is called by Local only at MajorIterations.
315315
func checkConvergence(loc *Location, settings *Settings) Status {
316316
if loc.Gradient != nil {
317317
norm := floats.Norm(loc.Gradient, math.Inf(1))
@@ -333,7 +333,7 @@ func checkConvergence(loc *Location, settings *Settings) Status {
333333

334334
// checkLimits returns NotTerminated status if the various limits given by
335335
// settings has not been reached. Otherwise it returns a corresponding status.
336-
// Unlike checkConvergence(), it is called by Local() at _every_ iteration.
336+
// Unlike checkConvergence, checkLimits is called by Local at _every_ iteration.
337337
func checkLimits(loc *Location, stats *Stats, settings *Settings) Status {
338338
// Check the objective function value for negative infinity because it
339339
// could break the linesearches and -inf is the best we can do anyway.

termination.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var statuses = []struct {
107107
// calls to NewStatus are not thread safe.
108108
//
109109
// NewStatus takes in three arguments, the string that should be output from
110-
// Status.String(), a boolean if the status indicates early optimization conclusion,
110+
// Status.String, a boolean if the status indicates early optimization conclusion,
111111
// and the error to return from Err (if any).
112112
func NewStatus(name string, early bool, err error) Status {
113113
statuses = append(statuses, struct {

types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ type Result struct {
9898
// Stats contains the statistics of the run.
9999
type Stats struct {
100100
MajorIterations int // Total number of major iterations
101-
FuncEvaluations int // Number of evaluations of Func()
102-
GradEvaluations int // Number of evaluations of Grad()
103-
HessEvaluations int // Number of evaluations of Hess()
101+
FuncEvaluations int // Number of evaluations of Func
102+
GradEvaluations int // Number of evaluations of Grad
103+
HessEvaluations int // Number of evaluations of Hess
104104
Runtime time.Duration // Total runtime of the optimization
105105
}
106106

@@ -154,7 +154,7 @@ func (p Problem) satisfies(method Method) error {
154154

155155
// Settings represents settings of the optimization run. It contains initial
156156
// settings, convergence information, and Recorder information. In general, users
157-
// should use DefaultSettings() rather than constructing a Settings literal.
157+
// should use DefaultSettings rather than constructing a Settings literal.
158158
//
159159
// If UseInitData is true, InitialValue, InitialGradient and InitialHessian
160160
// specify function information at the initial location.
@@ -208,21 +208,21 @@ type Settings struct {
208208

209209
// FuncEvaluations is the maximum allowed number of function evaluations.
210210
// FunctionEvaluationLimit status is returned if the total number of calls
211-
// to Func() equals or exceeds this number.
211+
// to Func equals or exceeds this number.
212212
// If it equals zero, this setting has no effect.
213213
// The default value is 0.
214214
FuncEvaluations int
215215

216216
// GradEvaluations is the maximum allowed number of gradient evaluations.
217217
// GradientEvaluationLimit status is returned if the total number of calls
218-
// to Grad() equals or exceeds this number.
218+
// to Grad equals or exceeds this number.
219219
// If it equals zero, this setting has no effect.
220220
// The default value is 0.
221221
GradEvaluations int
222222

223223
// HessEvaluations is the maximum allowed number of Hessian evaluations.
224224
// HessianEvaluationLimit status is returned if the total number of calls
225-
// to Hess() equals or exceeds this number.
225+
// to Hess equals or exceeds this number.
226226
// If it equals zero, this setting has no effect.
227227
// The default value is 0.
228228
HessEvaluations int

unconstrained_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type unconstrainedTest struct {
3131
// the default value of 20 will be used.
3232
fIter int
3333
// long indicates that the test takes long time to finish and will be
34-
// excluded if testing.Short() is true.
34+
// excluded if testing.Short returns true.
3535
long bool
3636
}
3737

@@ -995,15 +995,15 @@ func newVariablyDimensioned(dim int, gradTol float64) unconstrainedTest {
995995

996996
func TestLocal(t *testing.T) {
997997
var tests []unconstrainedTest
998-
// Mix of functions with and without Grad() method.
998+
// Mix of functions with and without Grad method.
999999
tests = append(tests, gradFreeTests...)
10001000
tests = append(tests, gradientDescentTests...)
10011001
testLocal(t, gradientDescentTests, nil)
10021002
}
10031003

10041004
func TestNelderMead(t *testing.T) {
10051005
var tests []unconstrainedTest
1006-
// Mix of functions with and without Grad() method.
1006+
// Mix of functions with and without Grad method.
10071007
tests = append(tests, gradFreeTests...)
10081008
tests = append(tests, gradientDescentTests...)
10091009
testLocal(t, tests, &NelderMead{})

0 commit comments

Comments
 (0)