Example Usage
The following code presents a simple use of GOFit to globally minimize, using the Multistart Algorithm, the Levy and Gomez test function in 2D.
from gofit import multistart
import numpy as np
# Levy and Gomez test function
def eval_res(x):
res = np.zeros(3)
y = 1 + (x - 1)/4
res[0] = np.sin(np.pi*y[0])
res[1] = (y[0]-1)*np.sqrt(1+10*np.sin(np.pi*y[1])**2)
res[2] = y[1]-1
return res
# Problem data
m = 3
n = 2
xl = -10*np.ones(n)
xu = 10*np.ones(n)
# Parameters
samples = 10
maxit = 100
# Run GOFit multistart algorithm
x, status = multistart(m, n, xl, xu, eval_res, samples=samples, maxit=maxit)
print("status:")
print(status)
print("x*:")
print(x)
For this problem, GOFit’s Multistart Algorithm finds the global minimum at x=[1,1] quickly:
status:
0
x*:
[1. 1.00000231]
More usage examples can be found in the tests sub-directory. See GOFit Algorithms for details of the available algorithms.