Skip to main content

puan-rspy

Puan's python and rust connection package.

What is it?

Puan is a collection of tools for discrete optimization modelling in various programming languages. Puan-rspy binds Puan's Rust package into a Python package. Check the link for more information about the tools inside.

Install

Using pip package manager just

pip install puan-rspy

Usage

Here we construct a problem using the propositional logic classes within puan-rspy. We construct a TheoryPy using a list of statements. Each statement has a variable and (optional) an AtLeast-proposition.

As an example, we'll create a model with only boolean variables "A","B","C","a","b","x","y". Since a StatementPy only takes an integer as id parameter, we imagine them all being 0, 1, 2, ..., 6, respectively. We want to say that if any of "a" or "b" is selected, then "x" and "y" must be selected. We do this by creating new statements connecting a new variable to these variables. First we create C = x + y -2 (which is the pr.StatementPy(2, (0,1), pr.AtLeastPy([5,6],-2, pr.SignPy.Positive))). Then we remeber from logic class that an implication statement (B -> C) is equivilant to !B or C. So for the B = "a" or "b" statement, we negate it first into not "a" and not "b" which then described as B = -a - b + 0. Last, we connec B and C into a final statement A = B + C.

import puan_rspy as pr

model = pr.TheoryPy([
    # This first statement has id=0, bounds=(0,1) and an AtLeast proposition
    # saying that the sum of value of variable "1" and variable "2" and -1 must
    # be greater or equal than zero. In other words, at least one of variable "1"
    # and variable "2" must be 1.
    pr.StatementPy(0, (0,1), pr.AtLeastPy([1,2],-1, pr.SignPy.Positive)),
    pr.StatementPy(1, (0,1), pr.AtLeastPy([3,4], 1, pr.SignPy.Negative)),
    pr.StatementPy(2, (0,1), pr.AtLeastPy([5,6],-2, pr.SignPy.Positive)),

    # These are independent variable declarations, e.i. variables that are
    # not dependent on other variables
    pr.StatementPy(3, (0,1), None),
    pr.StatementPy(4, (0,1), None),
    pr.StatementPy(5, (0,1), None),
    pr.StatementPy(6, (0,1), None),
])

# Here we use puan-rust's internal solver for solving our model with these
# five different objectives, and then print the result.
for solution, objective_value, status_code in theory.solve([{3: 1}, {4: 1}, {5: 1}, {6: 1}, {3:1, 4:1}], True):
    print(solution, objective_value, status_code)

# Which prints:
# {3: 1, 6: 0, 5: 0, 4: 0} 1 5
# {3: 0, 4: 1, 5: 0, 6: 0} 1 5
# {5: 1, 4: 0, 3: 0, 6: 0} 1 5
# {5: 0, 6: 1, 4: 0, 3: 0} 1 5
# {4: 1, 5: 1, 3: 1, 6: 1} 2 5 

Release files for puan-rspy 0.4.2

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

Source distribution (sdist)

Source distribution for puan-rspy 0.4.2
File Size Uploaded
puan_rspy-0.4.2.tar.gz 13.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for puan-rspy 0.4.2
File
puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.11 CPython 3.11 Linux glibc 2.5+ x86-32 Details
puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.7+ x86-64 Details
puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-32 Details
puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.7+ x86-64 Details
puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-32 Details
puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-32 Details
puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details

Total release size: 11.5 MB

Release files / puan_rspy-0.4.2.tar.gz

Download URL puan_rspy-0.4.2.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5f98e2d8f9aeba79186916eba91a8d0381827cc6029b30d07081be358d2b44c1
BLAKE2b-256 checksum
How to use checksums
a54383d84a47d190daa9d00269f263f875e9fb69847fe299d4d478e77641e24e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5d3298a851cca5693f282b8e7bdced91b0b3d9e5f732d5438562c5292874826f
BLAKE2b-256 checksum
How to use checksums
63d7a6674ead4d1e45152eeb1737e3a725ff457a4e2bc54b8e3fd011d70b4c78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl

