pykp.solvers#

Implementations of various solvers for the knapsack problem.

PyKP solvers provides various solvers for knapsack problem. It provides access to knapsack-specific branch-and-bound algorithms, as well as well-known general-purpose constraint-modelling algorithms, like Gecode and Coin-OR Branch-and-cut.

Common functions and objects, shared across different solvers, are:

Solution(value, type, statistics)

Represents a solution returned by a solver.

SolutionStatistics(time, n_solutions, cost)

Statistics about the solution returned by a solver.

SolutionType(value[, names, module, ...])

Types of solutions that can be returned by a solver.

Exact Algorithms#

branch_and_bound(items, capacity[, n])

Solves the knapsack problem using the branch-and-bound algorithm.

minizinc(items, capacity[, solver])

Solves the knapsack problem using the MiniZinc.

Approximation Algorithms#

greedy(items, capacity)

Appy the greedy algorithm to a knapsack problem instance.