Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A package for optimizing functions
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Goptimize v 0.2.1

Quick and dirty optimization. The goal is to extend to Go similar functionality to the Optimization library in SciPy.

The package is still early in development and its implementation is subject to change.

The package exports three functions:

  • MonteCarlo
    • A Monte-Carlo optimization for functions of two inputs.
    • func MonteCarlo(f Function2, xMin float64, xMax float64, yMin float64, yMax float64) []float64
    • where Function2 is type Function func(x, y float64) float64
  • MonteCarloCons
    • A Monte-Carlo optimization for functions of two inputs, with a functional constraint
    • func MonteCarloCons(f Function2, cons Constraint2, xMin float64, xMax float64, yMin float64, yMax float64) []float64
    • where Constraint2 is type Constraint2 func(x, y float64) bool
  • GradientDescent
    • A Gradient Descent algorithm, requires the derivative of the function you are trying to optimize.
    • func GradientDescent(f Derivitive, deriv Derivitive, x []float64, sign float64) []float64
    • where Derivitive is func(x []float64, sign float64) []float64
  • Bisection
    • A Bisection Algorithm to find a specified value in the range of the function.
    • func Bisection(f Function, lBound float64, uBound float64, goal float64) float64

It relies on a few special, exported types:

  • type Derivitive func(x []float64, sign float64) []float64
  • type Function func(x float64) float64
  • type Function2 func(x, y float64) float64 //a function with two inputs
  • type Constraint2 func(x, y float64) bool

Also included are nascent unit tests.

  • go test -v to see expected and computed results for test cases.

To Install/update

Run go get to install

Run go get -u to update the package

To do

  • Improve unit tests, particularly on Gradient Descent
  • Create uniformity between methods (i.e. inputs and outputs between methods)
  • Add constraints to functions
  • Add goroutines to MonteCarlo?

Functions to add

  • Brent's Method
Something went wrong with that request. Please try again.