Skip to main content

No project description provided

Project description

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 

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

puan_rspy-0.4.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distributions

puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl (371.6 kB view details)

Uploaded CPython 3.11 macOS 10.7+ x86-64

puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl (371.6 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl (372.4 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl (371.9 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

File details

Details for the file puan_rspy-0.4.2.tar.gz.

File metadata

  • Download URL: puan_rspy-0.4.2.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for puan_rspy-0.4.2.tar.gz
Algorithm Hash digest
SHA256 5f98e2d8f9aeba79186916eba91a8d0381827cc6029b30d07081be358d2b44c1
MD5 cba6dbf6091b3c4c52f2e90bf79eb76d
BLAKE2b-256 a54383d84a47d190daa9d00269f263f875e9fb69847fe299d4d478e77641e24e

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d3298a851cca5693f282b8e7bdced91b0b3d9e5f732d5438562c5292874826f
MD5 a7a61ed335a1917abda4c9da799584c2
BLAKE2b-256 63d7a6674ead4d1e45152eeb1737e3a725ff457a4e2bc54b8e3fd011d70b4c78

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 d02ce095bf962648245c648078a0dbde48777bb42fde598282709ae0c5a9e1f3
MD5 b4c477d6eaa9760e313b6122e0ecfd6a
BLAKE2b-256 3006a36093b15d4de0c001ba2ce6d5f0af451b6074c7815efc764ebb78910e4f

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 d35a8423104103b5c0763efa515ae56773d51bcbb7c5bd6968373a1d5aadfc1e
MD5 c61d4275fe78f3991cadca534fd3beb5
BLAKE2b-256 77b4cd4d31b2968c273ff2792df470aac04484af22f059ee073f13b75c205bd9

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58f51bb37f83ea2bbd81bce55211420d5ad6fb4300f0bd4afd6215b238a047a9
MD5 fc5977bea44f449f3c4d3a6398e01bf6
BLAKE2b-256 bb295560ab864862a5bd0ea58d2ba5c1677ba196fe0701b272130f55ed3aa402

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 82a4de113bee7178756cd93a8f9f68641bbfa409610ef9a134fb7b7ba3b0eb4b
MD5 835e65e2e61e05037774aca0c962b539
BLAKE2b-256 7f34b6eb282ca5115e3e9ca40ca8ab6278d08bf0a88c5b16de2d4fd4b19bfb97

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9107666caa1603e65d3fb4fd460eb2d2289a6d0da6ea74cd5a3034bd52882f1d
MD5 43e608aa513335eba6d8d8ab9942db34
BLAKE2b-256 92e3d27a10662f62af7aa5a31e5fd15ec5297676f4c25651b0b6149c0ccee88d

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af6aadd2bd864118d8da03b64d6026c8502acc5ffddf57bef78fd2ccaacb4cbd
MD5 7fed78d3cdaca3c234e22d8570c18e6a
BLAKE2b-256 e7769d383983534fb3f15fc24fd7b7aed43a425e4631359de510555b9d09fb12

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1a11a15e1efb700aa0a11bda48e51cc9bc6c300499bfdfd6c36b7f325833466b
MD5 463f5ed038b7b7c236a4c7895ddad41f
BLAKE2b-256 8b310bae3126eacf6db73b7ead2448e867fbda546be3a8b8029b1068a2b5288a

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 1888ca6e49cf73ff63a57eac2650718ad0ca7e336804e8d96d252b733e638b06
MD5 8903e6702d14be0ee085adb9ed27a8f3
BLAKE2b-256 9e8af88736ed9d3d1d7d64967fcb92d9148a3152fd5d63495de38ed6edc19149

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e37f488995cab9253862c4decc1186379014ec0974e9a36ef2bf6f03fa131b6f
MD5 cfd3b304cc191c641290dbbad842b6bb
BLAKE2b-256 a3bb8fd1f876d57ef9656bc3dde5ac3df602d58728b6facbf024c904a6a72f38

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ad8dc1ac15311ffa7c66926c6ad6fb4672b880223ff30fd52877df60438684d9
MD5 155bebaa5746c27bac6c322a6d4cbde1
BLAKE2b-256 fe6b443dd8a67b22705bfa0302618c5c72371609db4147ed2a0be354f228a904

See more details on using hashes here.

File details

Details for the file puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for puan_rspy-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ddb5f423da1f2f9010f6e71a1962598135279f1304d994ef7503e6a77d270345
MD5 bd09e1f6d15c68dc9ce8ea94783ac29a
BLAKE2b-256 d449ad9d2dc97655609e741e84d55ee343801513046e9e2676b79771be944d19

See more details on using hashes here.

Supported by

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