Skip to main content

Polyblocks

This package provides a set of solvers for monotonic optimisation problems, which take the general form:

$$ \begin{aligned} \max_{x \in \mathbb{R}^n} \quad & f(x) \ \text{s.t.} \ \quad & x_l \le x \le x_u \ & g(x) \le 0 \ & h(x) \ge 0 \end{aligned} $$

where $f$, $g$, and $h$ are non-decreasing in each coordinate. This covers a broad class of non-convex problems, including polynomial programming along with many radio resource allocation problems in communications.

Solvers are built around the Polyblock Outer-approximation (POA) algorithm: a branch-and-bound algorithm which iteratively refines a rectangular outer-approximation of the solution space. Full details are available in the accompanying paper: LINK

Installation

pip install polyblocks

or, for local development:

git clone https://github.com/RashwanA/polyblocks.git
cd polyblocks
pip install .

Solvers

The package includes three built-in solvers: BasePOA, BalancedPOA, and TreePOA. Of these TreePOA typically has the best empirical performance as it uses an efficient tree-based representation of the solution space. All solvers implement the common ABPolyblock interface, which exposes a set of subroutines used by the POA algorithm. Users may also define custom solvers by implementing this interface.

Usage

Each solver is called via its solve classmethod, which takes the objective, the bounding box, and oracles for querying feasibility.

Ball optimisation example:

from polyblocks import TreePOA

# maximise 3x + 4y
# subject to x^2 + y^2 <= 1

def obj(x):
    return x @ [3, 4]

def ub_oracle(x):
    return (x ** 2).sum(-1) <= 1

sol = TreePOA.solve(
    obj=obj,
    ub_oracle=ub_oracle,
    x_l=(0., 0.),
    x_u=(1., 1.),
)

print(f"status={sol.status}, obj={sol.obj:.2f}, x={sol.x.round(2)}")

Geometric programming example:

from polyblocks import TreePOA

# maximise x y z
# subject to x (y + z) <= 4,
#            y z <= 4,
#            x, y, z ∈ [0, 4]

def obj(x):
    return x.prod(1)

def ub_oracle(x):
    cons1 = x[:,0] * (x[:,1:].sum(1)) <= 4.
    cons2 = x[:,1:].prod(1) <= 4.
    return cons1 * cons2

sol = TreePOA.solve(
    obj=obj,
    ub_oracle=ub_oracle,
    x_l=(0., 0., 0.),
    x_u=4.,             # bounds are broadcast
    verbose_gap=10,     # print progress every 10 iterations
)
print(f"status={sol.status}, obj={sol.obj:.2f}, x={sol.x.round(2)}")

Objectives and oracles are expected to accept batched inputs of shape (num_points, dim).

Metadata

Release files for polyblocks 0.1.0

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

Source distribution (sdist)

Source distribution for polyblocks 0.1.0
File Size Uploaded
polyblocks-0.1.0.tar.gz 15.1 kB Details

Built distribution (wheel)

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

Total release size: 33.3 kB

Release files / polyblocks-0.1.0.tar.gz

Download URL polyblocks-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cf6d1e96752820a35518d9b4bb292c351d324b8054c772cbc6177eaf97acc345
BLAKE2b-256 checksum
How to use checksums
7f8a839244d8346d50d8f2f63a28dd68fb49d06bb2b8ad82bca35d448a8e3dd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / polyblocks-0.1.0-py3-none-any.whl

Download URL polyblocks-0.1.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d714a7137f1c00aa40eb641d78fb51ebedfe7b949c35459fdcce9b9483a67ad0
BLAKE2b-256 checksum
How to use checksums
d404fc03c57a58e7ea7f5c1a5294e3c2302d9408336f0c815afa4ee4222d102d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

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