Skip to main content
Files added late

4 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.

Thin wrapper for QPBO

Thin Python wrapper for a modified version of the quadratic pseudo-Boolean optimization (QPBO) algorithm by Vladimir Kolmogorov. The original source code by Vladimir Kolmogorov availbable at http://pub.ist.ac.at/~vnk/software.html. This wrapper uses a modified version with support for larger graphs and slightly lower memory usage. See submodule repository for more details.

QPBO vs. Maxflow

While the QPBO algorithm performs a s-t graph cut similar to Maxflow, it allows for non-submodular energy terms, which Maxflow doesn't. Amongst other things, this allows QPBO to solve optimization problems with exclusions terms, which can be very usefull. The graph constructed by the QPBO implementation is twice the size of a Maxflow graph for an equivalent problem. Thus, QPBO uses more memory and is slightly slower than Maxflow.

Installation

Install package using pip install thinqpbo or clone this repository (including submodule). Building the package requires Cython.

Graph types

Currently, there are three different types of graphs: QPBOInt, QPBOFloat and QPBODouble. The only difference is the underlying datatypes used for the edge capacities in the graph. For stability, it is recommended to use QPBOInt for integer capacities and QPBODouble for floating point capacities. However, in some cases, it maybe be favourable to use QPBOFloat to reduce memory consumption.

Advanced features (QPBO-P and QPBO-I)

The QPBO implementation has a few advanced extensions known as QPBO-P and QPBO-I. Currently, not all advanced functions have been wrapped. If you need to use features of the QPBO C++ library that are not wrapped by thinqpbo, please let me know by creating an issue on GitHub.

Tiny example

import thinqpbo as tq

# Create graph object.
graph = tq.QPBOInt()

# Number of nodes to add.
nodes_to_add = 2

# Add two nodes.
first_node_id = graph.add_node(nodes_to_add)

# Add edges.
graph.add_unary_term(0, 0, 5) # E1(0) = 5, s     --5->   n(0)
graph.add_unary_term(0, 1, 0) # E0(0) = 1, n(0)  --1->   t
graph.add_unary_term(1, 5, 0) # E0(1) = 5, n(1)  --5->   t
graph.add_pairwise_term(0, 1, 0, 7, 0, 4)   # E01(0,1) = 7, n(0)  --7->   n(1)
                                            # E11(0,1) = 4, Not possible with standard Maxflow


# Find maxflow/cut graph.
graph.solve()
graph.compute_weak_persistencies()
twice_energy = graph.compute_twice_energy()

for n in range(nodes_to_add):
    segment = graph.get_label(n)
    print('Node %d has label %d.' % (n, segment))
# Node 0 has label 0.
# Node 1 has label 0.

print('Twice energy/flow: %s' % twice_energy)
# Twice energy/flow: 12

License

As the QPBO implementation is distributed under the GPLv3 license, so is this package.

Release files for thinqpbo 0.1.4

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

Files added late

4 files were uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for thinqpbo 0.1.4
File Size Uploaded
thinqpbo-0.1.4.tar.gz 112.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for thinqpbo 0.1.4
File
thinqpbo-0.1.4-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
thinqpbo-0.1.4-cp39-cp39-macosx_10_14_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.14+ x86-64 Details
thinqpbo-0.1.4-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
thinqpbo-0.1.4-cp38-cp38-macosx_10_14_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.14+ x86-64 Details
thinqpbo-0.1.4-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
thinqpbo-0.1.4-cp37-cp37m-macosx_10_14_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 Details
thinqpbo-0.1.4-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
thinqpbo-0.1.4-cp36-cp36m-macosx_10_14_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64 Details
thinqpbo-0.1.4-cp27-cp27m-macosx_10_14_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.14+ x86-64 Details

Total release size: 918.2 kB

Release files / thinqpbo-0.1.4.tar.gz

