示例#1
0
func TestOverviewSwarm(t *testing.T) {
	maxeval := 50000
	maxiter := 5000
	successfrac := 1.00
	avgiter := 250.0

	for _, fn := range bench.Basic {
		sfn := func() *optim.Solver {
			return &optim.Solver{
				Method:  swarmsolver(fn, nil, -1),
				Obj:     optim.Func(fn.Eval),
				MaxEval: maxeval,
				MaxIter: maxiter,
			}
		}
		bench.Benchmark(t, fn, sfn, successfrac, avgiter)
	}
}
示例#2
0
func TestBenchSwarmRosen(t *testing.T) {
	ndim := 30
	npar := 30
	maxiter := 10000
	successfrac := 1.00
	avgiter := 500.0

	fn := bench.Rosenbrock{ndim}
	sfn := func() *optim.Solver {
		return &optim.Solver{
			Method:  swarmsolver(fn, nil, npar),
			Obj:     optim.Func(fn.Eval),
			MaxEval: maxiter * npar,
			MaxIter: maxiter,
		}
	}
	bench.Benchmark(t, fn, sfn, successfrac, avgiter)
}
示例#3
0
func TestBenchPSwarmRastrigrin(t *testing.T) {
	ndim := 30
	npar := 30
	maxiter := 10000
	successfrac := 1.00
	avgiter := 130.0

	fn := bench.Rastrigrin{ndim}
	sfn := func() *optim.Solver {
		m, mesh := pswarmsolver(fn, nil, npar)
		return &optim.Solver{
			Method:  m,
			Obj:     optim.Func(fn.Eval),
			Mesh:    mesh,
			MaxEval: maxiter * npar,
			MaxIter: maxiter,
		}
	}
	bench.Benchmark(t, fn, sfn, successfrac, avgiter)
}
示例#4
0
func TestOverviewPattern(t *testing.T) {
	maxeval := 50000
	maxiter := 5000
	successfrac := 0.50
	avgiter := 2500.0

	// ONLY test plain pattern search on convex functions
	for _, fn := range []bench.Func{bench.Rosenbrock{NDim: 2}} {
		sfn := func() *optim.Solver {
			m, mesh := patternsolver(fn, nil)
			m.Poller = &pattern.Poller{Spanner: pattern.CompassNp1{}}
			return &optim.Solver{
				Method:  m,
				Obj:     optim.Func(fn.Eval),
				Mesh:    mesh,
				MaxIter: maxiter,
				MaxEval: maxeval,
			}
		}
		bench.Benchmark(t, fn, sfn, successfrac, avgiter)
	}
}
示例#5
0
func TestBenchPSwarmRosen(t *testing.T) {
	ndim := 30
	npar := 30
	maxiter := 10000
	successfrac := 1.0
	avgiter := 300.0

	fn := bench.Rosenbrock{ndim}
	sfn := func() *optim.Solver {
		m, mesh := pswarmsolver(fn, nil, npar)
		low, _ := fn.Bounds()
		ndim := len(low)
		m.Poller = &pattern.Poller{Spanner: &pattern.RandomN{N: ndim}}
		return &optim.Solver{
			Method:  m,
			Obj:     optim.Func(fn.Eval),
			Mesh:    mesh,
			MaxEval: maxiter * npar,
			MaxIter: maxiter,
		}
	}
	bench.Benchmark(t, fn, sfn, successfrac, avgiter)
}