项目作者: cshenton

项目描述 :
Thread-safe blackbox optimsers for Go
高级语言: Go
项目地址: git://github.com/cshenton/opt.git
创建时间: 2018-03-26T23:51:17Z
项目社区:https://github.com/cshenton/opt

开源协议:MIT License

下载


Opt: Scalable Optimisation for Humans

Build Status
Coverage
Go Report Card

opt is an optimisation library designed to make writing scalable optimisation
routines easy. It provides a unified API for optimising within a single thread,
multiple threads, or across machines, meaning the choice of how to distribute work
is up to you.

Just go get github.com/cshenton/opt to install.

Basic Usage

Opt uses natural evolution strategies
optimisers under the hood, which enables a simple API. First, Search() against an optimiser
to get a test point, then evaluate its score how you see fit, then Show() that score with
the test seed to the optimiser. Keep going until you converge.

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/cshenton/opt"
  5. "github.com/cshenton/opt/bench"
  6. )
  7. func main() {
  8. n := 10000
  9. op := opt.DefaultOptions
  10. op.LearningRate = 0.5
  11. o := opt.NewSNES(10, op)
  12. for i := 0; i < n; i++ {
  13. point, seed := o.Search()
  14. // Minimise the 10-dimensional sphere function
  15. score := -bench.Sphere(point)
  16. o.Show(score, seed)
  17. }
  18. final, _ := o.Search()
  19. fmt.Println(final)
  20. }

Want to use more workers on the same machine to speed up evaluations? Just do it,
opt optimisers are thread safe, and will simply block calls to Search and Show
when important computations are happening.

See examples for some suggestions on how to use opt.

Choice of Optimizers

Right now, opt deals with optimisers that work with real-valued inputs.

Available

  • SNES (separable natural evolution strategies), great for high (>100) dimensional problems.

Coming Soon

  • xNES (exponential natural evolution strategies), great for tricky low (<100) dimensional problems.
  • Adaptive learning rates for XNES, SNES, great for unfamiliar problems.
  • Hyperprojection SNES
  • Block-free SNES

ToDo

  • Simpler options handling
  • xNES
  • More expensive benchmark function to demonstrate multithread perf.
  • worker queue example
  • rpc example
  • benchmark runner.
  • some introspection / stopping functions for SNES
  • Travis, coveralls

Dependencies

  • golang.org/x/exp/rand Rob Pike’s experimental rand library.
    • <1ns to create a random source vs. 8.5µs in std lib.
    • This probably matters more for smaller optimisation problems.