Download URL thinqpbo-0.1.4.tar.gz
Size 112.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc0475bb93fa37e0af64efbd3a8c487941b5aa671e668028d144e28453887846
BLAKE2b-256 checksum
How to use checksums
e982f80001cb54d3d6d7203943565a766c2e85b67b75084c458d8568b555c92d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / thinqpbo-0.1.4-cp39-cp39-win_amd64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL thinqpbo-0.1.4-cp39-cp39-win_amd64.whl
Size 75.4 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
a41b30458f98e84c7c451a3564abddf6bed655f3bb0751ace89f56bd7996f664
BLAKE2b-256 checksum
How to use checksums
c4870c28ace1026fd099b6267299ab5c940f18be30763d52cdc03fbafc37101d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / thinqpbo-0.1.4-cp39-cp39-macosx_10_14_x86_64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL thinqpbo-0.1.4-cp39-cp39-macosx_10_14_x86_64.whl
Size 100.1 kB
Tags CPython 3.9 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
85590bbdd4dfbe5d09008278a0aa9423639576c81e84fb074b50e6eff6bbcb8f
BLAKE2b-256 checksum
How to use checksums
c2931b456df8218e9e014e321927d38b1f43fb5d594937ff219e7a03443c8e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / thinqpbo-0.1.4-cp38-cp38-win_amd64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL thinqpbo-0.1.4-cp38-cp38-win_amd64.whl
Size 75.4 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
16c28700cfbed7211555886e8fac4a3b56774361312fcb4b7df4898d023ad0f0
BLAKE2b-256 checksum
How to use checksums
0ee13816237ed1a7468b8f1204e11c5eff9b12de8146c1a053c028fccd1bd76c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / thinqpbo-0.1.4-cp38-cp38-macosx_10_14_x86_64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL thinqpbo-0.1.4-cp38-cp38-macosx_10_14_x86_64.whl
Size 99.9 kB
Tags CPython 3.8 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
19ec9e7e1378037445846c7c97de92c319b691ae2695fda45f821d7ed97016cf
BLAKE2b-256 checksum
How to use checksums
15f4c851497da906f53d85c10e9be192fecb2001896cd7d1ea937df46d0c3dad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / thinqpbo-0.1.4-cp37-cp37m-win_amd64.whl

Download URL thinqpbo-0.1.4-cp37-cp37m-win_amd64.whl
Size 74.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8e7a9b217022e934a26260acd85a23e351911fbe2bfd823b78e030dcb5776fe3
BLAKE2b-256 checksum
How to use checksums
ab99965714525cbbfb1b64fe327fb30d11557220cfc58170315770d8693c6bfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / thinqpbo-0.1.4-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL thinqpbo-0.1.4-cp37-cp37m-macosx_10_14_x86_64.whl
Size 102.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
c415922b4c3eddd6ce2422cf8538057428dc0cf0fc3e1d20fa201e8a4078f84e
BLAKE2b-256 checksum
How to use checksums
a0a0b63183c603c7ded17efc345dd8fad6aa3dc23b89b6cd09ddd481707e65d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / thinqpbo-0.1.4-cp36-cp36m-win_amd64.whl

Download URL thinqpbo-0.1.4-cp36-cp36m-win_amd64.whl
Size 75.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
700c82f78b5a1b88fec2e226e1c19529ef95224fec060b86a2af5a38d72c9142
BLAKE2b-256 checksum
How to use checksums
0eff88430eab91ef38e20934f38fb21126698bf34b7718f1b639eca77253ffc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / thinqpbo-0.1.4-cp36-cp36m-macosx_10_14_x86_64.whl

Download URL thinqpbo-0.1.4-cp36-cp36m-macosx_10_14_x86_64.whl
Size 102.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
64f679fa873fa05bb9e9f81bc15376be8baedf49df32de7846afb6cf11753c8f
BLAKE2b-256 checksum
How to use checksums
07750d181bcefe03b70fea3cd42d0247c4032bfc2f3f636535ed86dfdc5090a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / thinqpbo-0.1.4-cp27-cp27m-macosx_10_14_x86_64.whl

Download URL thinqpbo-0.1.4-cp27-cp27m-macosx_10_14_x86_64.whl
Size 99.1 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
41f3ba1cc4b27a95fdd8a60f56ad874f112d4e124c44e82114b0b34dd95c43fd
BLAKE2b-256 checksum
How to use checksums
b475c5d18931f6633f3b633912764e4ccabbbc3a90ed491afb00011c689f87bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.1.4 This release

10 release files

0.1.3

6 release files

0.1.2

9 release files

0.1.1

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