Skip to main content

Travis CI: image0

Python 3 implementation of “neighborhood algorithm” direct-search optimization and Bayesian ensemble appraisal. In short, a nearest-neighbor interpolant based on Voronoi polygons is used to interpolate the misfit (search) and posterior probability (appraisal) to allow efficient sampling and integration for high-dimensional problems. Details on theory and implementation are supplied in the references.

https://raw.githubusercontent.com/keithfma/neighborhood/master/example_rosenbrock_4d.png

Example search population for 4D Rosenbrock objective function. Image include 10,000 samples collected in 1,000 iterations of the neighborhood algorithm direct search, with num_samp=10 and num_resamp=5. The true minimum is 0 at (1, 1, 1, 1), while the best sample is 0.0113 at ((0.976, 0.953, 0.908, 0.824). This result continues to converge for larger sample size (but the plot is less interesting since the density converges to a point!)

To generate the example figure above, you can run the internal demo, like so:

import neighborhood as nbr

nbr.demo_search(ndim=4, nsamp=10, nresamp=5, niter=500)

Equivalently, you can do the following:

import neighborhood as nbr

num_dim = 4
srch = nbr.Searcher(
    objective=nbr.rosenbrock,
    limits=[(-1.5, 1.5) for _ in range(num_dim)],
    num_samp=10,
    num_resamp=5,
    maximize=False,
    verbose=True
    )
srch.update(500)
srch.plot()

Status

Optimization is implemented, ensemble appraisal is in progress.

Testing

This project uses pytest for unit testing. The aim is not to be exhuastive, but to provide reasonable assurances that everything works as advertised. To run, simply call pytest --verbose from somewhere in this package.

Release

Release versions are tagged in the repository, built as distributions, and uploaded to PyPI. The minimal commands to do this are:

# update PyPI-readable README
pandoc --from=markdown --to=rst --output=README.rst README.md
# build with setuptools
python3 setup.py sdist bdist_wheel
# upload to PyPI test server (then check it out)
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# upload to PyPI
twine upload dist/*
# tag release in git repo
git tag -a X.X.X -m "vX.X.X"
git push origin --tags

References

  1. Sambridge, M. (1999). Geophysical inversion with a neighbourhood algorithm - I. Searching a parameter space. Geophysical Journal International, 138(2), 479–494. http://doi.org/10.1046/j.1365-246X.1999.00876.x

  2. Sambridge, M. (1999). Geophysical inversion with a neighborhood algorithm -

  1. Appraising the ensemble. Geophys, J. Int., 138, 727–746. http://doi.org/10.1046/j.1365-246x.1999.00900.x

Metadata

Release files for neighborhood 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neighborhood 0.1.1
File Size Uploaded
neighborhood-0.1.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neighborhood 0.1.1
File Interpreter ABI Platform
neighborhood-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / neighborhood-0.1.1.tar.gz

Download URL neighborhood-0.1.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0355ec5e0fe292814caeee3fbdff51bbe18d34f79ae490cd0574bff290b871d3
BLAKE2b-256 checksum
How to use checksums
7f5fa211bd7d7801e3fbe7576b79baa80afa3806cdf49dbf4735a41396913f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / neighborhood-0.1.1-py3-none-any.whl

Download URL neighborhood-0.1.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb4fea44253f0521f2953231e3122fb1358141d1064704093df72d52a82b9a35
BLAKE2b-256 checksum
How to use checksums
876ad6fb49e1da702779d58940df16834c54bdae1b4f62f0f0b7410d0c54033f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page