Skip to main content

A Python library of standardized optimization test functions

Project description

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])

Project details


Download files

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

Source Distribution

landscapes-0.0.3.tar.gz (3.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page