예제 #1
0
func patternsolver(fn bench.Func, db *sql.DB) (*pattern.Method, optim.Mesh) {
	low, up := fn.Bounds()
	max, min := up[0], low[0]
	mesh := &optim.InfMesh{StepSize: (max - min) / 10}
	p := initialpoint(fn)
	mesh.SetOrigin(p.Pos)
	return pattern.New(p, pattern.DB(db)), mesh
}
예제 #2
0
func swarmsolver(fn bench.Func, db *sql.DB) (optim.Method, optim.Mesh) {
	low, up := fn.Bounds()
	n := 20 + 1*len(low)
	return New(
		NewPopulationRand(n, low, up),
		VmaxBounds(fn.Bounds()),
		DB(db),
	), &optim.BoxMesh{&optim.InfMesh{}, low, up}
}
예제 #3
0
func initialpoint(fn bench.Func) *optim.Point {
	low, up := fn.Bounds()
	max, min := up[0], low[0]
	pos := make([]float64, len(low))
	for i := range low {
		pos[i] = rand.Float64()*(max-min) + min
	}
	return &optim.Point{pos, math.Inf(1)}
}
예제 #4
0
func patternsolver(fn bench.Func, db *sql.DB) (optim.Method, optim.Mesh) {
	low, up := fn.Bounds()
	max, min := up[0], low[0]
	pos := make([]float64, len(low))
	for i := range pos {
		pos[i] = low[i] + (up[i]-low[i])/3
	}
	m := &optim.BoxMesh{&optim.InfMesh{StepSize: (max - min) / 10}, low, up}
	m.SetOrigin(pos)
	p := &optim.Point{pos, math.Inf(1)}
	return New(p, DB(db)), m
}
예제 #5
0
func swarmsolver(fn bench.Func, db *sql.DB, n int) optim.Method {
	low, up := fn.Bounds()

	if n < 0 {
		n = 30 + 1*len(low)
		if n > maxeval/500 {
			n = maxeval / 500
		}
	}

	return swarm.New(
		swarm.NewPopulationRand(n, low, up),
		swarm.VmaxBounds(fn.Bounds()),
		swarm.DB(db),
	)
}