Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Python library of standardized optimization test functions

Project description

Build Status GitHub license PyPI pyversions PyPI version fury.io Downloads

Installation

There are a couple ways in which you can use this library. The first and probably the easiest is by using pip and PyPi:

pip install landscapes

You can also install directly from this git repo:

pip install git+https://github.com/nathanrooy/landscapes

Lastly, you can always clone/download this repo and use as is.

wget https://github.com/nathanrooy/landscapes/archive/master.zip
unzip master.zip
cd landscapes-master

Usage

As a simple example, let's use the Nelder-Mead method via SciPy to minimize the sphere function. We'll start off by importing the sphere function from Landscapes and the minimize method from SciPy.

>>> from landscapes.single_objective import sphere
>>> from scipy.optimize import minimize

Next, we'll call the minimize method using a starting location of [5,5].

>>> minimize(sphere, x0=[5,5], method='Nelder-Mead')

The output of which should look close to this:

 final_simplex: (array([[-3.33051318e-05, -1.93825710e-05],
       [ 4.24925225e-05,  1.37129516e-05],
       [ 3.09383247e-05, -4.04797876e-05]]), array([1.48491586e-09, 1.99365951e-09, 2.59579314e-09]))
           fun: 1.4849158640215086e-09
       message: 'Optimization terminated successfully.'
          nfev: 80
           nit: 44
        status: 0
       success: True
             x: array([-3.33051318e-05, -1.93825710e-05])

Function Reference - Single Objective

Ackley function

from landscapes.single_objective import ackley
global minimum bounds usage
f(x=0,y=0)=0 -5.12 <= x, y <= 5.12 ackley([x,y])

Beale function

from landscapes.single_objective import beale
global minimum bounds usage
f(x=3, y=0.5) = 0 -4.5 <= x, y <= 4.5 beale([x,y])

Booth function

from landscapes.single_objective import booth
global minimum bounds usage
f(x=1, y=3) = 0 -10 <= x, y <= 10 booth([x,y])

Bukin N.6 function

from landscapes.single_objective import bukin_n6
global minimum bounds usage
f(x=-10, y=1) = 0 -15 <= x <= -5
-3 <= y <= 3
bukin_n6([x,y])

Cross-in-tray function

from landscapes.single_objective import cross_in_tray
global minimum(s) bounds usage
f(x=1.34941, y=-1.34941) = -2.06261
f(x=1.34941, y=1.34941) = -2.06261
f(x=-1.34941, y=1.34941) = -2.06261
f(x=-1.34941, y=-1.34941) = -2.06261
-10 <= x, y <= 10 cross_in_tray([x,y])

Easom function

from landscapes.single_objective import easom
global minimum bounds usage
f(x=pi, y=pi) = -1 -100 <= x, y <= 100 easom([x,y])

Eggholder function

from landscapes.single_objective import eggholder
global minimum bounds usage
f(x=512, y=404.2319) = -959.6407 -512 <= x, y <= 512 eggholder([x,y])

Goldstein–Price function

from landscapes.single_objective import goldstein_price
global minimum bounds usage
f(x=0, y=-1) = 3 -2 <= x, y <= 2 goldstein_price([x,y])

Himmelblau's function

from landscapes.single_objective import himmelblau
global minimum(s) bounds usage
f(x=3.0, y=2.0) = 0.0
f(x=-2.805118, y=3.131312) = 0.0
f(x=-3.779310, y=-3.283186) = 0.0
f(x=3.584428, y=-1.848126) = 0.0
-5 <= x, y <= 5 himmelblau([x,y])

Hölder table function

from landscapes.single_objective import holder_table
global minimum(s) bounds usage
f(x=8.05502, y=9.66459) = -19.2085
f(x=-8.05502, y=9.66459) = -19.2085
f(x=8.05502, y=-9.66459) = -19.2085
f(x=-8.05502, y=-9.66459) = -19.2085
-10 <= x, y <= 10 holder_table([x,y])

Lévi function N.13

from landscapes.single_objective import levi_n13
global minimum bounds usage
f(x=1, y=1) = 0 -10 <= x, y <= 10 levi_n13([x,y])

Matyas function

from landscapes.single_objective import mccormick
global minimum bounds usage
f(x=0, y=0) = 0 -10 <= x, y <= 10 matyas([x,y])

McCormick function

from landscapes.single_objective import mccormick
global minimum bounds usage
f(x=-0.54719, y=-1.54719) = -1.9133 -1.5 <= x <= 4
-3 <= y <= 4
mccormick([x,y])

Rastrigin function

from landscapes.single_objective import rastrigin
global minimum bounds usage
f([0,...,0]) = 0 -5.12 <= x_i <= 5.12 rastrigin([x_1,...,x_n])

Rosenbrock function

from landscapes.single_objective import rosenbrock
global minimum bounds usage
f([1,...,1]) = 0 -inf <= x_i <= inf rosenbrock([x_1,...,x_n])

Schaffer function N.2

from landscapes.single_objective import schaffer_n2
global minimum bounds usage
f(x=0, y=0) = 0 -100 <= x, y <= 100 schaffer_n2([x,y])

Schaffer function N.4

from landscapes.single_objective import schaffer_n4
global minimum bounds usage
f(x=0, y=1.25313) = 0.292579
f(x=0, y=-1.25313) = 0.292579
-100 <= x, y <= 100 schaffer_n4([x,y])

Sphere function

from landscapes.single_objective import sphere
global minimum bounds usage
f([0,...,0]) = 0 -inf <= x_i <= inf sphere([x_1,...x_n])

Styblinski–Tang function

from landscapes.single_objective import styblinski_tang
global minimum bounds usage
-39.16617n < f([-2.903534,...,-2.903534]) < -39.16616n -5 <= x_i <= 5 styblinski_tang([x_1,...x_n])

Three-hump camel function

from landscapes.single_objective import three_hump_camel
global minimum bounds usage
-f(x=0, y=0) = 0 -5 <= x_i <= 5 three_hump_camel([x,y])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for landscapes, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size landscapes-0.0.6.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page