Skip to main content

Python interface to POUNCE — a pure-Rust port of the Ipopt interior-point NLP solver. cyipopt-style Problem class, scipy-style minimize() facade, and JAX-friendly autodiff / implicit differentiation.

Project description

pounce — Python interface

pounce is a Python wrapper around POUNCE, a pure-Rust port of the Ipopt interior-point nonlinear programming solver. The Python surface area is intentionally cyipopt-compatible: code written for cyipopt typically runs against pounce by changing only the import.

Install (development)

# from the repo root:
cd python
pip install maturin
maturin develop --release            # builds the native extension into your venv
# optional extras:
pip install -e .[jax]                # jax integration
pip install -e .[dev]                # tests + jax + scipy

Quick start (cyipopt-style)

import numpy as np
import pounce

class HS071:
    def objective(self, x):
        return x[0]*x[3]*(x[0]+x[1]+x[2]) + x[2]
    def gradient(self, x):
        return np.array([
            x[0]*x[3] + x[3]*(x[0]+x[1]+x[2]),
            x[0]*x[3],
            x[0]*x[3] + 1.0,
            x[0]*(x[0]+x[1]+x[2]),
        ])
    def constraints(self, x):
        return np.array([np.prod(x), np.dot(x, x)])
    def jacobianstructure(self):
        return (np.repeat([0,1], 4), np.tile([0,1,2,3], 2))
    def jacobian(self, x):
        return np.array([
            x[1]*x[2]*x[3], x[0]*x[2]*x[3], x[0]*x[1]*x[3], x[0]*x[1]*x[2],
            2*x[0], 2*x[1], 2*x[2], 2*x[3],
        ])

prob = pounce.Problem(
    n=4, m=2,
    problem_obj=HS071(),
    lb=[1]*4, ub=[5]*4,
    cl=[25, 40], cu=[2e19, 40],
)
prob.add_option('tol', 1e-8)
x, info = prob.solve(x0=np.array([1.0, 5.0, 5.0, 1.0]))
print(info['status_msg'], info['obj_val'], x)

scipy.optimize-style

from pounce import minimize
res = minimize(lambda x: (x-1)**2 @ (x-1) + 1, x0=np.zeros(5))
print(res.fun, res.x)

JAX integration

import jax, jax.numpy as jnp
from pounce.jax import from_jax

def f(x): return jnp.sum((x-1)**2)
def g(x): return jnp.stack([jnp.sum(x) - 5.0])

prob = from_jax(f, g, n=4, m=1, lb=jnp.zeros(4), ub=jnp.full(4, 10.0),
                cl=jnp.zeros(1), cu=jnp.zeros(1))
x, info = prob.solve(x0=jnp.ones(4))

Differentiate through the solver:

from pounce.jax import solve as psolve

def loss(p):
    x_star = psolve(p, f=..., g=..., n=4, m=1, ...)
    return jnp.sum(x_star ** 2)

dloss_dp = jax.grad(loss)(jnp.ones(4))

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

pounce_solver-0.2.0.tar.gz (536.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pounce_solver-0.2.0-cp39-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.9+Windows x86-64

pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

pounce_solver-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pounce_solver-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file pounce_solver-0.2.0.tar.gz.

File metadata

  • Download URL: pounce_solver-0.2.0.tar.gz
  • Upload date:
  • Size: 536.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pounce_solver-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ffa70083f8fd837335fb3e8b292adbfc5f743f74374c17c1cd5ee3dec16aa75d
MD5 4ddb46dbb745b8ed3c9b9a0c1bee6acc
BLAKE2b-256 a733aeb07cc1260dbca5f458384f263644caa4a122417b5ddbfd9849eef049fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0.tar.gz:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pounce_solver-0.2.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pounce_solver-0.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dcaf557623a1f66bf3b8f64a016d61e48bd3267c4cd65736e063706a99498f10
MD5 d64948e93c1cf5ba8b4d3ff23f6fadb0
BLAKE2b-256 308d8f6634b2038aaa71aef7e2710ca639f106ce1df1f152c392d15a3a712a9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0-cp39-abi3-win_amd64.whl:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8495b4430a6f94b35f8fbc0a11494837702a2adecff7e9052412be0ada7e044e
MD5 0347cdd533cd3d00636e370fcf559344
BLAKE2b-256 c9e644e57d63aa7631f63780064527480810363dbff5c14af974e4e537eba9bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fcc71bff131d22cc419033ce0267f182795b94c4ad37aab9251e90a4510a5ca7
MD5 c627a074ddbe68db3f0cea7281367ac7
BLAKE2b-256 18378300d276a1822b00c0529026a08e2e2e3d2ddccd0bc29edd47fcc56d5d9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pounce_solver-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pounce_solver-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4a7360d38e62a9a4408a2e9fa1ab21dc3abd042cc4a71571acc3e5472187603
MD5 7d58bf0ce1dc55750d3b345dc277150d
BLAKE2b-256 1f0a748fcf194b884417aa87fa93de1f5415dce270a462948d5b388d8abcf916

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pounce_solver-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pounce_solver-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ae6cf661249051db4ff9477ec5f5caf0058703bd9df9aace135b2f98375dd510
MD5 dd0689eacdb918cb3b1c0c6bda2087ab
BLAKE2b-256 120050c49b24a46aa58eeff9bb03ad8fe2558cf63d57f3319116fdcc1dd83cdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pounce_solver-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-pounce.yml on jkitchin/pounce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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