optimize: clean up lint
MODIFY
optimize/convex/lp/simplex_test.go
optimize/convex/lp/simplex_test.go
@@ -173,7 +173,7 @@ func testRandomSimplex(t *testing.T, nTest int, pZero float64, maxN int, rnd *ra
}
}
-func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b []float64, convergenceTol float64) error {
+func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b []float64, convergenceTol float64) {
primalOpt, primalX, _, errPrimal := simplex(initialBasic, c, a, b, convergenceTol)
if errPrimal == nil {
// No error solving the simplex, check that the solution is feasible.
@@ -200,7 +200,7 @@ func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b
if primalBad {
t.Errorf("non-known error returned: %s", errPrimal)
}
- return errPrimal
+ return
}
// Compare the result to the answer found from solving the dual LP.
@@ -233,7 +233,7 @@ func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b
// Check about the zero status.
if errPrimal == ErrZeroRow || errPrimal == ErrZeroColumn {
- return errPrimal
+ return
}
// If the primal problem is feasible, then the primal and the dual should
@@ -265,6 +265,4 @@ func testSimplex(t *testing.T, initialBasic []int, c []float64, a mat.Matrix, b
t.Errorf("Primal infeasible but dual not infeasible or unbounded: %s", errDual)
}
}
-
- return errPrimal
}

MODIFY
optimize/guessandcheck_test.go
optimize/guessandcheck_test.go
@@ -27,10 +27,16 @@ func TestGuessAndCheck(t *testing.T) {
panic("bad test")
}
initX := make([]float64, dim)
- Minimize(problem, initX, nil, &GuessAndCheck{Rander: d})
+ _, err := Minimize(problem, initX, nil, &GuessAndCheck{Rander: d})
+ if err != nil {
+ t.Errorf("unexpected error running Minimize with nil settings: %v", err)
+ }
settings := &Settings{}
settings.Concurrent = 5
settings.MajorIterations = 15
- Minimize(problem, initX, settings, &GuessAndCheck{Rander: d})
+ _, err = Minimize(problem, initX, settings, &GuessAndCheck{Rander: d})
+ if err != nil {
+ t.Errorf("unexpected error running Minimize with settings %+v: %v", settings, err)
+ }
}

MODIFY
optimize/newton.go
optimize/newton.go
@@ -152,10 +152,12 @@ func (n *Newton) NextDirection(loc *Location, dir []float64) (stepSize float64)
pd := n.chol.Factorize(n.hess)
if pd {
// Store the solution in d's backing array, dir.
- n.chol.SolveVecTo(d, grad)
+ err := n.chol.SolveVecTo(d, grad)
+ if err == nil {
d.ScaleVec(-1, d)
return 1
}
+ }
// Modified Hessian is not PD, so increase tau.
n.tau = math.Max(n.Increase*n.tau, 0.001)
}

optimize: clean up lint