Skip to main content

A Numpy and Numba based Python library for solving Constraint Satisfaction Problems over finite domains

Project description

NucS logo

pypi version pypi downloads

numba version numpy version

tests doc license

TLDR

NuCS is a Python library for solving Constraint Satisfaction and Optimization Problems. Because it is 100% written in Python, NuCS is easy to install and allows to model complex problems in a few lines of code. The NuCS solver is also very fast because it is powered by Numpy and Numba.

Installation

pip install nucs

Documentation

Check out NUCS documentation.

With NuCS, in a few seconds you can ...

Find all 14200 solutions to the 12-queens problem

NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.queens -n 12
{
    'OPTIMIZER_SOLUTION_NB': 0,
    'PROBLEM_FILTER_NB': 262011,
    'PROBLEM_PROPAGATOR_NB': 3,
    'PROBLEM_VARIABLE_NB': 36,
    'PROPAGATOR_ENTAILMENT_NB': 0,
    'PROPAGATOR_FILTER_NB': 2269980,
    'PROPAGATOR_FILTER_NO_CHANGE_NB': 990450,
    'PROPAGATOR_INCONSISTENCY_NB': 116806,
    'SOLVER_BACKTRACK_NB': 131005,
    'SOLVER_CHOICE_NB': 131005,
    'SOLVER_CHOICE_DEPTH': 10,
    'SOLVER_SOLUTION_NB': 14200
}

Compute the 92 solutions to the BIBD(8,14,7,4,3) problem

NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.bibd -v 8 -b 14 -r 7 -k 4 -l 3 --symmetry_breaking
{
    'OPTIMIZER_SOLUTION_NB': 0,
    'PROBLEM_FILTER_NB': 2797,
    'PROBLEM_PROPAGATOR_NB': 462,
    'PROBLEM_VARIABLE_NB': 504,
    'PROPAGATOR_ENTAILMENT_NB': 5273,
    'PROPAGATOR_FILTER_NB': 562130,
    'PROPAGATOR_FILTER_NO_CHANGE_NB': 531724,
    'PROPAGATOR_INCONSISTENCY_NB': 1307,
    'SOLVER_BACKTRACK_NB': 1398,
    'SOLVER_CHOICE_NB': 1398,
    'SOLVER_CHOICE_DEPTH': 41,
    'SOLVER_SOLUTION_NB': 92
}

Demonstrate that the optimal 10-marks Golomb ruler length is 55

NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.golomb -n 10 --symmetry_breaking
{
    'OPTIMIZER_SOLUTION_NB': 10,
    'PROBLEM_FILTER_NB': 22886,
    'PROBLEM_PROPAGATOR_NB': 82,
    'PROBLEM_VARIABLE_NB': 45,
    'PROPAGATOR_ENTAILMENT_NB': 98080,
    'PROPAGATOR_FILTER_NB': 2843257,
    'PROPAGATOR_FILTER_NO_CHANGE_NB': 1806240,
    'PROPAGATOR_INCONSISTENCY_NB': 11406,
    'SOLVER_BACKTRACK_NB': 11405,
    'SOLVER_CHOICE_NB': 11470,
    'SOLVER_CHOICE_DEPTH': 9,
    'SOLVER_SOLUTION_NB': 10
}
[1, 6, 10, 23, 26, 34, 41, 53, 55]

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

nucs-2.1.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

NUCS-2.1.0-py3-none-any.whl (96.4 kB view details)

Uploaded Python 3

File details

Details for the file nucs-2.1.0.tar.gz.

File metadata

  • Download URL: nucs-2.1.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nucs-2.1.0.tar.gz
Algorithm Hash digest
SHA256 8780cae88c4908e74e26cdcaf30dd4b9140eb3363434b53afacd09840b503b56
MD5 c02a02a604fad48a132a195541d61e68
BLAKE2b-256 217130701b3f1fb82c90f2548ee370528f5c50a2563d2b2c65c80e52554b2883

See more details on using hashes here.

Provenance

The following attestation bundles were made for nucs-2.1.0.tar.gz:

Publisher: publish.yml on yangeorget/nucs

Attestations:

File details

Details for the file NUCS-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: NUCS-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 96.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for NUCS-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc952b579f1f9deb3e090d7d61fff4d48fec44a87e6e16565e8e919159124555
MD5 64ce50be0e525a653f19886860074e67
BLAKE2b-256 0f5312926aa13f47705e73fa8bd897c733825fba3629e2de3c59e0ed25905e8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for NUCS-2.1.0-py3-none-any.whl:

Publisher: publish.yml on yangeorget/nucs

Attestations:

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