optimize: make tests parallel
MODIFY
optimize/cmaes_test.go
optimize/cmaes_test.go
@@ -200,6 +200,7 @@ func cmaTestCases() []cmaTestCase {
}
func TestCmaEsChol(t *testing.T) {
+ t.Parallel()
for i, test := range cmaTestCases() {
src := rand.New(rand.NewSource(1))
method := test.method

MODIFY
optimize/convex/lp/simplex_test.go
optimize/convex/lp/simplex_test.go
@@ -16,6 +16,7 @@ import (
const convergenceTol = 1e-10
func TestSimplex(t *testing.T) {
+ t.Parallel()
// First test specific inputs. These were collected from failures
// during randomized testing.
// TODO(btracey): Test specific problems with known solutions.

MODIFY
optimize/functions/functions_test.go
optimize/functions/functions_test.go
@@ -7,6 +7,7 @@ package functions
import "testing"
func TestBeale(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 1},
@@ -23,6 +24,7 @@ func TestBeale(t *testing.T) {
}
func TestBiggsEXP2(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2},
@@ -34,6 +36,7 @@ func TestBiggsEXP2(t *testing.T) {
}
func TestBiggsEXP3(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2, 1},
@@ -45,6 +48,7 @@ func TestBiggsEXP3(t *testing.T) {
}
func TestBiggsEXP4(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2, 1, 1},
@@ -57,6 +61,7 @@ func TestBiggsEXP4(t *testing.T) {
}
func TestBiggsEXP5(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2, 1, 1, 1},
@@ -69,6 +74,7 @@ func TestBiggsEXP5(t *testing.T) {
}
func TestBiggsEXP6(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2, 1, 1, 1, 1},
@@ -82,6 +88,7 @@ func TestBiggsEXP6(t *testing.T) {
}
func TestBox3D(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0, 10, 20},
@@ -93,6 +100,7 @@ func TestBox3D(t *testing.T) {
}
func TestBrownBadlyScaled(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 1},
@@ -119,6 +127,7 @@ func TestBrownBadlyScaled(t *testing.T) {
// }
func TestExtendedPowellSingular(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{3, -1, 0, 3},
@@ -135,6 +144,7 @@ func TestExtendedPowellSingular(t *testing.T) {
}
func TestExtendedRosenbrock(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{-1.2, 1},
@@ -156,6 +166,7 @@ func TestExtendedRosenbrock(t *testing.T) {
}
func TestGaussian(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0.4, 1, 0},
@@ -167,6 +178,7 @@ func TestGaussian(t *testing.T) {
}
func TestGulfResearchAndDevelopment(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{5, 2.5, 0.15},
@@ -178,6 +190,7 @@ func TestGulfResearchAndDevelopment(t *testing.T) {
}
func TestHelicalValley(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{-1, 0, 0},
@@ -189,6 +202,7 @@ func TestHelicalValley(t *testing.T) {
}
func TestPenaltyI(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{1, 2, 3, 4},
@@ -206,6 +220,7 @@ func TestPenaltyI(t *testing.T) {
}
func TestPenaltyII(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0.5, 0.5, 0.5, 0.5},
@@ -226,6 +241,7 @@ func TestPenaltyII(t *testing.T) {
}
func TestPowelBadlyScaled(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0, 1},
@@ -237,6 +253,7 @@ func TestPowelBadlyScaled(t *testing.T) {
}
func TestTrigonometric(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0.5, 0.5},
@@ -262,6 +279,7 @@ func TestTrigonometric(t *testing.T) {
}
func TestVariablyDimensioned(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0.5, 0},
@@ -283,6 +301,7 @@ func TestVariablyDimensioned(t *testing.T) {
}
func TestWatson(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{0, 0},
@@ -315,6 +334,7 @@ func TestWatson(t *testing.T) {
}
func TestWood(t *testing.T) {
+ t.Parallel()
tests := []funcTest{
{
X: []float64{-3, -1, -3, -1},

MODIFY
optimize/functions/minsurf_test.go
optimize/functions/minsurf_test.go
@@ -13,6 +13,7 @@ import (
)
func TestMinimalSurface(t *testing.T) {
+ t.Parallel()
for _, size := range [][2]int{
{20, 30},
{30, 30},

MODIFY
optimize/guessandcheck_test.go
optimize/guessandcheck_test.go
@@ -13,6 +13,7 @@ import (
)
func TestGuessAndCheck(t *testing.T) {
+ t.Parallel()
dim := 30
problem := Problem{
Func: functions.ExtendedRosenbrock{}.Func,

MODIFY
optimize/linesearcher_test.go
optimize/linesearcher_test.go
@@ -14,6 +14,7 @@ import (
)
func TestMoreThuente(t *testing.T) {
+ t.Parallel()
d := 0.001
c := 0.001
ls := &MoreThuente{
@@ -24,6 +25,7 @@ func TestMoreThuente(t *testing.T) {
}
func TestBisection(t *testing.T) {
+ t.Parallel()
c := 0.1
ls := &Bisection{
CurvatureFactor: c,
@@ -32,6 +34,7 @@ func TestBisection(t *testing.T) {
}
func TestBacktracking(t *testing.T) {
+ t.Parallel()
d := 0.001
ls := &Backtracking{
DecreaseFactor: d,

MODIFY
optimize/listsearch_test.go
optimize/listsearch_test.go
@@ -15,6 +15,7 @@ import (
)
func TestListSearch(t *testing.T) {
+ t.Parallel()
rnd := rand.New(rand.NewSource(1))
for cas, test := range []struct {
r, c int

MODIFY
optimize/unconstrained_test.go
optimize/unconstrained_test.go
@@ -997,6 +997,7 @@ func newVariablyDimensioned(dim int, gradTol float64) unconstrainedTest {
}
func TestLocal(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
// Mix of functions with and without Grad method.
tests = append(tests, gradFreeTests...)
@@ -1005,6 +1006,7 @@ func TestLocal(t *testing.T) {
}
func TestNelderMead(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
// Mix of functions with and without Grad method.
tests = append(tests, gradFreeTests...)
@@ -1013,10 +1015,12 @@ func TestNelderMead(t *testing.T) {
}
func TestGradientDescent(t *testing.T) {
+ t.Parallel()
testLocal(t, gradientDescentTests, &GradientDescent{})
}
func TestGradientDescentBacktracking(t *testing.T) {
+ t.Parallel()
testLocal(t, gradientDescentTests, &GradientDescent{
Linesearcher: &Backtracking{
DecreaseFactor: 0.1,
@@ -1025,12 +1029,14 @@ func TestGradientDescentBacktracking(t *testing.T) {
}
func TestGradientDescentBisection(t *testing.T) {
+ t.Parallel()
testLocal(t, gradientDescentTests, &GradientDescent{
Linesearcher: &Bisection{},
})
}
func TestCG(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1038,6 +1044,7 @@ func TestCG(t *testing.T) {
}
func TestFletcherReevesQuadStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1048,6 +1055,7 @@ func TestFletcherReevesQuadStep(t *testing.T) {
}
func TestFletcherReevesFirstOrderStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1058,6 +1066,7 @@ func TestFletcherReevesFirstOrderStep(t *testing.T) {
}
func TestHestenesStiefelQuadStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1068,6 +1077,7 @@ func TestHestenesStiefelQuadStep(t *testing.T) {
}
func TestHestenesStiefelFirstOrderStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1078,6 +1088,7 @@ func TestHestenesStiefelFirstOrderStep(t *testing.T) {
}
func TestPolakRibiereQuadStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1088,6 +1099,7 @@ func TestPolakRibiereQuadStep(t *testing.T) {
}
func TestPolakRibiereFirstOrderStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1098,6 +1110,7 @@ func TestPolakRibiereFirstOrderStep(t *testing.T) {
}
func TestDaiYuanQuadStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1108,6 +1121,7 @@ func TestDaiYuanQuadStep(t *testing.T) {
}
func TestDaiYuanFirstOrderStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1118,6 +1132,7 @@ func TestDaiYuanFirstOrderStep(t *testing.T) {
}
func TestHagerZhangQuadStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1128,6 +1143,7 @@ func TestHagerZhangQuadStep(t *testing.T) {
}
func TestHagerZhangFirstOrderStep(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, cgTests...)
@@ -1138,6 +1154,7 @@ func TestHagerZhangFirstOrderStep(t *testing.T) {
}
func TestBFGS(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, quasiNewtonTests...)
@@ -1146,6 +1163,7 @@ func TestBFGS(t *testing.T) {
}
func TestLBFGS(t *testing.T) {
+ t.Parallel()
var tests []unconstrainedTest
tests = append(tests, gradientDescentTests...)
tests = append(tests, quasiNewtonTests...)
@@ -1154,6 +1172,7 @@ func TestLBFGS(t *testing.T) {
}
func TestNewton(t *testing.T) {
+ t.Parallel()
testLocal(t, newtonTests, &Newton{})
}
@@ -1297,6 +1316,7 @@ func testLocal(t *testing.T, tests []unconstrainedTest, method Method) {
}
func TestIssue76(t *testing.T) {
+ t.Parallel()
p := Problem{
Func: functions.BrownAndDennis{}.Func,
Grad: functions.BrownAndDennis{}.Grad,
@@ -1321,6 +1341,7 @@ func TestIssue76(t *testing.T) {
}
func TestNelderMeadOneD(t *testing.T) {
+ t.Parallel()
p := Problem{
Func: func(x []float64) float64 { return x[0] * x[0] },
}

optimize: make tests parallel