Skip to main content

knapsack is a package for solving knapsack problem.

  • Maximize sum of selected weight.
  • Sum of selected size is less than capacity.
  • Algorithm: Dynamic Optimization

Usage

import knapsack
size = [21, 11, 15, 9, 34, 25, 41, 52]
weight = [22, 12, 16, 10, 35, 26, 42, 53]
capacity = 100
knapsack.knapsack(size, weight).solve(capacity)

See also https://pypi.org/project/ortoolpy/

Requirements

  • Python 3

Setup

$ pip install knapsack

History

  • 0.0.1 (2015-6-26): first release

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

knapsack-0.3.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file knapsack-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: knapsack-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for knapsack-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc12941156a5e79e06373bddc89b3eb61091b0772b24e0d5766abbc88605e469
MD5 b31fa41d6d090ee1a3a05e9577661d12
BLAKE2b-256 d11c43cdefe94c9354e9f9a1f79954adbb3d0fed58abd86027ebdc83f6e18941

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 file

0.3.0

1 file

0.2.0

1 file

0.1.1

2 files

0.1.0

1 file

0.0.7

1 file

0.0.6

2 files

0.0.5

2 files

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

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