Download URL puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.3 MB
Tags CPython 3.11 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
d02ce095bf962648245c648078a0dbde48777bb42fde598282709ae0c5a9e1f3
BLAKE2b-256 checksum
How to use checksums
3006a36093b15d4de0c001ba2ce6d5f0af451b6074c7815efc764ebb78910e4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl

Download URL puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl
Size 371.6 kB
Tags CPython 3.11 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
d35a8423104103b5c0763efa515ae56773d51bcbb7c5bd6968373a1d5aadfc1e
BLAKE2b-256 checksum
How to use checksums
77b4cd4d31b2968c273ff2792df470aac04484af22f059ee073f13b75c205bd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
58f51bb37f83ea2bbd81bce55211420d5ad6fb4300f0bd4afd6215b238a047a9
BLAKE2b-256 checksum
How to use checksums
bb295560ab864862a5bd0ea58d2ba5c1677ba196fe0701b272130f55ed3aa402
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl

Download URL puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.3 MB
Tags CPython 3.10 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
82a4de113bee7178756cd93a8f9f68641bbfa409610ef9a134fb7b7ba3b0eb4b
BLAKE2b-256 checksum
How to use checksums
7f34b6eb282ca5115e3e9ca40ca8ab6278d08bf0a88c5b16de2d4fd4b19bfb97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl

Download URL puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl
Size 371.6 kB
Tags CPython 3.10 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
9107666caa1603e65d3fb4fd460eb2d2289a6d0da6ea74cd5a3034bd52882f1d
BLAKE2b-256 checksum
How to use checksums
92e3d27a10662f62af7aa5a31e5fd15ec5297676f4c25651b0b6149c0ccee88d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
af6aadd2bd864118d8da03b64d6026c8502acc5ffddf57bef78fd2ccaacb4cbd
BLAKE2b-256 checksum
How to use checksums
e7769d383983534fb3f15fc24fd7b7aed43a425e4631359de510555b9d09fb12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl

Download URL puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.3 MB
Tags CPython 3.9 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
1a11a15e1efb700aa0a11bda48e51cc9bc6c300499bfdfd6c36b7f325833466b
BLAKE2b-256 checksum
How to use checksums
8b310bae3126eacf6db73b7ead2448e867fbda546be3a8b8029b1068a2b5288a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl

Download URL puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl
Size 372.4 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
1888ca6e49cf73ff63a57eac2650718ad0ca7e336804e8d96d252b733e638b06
BLAKE2b-256 checksum
How to use checksums
9e8af88736ed9d3d1d7d64967fcb92d9148a3152fd5d63495de38ed6edc19149
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e37f488995cab9253862c4decc1186379014ec0974e9a36ef2bf6f03fa131b6f
BLAKE2b-256 checksum
How to use checksums
a3bb8fd1f876d57ef9656bc3dde5ac3df602d58728b6facbf024c904a6a72f38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl

Download URL puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.3 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
ad8dc1ac15311ffa7c66926c6ad6fb4672b880223ff30fd52877df60438684d9
BLAKE2b-256 checksum
How to use checksums
fe6b443dd8a67b22705bfa0302618c5c72371609db4147ed2a0be354f228a904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl

Download URL puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl
Size 371.9 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
ddb5f423da1f2f9010f6e71a1962598135279f1304d994ef7503e6a77d270345
BLAKE2b-256 checksum
How to use checksums
d449ad9d2dc97655609e741e84d55ee343801513046e9e2676b79771be944d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.4.2 This release

13 release files

0.4.1

13 release files

0.3.0

13 release files

0.2.8

7 release files

0.2.7

7 release files

0.2.6

7 release files

0.2.5

7 release files

0.2.4

2 release files

0.2.2

5 release files

0.2.1

2 release files

0.1.8

3 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