From 3818273ca32491d59c4bbcf42f307cdd7befb4dd Mon Sep 17 00:00:00 2001 From: Vladimir Chalupecky Date: Fri, 18 Sep 2015 11:49:41 +0900 Subject: [PATCH] Drop () from FuncName() in comments --- cg.go | 2 +- functions/minsurf_test.go | 4 ++-- interfaces.go | 8 ++++---- linesearch.go | 8 ++++---- local.go | 14 +++++++------- termination.go | 2 +- types.go | 14 +++++++------- unconstrained_test.go | 6 +++--- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cg.go b/cg.go index b618093..3aba076 100644 --- a/cg.go +++ b/cg.go @@ -40,7 +40,7 @@ type CGVariant interface { // - The angle between the gradients at two consecutive iterations ∇f_k and // ∇f_{k+1} is too large. // - The direction d_{k+1} is not a descent direction. -// - β_k given by CGVariant.Beta() is equal to zero. +// - β_k returned from CGVariant.Beta is equal to zero. // // The line search for CG must yield step sizes that satisfy the strong Wolfe // conditions at every iteration, otherwise the generated search direction diff --git a/functions/minsurf_test.go b/functions/minsurf_test.go index 8b9a38c..0f93979 100644 --- a/functions/minsurf_test.go +++ b/functions/minsurf_test.go @@ -32,8 +32,8 @@ func TestMinimalSurface(t *testing.T) { } // Test that the gradient at the minimum is small enough. - // In some sense this test is not completely correct because ExactX() - // is the exact solution to the continuous problem projected on the + // In some sense this test is not completely correct because ExactX + // returns the exact solution to the continuous problem projected on the // grid, not the exact solution to the discrete problem which we are // solving. This is the reason why a relatively loose tolerance 1e-4 // must be used. diff --git a/interfaces.go b/interfaces.go index 6f977a0..04c7dac 100644 --- a/interfaces.go +++ b/interfaces.go @@ -31,19 +31,19 @@ package optimize type Method 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(). + // The initial location must be valid as specified by Needs. Init(loc *Location) (Operation, error) // Iterate retrieves data from loc, performs one iteration of the method, // updates loc and returns the next operation. // TODO(vladimir-ch): When decided, say something whether the contents of - // Location is preserved between calls to Iterate(). + // Location is preserved between calls to Iterate. Iterate(loc *Location) (Operation, error) // Needs specifies information about the objective function needed by the // optimizer beyond just the function value. The information is used // internally for initialization and must match evaluation types returned - // by Init() and Iterate() during the optimization process. + // by Init and Iterate during the optimization process. Needs() struct { Gradient bool Hessian bool @@ -52,7 +52,7 @@ type Method interface { // Statuser can report the status and any error. It is intended for methods as // an additional error reporting mechanism apart from the errors returned from -// Init() and Iterate(). +// Init and Iterate. type Statuser interface { Status() (Status, error) } diff --git a/linesearch.go b/linesearch.go index 7f0de01..b0e776d 100644 --- a/linesearch.go +++ b/linesearch.go @@ -22,13 +22,13 @@ type LinesearchMethod struct { dir []float64 // Search direction for the current iteration. first bool // Indicator of the first iteration. - nextMajor bool // Indicates that MajorIteration must be requested at the next call to Iterate(). + nextMajor bool // Indicates that MajorIteration must be requested at the next call to Iterate. loc Location // Storage for intermediate locations. eval Operation // Indicator of valid fields in loc. - lastStep float64 // Step taken from x in the previous call to Iterate(). - lastOp Operation // Operation returned from the previous call to Iterate(). + lastStep float64 // Step taken from x in the previous call to Iterate. + lastOp Operation // Operation returned from the previous call to Iterate. } func (ls *LinesearchMethod) Init(loc *Location) (Operation, error) { @@ -60,7 +60,7 @@ func (ls *LinesearchMethod) Iterate(loc *Location) (Operation, error) { switch ls.lastOp { case NoOperation: // TODO(vladimir-ch): We have previously returned with an error and - // Init() was not called. What to do? What about ls's internal state? + // Init was not called. What to do? What about ls's internal state? case MajorIteration: // We previously requested MajorIteration but since we're here, the diff --git a/local.go b/local.go index 6622df4..5b65a8f 100644 --- a/local.go +++ b/local.go @@ -21,7 +21,7 @@ import ( // routines that evaluate the objective function, gradient, and other // quantities related to the problem. The objective function, p.Func, must not // be nil. The optimization method used may require other fields to be non-nil -// as specified by method.Needs(). Local will panic if these are not met. The +// as specified by method.Needs. Local will panic if these are not met. The // method can be determined automatically from the supplied problem which is // described below. // @@ -34,7 +34,7 @@ import ( // problem dimension. // // The third argument contains the settings for the minimization. It is here that -// gradient tolerance, etc. are specified. The DefaultSettings() function +// gradient tolerance, etc. are specified. The DefaultSettings function // can be called for a Settings struct with the default values initialized. // If settings == nil, the default settings are used. See the documentation // for the Settings structure for more information. The optimization Method used @@ -50,8 +50,8 @@ import ( // in the method will be populated with default values. The methods are also // designed such that they can be reused in future calls to Local. // -// If method implements Statuser, method.Status() is called before every call -// to method.Iterate(). If the returned Status is not NotTerminated or the +// If method implements Statuser, method.Status is called before every call +// to method.Iterate. If the returned Status is not NotTerminated or the // error is non-nil, the optimization run is terminated. // // 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 } for { - // Sequentially call method.Iterate(), performing the operations it has + // Sequentially call method.Iterate, performing the operations it has // requested, until convergence. switch op { @@ -311,7 +311,7 @@ func getStartingLocation(p *Problem, method Method, initX []float64, stats *Stat // checkConvergence returns NotTerminated if the Location does not satisfy the // convergence criteria given by settings. Otherwise a corresponding status is // returned. -// Unlike checkLimits, it is called by Local() only at MajorIterations. +// Unlike checkLimits, checkConvergence is called by Local only at MajorIterations. func checkConvergence(loc *Location, settings *Settings) Status { if loc.Gradient != nil { norm := floats.Norm(loc.Gradient, math.Inf(1)) @@ -333,7 +333,7 @@ func checkConvergence(loc *Location, settings *Settings) Status { // checkLimits returns NotTerminated status if the various limits given by // settings has not been reached. Otherwise it returns a corresponding status. -// Unlike checkConvergence(), it is called by Local() at _every_ iteration. +// Unlike checkConvergence, checkLimits is called by Local at _every_ iteration. func checkLimits(loc *Location, stats *Stats, settings *Settings) Status { // Check the objective function value for negative infinity because it // could break the linesearches and -inf is the best we can do anyway. diff --git a/termination.go b/termination.go index 2a53a06..43c2df6 100644 --- a/termination.go +++ b/termination.go @@ -107,7 +107,7 @@ var statuses = []struct { // calls to NewStatus are not thread safe. // // NewStatus takes in three arguments, the string that should be output from -// Status.String(), a boolean if the status indicates early optimization conclusion, +// Status.String, a boolean if the status indicates early optimization conclusion, // and the error to return from Err (if any). func NewStatus(name string, early bool, err error) Status { statuses = append(statuses, struct { diff --git a/types.go b/types.go index a155613..2c5759d 100644 --- a/types.go +++ b/types.go @@ -98,9 +98,9 @@ type Result struct { // Stats contains the statistics of the run. type Stats struct { MajorIterations int // Total number of major iterations - FuncEvaluations int // Number of evaluations of Func() - GradEvaluations int // Number of evaluations of Grad() - HessEvaluations int // Number of evaluations of Hess() + FuncEvaluations int // Number of evaluations of Func + GradEvaluations int // Number of evaluations of Grad + HessEvaluations int // Number of evaluations of Hess Runtime time.Duration // Total runtime of the optimization } @@ -154,7 +154,7 @@ func (p Problem) satisfies(method Method) error { // Settings represents settings of the optimization run. It contains initial // settings, convergence information, and Recorder information. In general, users -// should use DefaultSettings() rather than constructing a Settings literal. +// should use DefaultSettings rather than constructing a Settings literal. // // If UseInitData is true, InitialValue, InitialGradient and InitialHessian // specify function information at the initial location. @@ -208,21 +208,21 @@ type Settings struct { // FuncEvaluations is the maximum allowed number of function evaluations. // FunctionEvaluationLimit status is returned if the total number of calls - // to Func() equals or exceeds this number. + // to Func equals or exceeds this number. // If it equals zero, this setting has no effect. // The default value is 0. FuncEvaluations int // GradEvaluations is the maximum allowed number of gradient evaluations. // GradientEvaluationLimit status is returned if the total number of calls - // to Grad() equals or exceeds this number. + // to Grad equals or exceeds this number. // If it equals zero, this setting has no effect. // The default value is 0. GradEvaluations int // HessEvaluations is the maximum allowed number of Hessian evaluations. // HessianEvaluationLimit status is returned if the total number of calls - // to Hess() equals or exceeds this number. + // to Hess equals or exceeds this number. // If it equals zero, this setting has no effect. // The default value is 0. HessEvaluations int diff --git a/unconstrained_test.go b/unconstrained_test.go index 2201562..27125ed 100644 --- a/unconstrained_test.go +++ b/unconstrained_test.go @@ -31,7 +31,7 @@ type unconstrainedTest struct { // the default value of 20 will be used. fIter int // long indicates that the test takes long time to finish and will be - // excluded if testing.Short() is true. + // excluded if testing.Short returns true. long bool } @@ -995,7 +995,7 @@ func newVariablyDimensioned(dim int, gradTol float64) unconstrainedTest { func TestLocal(t *testing.T) { var tests []unconstrainedTest - // Mix of functions with and without Grad() method. + // Mix of functions with and without Grad method. tests = append(tests, gradFreeTests...) tests = append(tests, gradientDescentTests...) testLocal(t, gradientDescentTests, nil) @@ -1003,7 +1003,7 @@ func TestLocal(t *testing.T) { func TestNelderMead(t *testing.T) { var tests []unconstrainedTest - // Mix of functions with and without Grad() method. + // Mix of functions with and without Grad method. tests = append(tests, gradFreeTests...) tests = append(tests, gradientDescentTests...) testLocal(t, tests, &NelderMead{})