Skip to main content

Contains generators for np-hard problems with known solution.

Project description

nphard-generators

This package provides some generators for creating instances of np-hard problems such as maximum-clique-problem or hamiltonian-cycle-problem. Most of them implement or provide a optimal solution for the generated instance or at least its size. For more details, see [bachelorarbeit]

Usage

Maximum-Clique-Problem

from nphard_generators import (
    MCPBrockFactory,
    MCPCFatFactory,
    MCPHamming2Factory,
    MCPSanchisFactory,
    MCPSynA1Factory,
    MCPSynA3Factory
)

MCPSynA1Factory.generate_instance(50, 0.5, 12).to_file("dataset_mcp/syna1.mtx")
MCPCFatFactory.generate_instance(50, 0.3).to_file("dataset_mcp/cfat.mtx")
MCPSanchisFactory.generate_instance(50, 0.5, 12).to_file("dataset_mcp/sanchis.mtx")
MCPHamming2Factory.generate_instance(50).to_file("dataset_mcp/hamming2.mtx")
MCPBrockFactory.generate_instance(50, 0.5, 14, 1).to_file("dataset_mcp/brock.mtx")
MCPSynA3Factory.generate_instance(50, 0.5, 3).to_file("dataset_mcp/syna3.mtx")

Hamiltonian-Cycle-Problem

from nphard_generators import HCPPetersenFactory, HCPSynH1Factory, HCPSynH2Factory

HCPSynH1Factory.generate_instance(30, 0.5).to_file("dataset_hcp/synh1.tsp")
HCPSynH2Factory.generate_instance(30, 0.5).to_file("dataset_hcp/synh2.tsp")
HCPPetersenFactory.generate_instance(23*2, 11).to_file("dataset_hcp/petersen_nh.tsp") # non-hamiltonian
HCPPetersenFactory.generate_instance(23*2, 13).to_file("dataset_hcp/petersen_h.tsp") # hamiltonian

Access types

ProblemSolution refers to a whole solution (e.g. size and which nodes), ProblemSimpleSolution only to the size from nphard_generators.types import MCProblemSolution, ...

Installation

Ensure you have a valid python installation running, e.g. Python 3.11

Install as package from TestPyPi

pip install --index-url https://test.pypi.org/simple/ nphard-generators or pip install --upgrade --index-url https://test.pypi.org/simple/ nphard-generators

Installing local for usage:

pip install -e . Installs nphard-generators itself as well as relevant libraries such as numpy, etc.

Installing local for development:

pip install -e .[dev] Installs relevant libraries as well as pytest, etc.

Packaging

Build

Generate distribution archives using python -m build. (Uses Hatchling as buildbackend)

Distribute

Upload to TestPyPi using twine: python -m twine upload --repository testpypi dist/*

Upload to PyPi using twine: python -m twine upload dist/*

Workflow

  1. Clone repository
  2. Install
  3. Edit
  4. Test
  5. Build
  6. Upload

Docstring

PEP 257; three-double-quote """ format Docstring for public methods, nontrivial size or non-obvious logic Content: How to use the method (without providing the actual code); No details

TODO: GitHub-flavored Markdown

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

nphard_generators-0.1.0.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nphard_generators-0.1.0-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file nphard_generators-0.1.0.tar.gz.

File metadata

  • Download URL: nphard_generators-0.1.0.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for nphard_generators-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7562653746eecafe4537292dc14abb8ca832be1a0c02147f585f0fff8766ca25
MD5 23434a93ee7882f00e1eacf4d25277a1
BLAKE2b-256 8fb938ee579bda923a8220fd939e852cd669690dcc9f4b230f4a8c78b157f572

See more details on using hashes here.

File details

Details for the file nphard_generators-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nphard_generators-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e380fc2254fbad61a0bf0456f69d6557cff1fa3ebc55d60c67591ef16ee8276
MD5 a4b09b9c90390091765c19d2f6bcc73f
BLAKE2b-256 82927a370864720da5dc11a35e1da774b268ba0d7230d101a48488354c45e2fe

See more details on using hashes here.

Supported by

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