Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chvillap committed Nov 13, 2017
0 parents commit 4225492
Show file tree
Hide file tree
Showing 19 changed files with 3,387 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.pyc

.installed.cfg
bin
develop-eggs

*.egg-info

tmp
build
dist
11 changes: 11 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax: glob

.installed.cfg
bin
develop-eggs

*.egg-info

tmp
build
dist
19 changes: 19 additions & 0 deletions HACKING.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Development setup
=================

To create a buildout,

$ python bootstrap.py
$ bin/buildout

Release HOWTO
=============

To make a release,

1) Update release date/version in NEWS.txt and setup.py
2) Run 'python setup.py sdist'
3) Test the generated source distribution in dist/
4) Upload to PyPI: 'python setup.py sdist register upload'
5) Increase version in setup.py (for next release)

674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
include NEWS.txt
9 changes: 9 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
News
====

0.1
---

*Release date: 05-Out-2017*

* Alpha 0.1 released.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PSIFA

**PSIFA** (**P**attern **S**earch and **I**mplicit **F**iltering **A**lgorithm) is a derivative-free optimization algorithm developed by Ferreira, Ehrhardt and Santos (2017) that has been designed for linearly constrained problems with noise in the objective function. It combines some elements of the pattern search approach of Lewis and Torczon (2000) with ideas from the implicit filtering method of Kelley (2011).

<!-- ## Installation
Binary installers for the latest released version will be available at the Python Package Index.
`pip install psifa` -->

## Requirements

- numpy (>= 1.13)
- scipy (>= 0.19)

## Example of use

```python
from psifa.api import psifa
import numpy as np
import pprint

# Objective function.
def f(x):
y = (1. / (27. * np.sqrt(3.))) * ((x[0] - 3.)**2 - 9.) * x[1]**3
eval_success = True
return y, eval_success

# Problem constraints.
A = np.array([
[1. / np.sqrt(3.), -1.],
[1., np.sqrt(3.)],
[-1., -np.sqrt(3.)]
])
l = np.array([0., 0., -6.])
u = np.array([np.inf, np.inf, np.inf])
bl = np.array([0., 0.])
bu = np.array([np.inf, np.inf])
n = 2

# Initial guess for the solution.
x0 = np.array([1., 0.5])

# Find a global optimum using PSIFA.
x, y, iterations, alpha, evaluations, history, exit_cause = \
psifa(f, x0, A, l, u, n, bl, bu)

# Show the results.
print('Solution: x = {}'.format(x))
print('Function value: f(x) = {}'.format(y))
print('Step length: alpha = {}'.format(alpha))
print('Number of iterations: {}'.format(iterations))
print('Function evaluations: {}'.format(evaluations))
print('Exit cause: {}'.format(exit_cause))
print('History:')
pprint.PrettyPrinter(indent=2).pprint(history)
```

## License

[GNU GPLv3](LICENSE)
113 changes: 113 additions & 0 deletions bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
$Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $
"""

import os, shutil, sys, tempfile, urllib2
from optparse import OptionParser

tmpeggs = tempfile.mkdtemp()

is_jython = sys.platform.startswith('java')

# parsing arguments
parser = OptionParser()
parser.add_option("-v", "--version", dest="version",
help="use a specific zc.buildout version")
parser.add_option("-d", "--distribute",
action="store_true", dest="distribute", default=True,
help="Use Disribute rather than Setuptools.")

options, args = parser.parse_args()

if options.version is not None:
VERSION = '==%s' % options.version
else:
VERSION = ''

USE_DISTRIBUTE = options.distribute
args = args + ['bootstrap']

to_reload = False
try:
import pkg_resources
if not hasattr(pkg_resources, '_distribute'):
to_reload = True
raise ImportError
except ImportError:
ez = {}
if USE_DISTRIBUTE:
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
else:
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

if to_reload:
reload(pkg_resources)
else:
import pkg_resources

if sys.platform == 'win32':
def quote(c):
if ' ' in c:
return '"%s"' % c # work around spawn lamosity on windows
else:
return c
else:
def quote (c):
return c

cmd = 'from setuptools.command.easy_install import main; main()'
ws = pkg_resources.working_set

if USE_DISTRIBUTE:
requirement = 'distribute'
else:
requirement = 'setuptools'

if is_jython:
import subprocess

assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
quote(tmpeggs), 'zc.buildout' + VERSION],
env=dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse(requirement)).location
),
).wait() == 0

else:
assert os.spawnle(
os.P_WAIT, sys.executable, quote (sys.executable),
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse(requirement)).location
),
) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
13 changes: 13 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[buildout]
parts = python scripts
develop = .
eggs = PSIFA

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[scripts]
recipe = zc.recipe.egg:scripts
eggs = ${buildout:eggs}
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from setuptools import setup, find_packages
import sys, os

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.md')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()


version = '0.1'

install_requires = [
# List your project dependencies here.
# For more details, see:
# http://packages.python.org/distribute/setuptools.html#declaring-dependencies
'numpy',
'scipy',
]


setup(name='PSIFA',
version=version,
description="Python implementation of the Pattern Search Implicit Filtering Algorithm (PSIFA)",
long_description=README + '\n\n' + NEWS,
classifiers=[
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering :: Mathematics',
],
keywords='derivative-free-optimization linearly-constrained-minimization noisy-optimization global-convergence degenerate-constraints',
author='Carlos H. Villa Pinto',
author_email='[email protected]',
url='https://github.com/chvillap',
license='GNU GPLv3',
packages=find_packages('src'),
package_dir = {'': 'src'},
include_package_data=True,
zip_safe=False,
install_requires=install_requires,
entry_points={
'console_scripts':
['PSIFA=psifa:main']
}
)
Binary file added setuptools-33.1.1.zip
Binary file not shown.
7 changes: 7 additions & 0 deletions src/psifa/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__doc__ = """
PSIFA (Pattern Search and Implicit Filtering Algorithm) is a derivative-free
optimization algorithm that has been designed for linearly constrained problems
with noise in the objective function. It combines some elements of the pattern
search approach of Lewis and Torczon (2000) with ideas from the implicit
filtering method of Kelley (2011).
"""
Loading

0 comments on commit 4225492

Please sign in to comment.