spinopt

Scipy Interface to NLOPT

https://github.com/mvds314/spinopt

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.3%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Scipy Interface to NLOPT

Basic Info
  • Host: GitHub
  • Owner: mvds314
  • License: bsd-2-clause
  • Language: Python
  • Default Branch: main
  • Size: 21.5 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Created almost 2 years ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

README.md

SpiNopt: a Scipy optimization interface to NLOPT

For optimization, everyone starts out with the Scipy optimization library, but, at some point, you might want to try something else. NLOPT is a great library, but can be quite a hassle rewrite your code to use it.

This package provides a Scipy interface to the NLOPT optimization library. It's aim is not to provide a complete ecosystem which different solvers are available, but merely a way to quickly connect the NLOPT solvers, once you already have something set up with Scipy, or are familiar with how to set something up with Scipy.

Basic example

```python import numpy as np from spinopt import NLOptimizer

dim = 3

Define objective in this way

def myeasyfunc(x, grad): if grad.size > 0: grad[:] = 2 * (x - np.arange(len(x))) x = x - np.arange(len(x)) return x.dot(x)

Define constraints Scipy style

A = np.ones((1, dim)) b = np.ones((1, 1)) constraints = [{"type": "eq", "jac": lambda w: A, "fun": lambda w: A.dot(w) - b.squeeze()}]

Initialize optimizer

x0=np.zeros(dim) opt = NLOptimizer(myeasyfunc, x0, constraints=constraints)

Optimize

res = opt.minimize() assert res.success assert np.allclose(res.x, np.arange(dim), atol=1e-5) ```

Installation

To install from PyPI:

bash pip install spinopt

To install the latest development version from github:

bash pip install git+https://github.com/mvds314/spinopt.git

Development

For development purposes, clone the repo:

bash git clone https://github.com/mvds314/spinopt.git

Then navigate to the folder containing setup.py and run

bash pip install -e .

to install the package in edit mode.

Run unittests with pytest.

Related software

Owner

  • Login: mvds314
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0 
message: "If you use this software, please cite it as below."
authors:
- family-names: "van der Schans"
  given-names: "Martin"
title: "SpiNopt: A Scipy interface to NLOPT"
version: 24.7.2
date-released: 2024-05-16
url: "https://github.com/mvds314/spinopt"

GitHub Events

Total
  • Release event: 2
  • Push event: 4
  • Create event: 2
Last Year
  • Release event: 2
  • Push event: 4
  • Create event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 52 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: spinopt

Scipy interface to NLOPT

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 52 Last month
Rankings
Dependent packages count: 10.9%
Forks count: 32.8%
Average: 36.9%
Stargazers count: 42.4%
Dependent repos count: 61.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/python-app.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
setup.py pypi
  • nlopt *