Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Algorithm::Knapsack 0.02

Date Added: October 17, 2010  |  Visits: 1.784

Algorithm::Knapsack is a brute-force algorithm for the knapsack problem. SYNOPSIS use Algorithm::Knapsack; my \$knapsack = Algorithm::Knapsack->new( capacity => \$capacity, weights => @weights, ); \$knapsack->compute(); foreach my \$solution (\$knapsack->solutions()) { foreach my \$index (@{\$solution}) { # do something with \$weights[\$index] } } The knapsack problem asks, given a set of items of various weights, find a subset or subsets of items such that their total weight is no larger than some given capacity but as large as possible. This module solves a special case of the 0-1 knapsack problem when the value of each item is equal to its weight. Capacity and weights are restricted to positive integers. METHODS new my \$knapsack = Algorithm::Knapsack->new( capacity => \$capacity, weights => @weights, ); Creates a new Algorith::Knapsack object. Value of \$capacity is a positive integer and @weights is a reference to an array of positive integers, each of which is less than \$capacity. compute \$knapsack->compute(); Iterates over all possible combinations of weights to solve the knapsack problem. Note that the time to solve the problem grows exponentially with respect to the number of items (weights) to choose from. solutions my @solutions = \$knapsack->solutions(); Returns a list of solutions. Each solution is a reference to an array of indexes to @weights..

 Requirements: No special requirements Platforms: Linux Keyword: Algorithm,  Algorithmknapsack,  Capacity,  Knapsack,  Knapsack Problem,  Libraries,  Problem,  Programming,  Solutions,  Weights Users rating: 0/10

 License: Freeware Size: 4.1 KB
USER REVIEWS
 More Reviews or Write Review
ALGORITHM::KNAPSACK RELATED
 Development Tools  -  General Viterbi Algorithm 1.0 General implementation of matlab version of Viterbi algorithm specifically written for gene structure finding problem in mind. However, it can be modified to suit the goal of a user.Input:Transition Probability MatrixEmission Probability... 10 KB Development Tools  -  Functions for the rectangular assignment problem 1.0 With this package, I provide some MATLAB-functions regarding the rectangular assignment problem. This problem appears for example in tracking applications, where one has M existing tracks and N new measurements. For each possible assignment, a... 20.48 KB Development Tools  -  Use of pdepe and Laplace Transform to Solve Heat Conduction Problems 1.0 In the present program three methods are used to solve a heat conduction problem. This problem is given in M. N. doOCozisik, Heat Conduction, Wiley, New York, 1980. We use pdepe, short times solution based on analytical inversion of a Laplace... 10 KB Development Tools  -  Finding a similar valid correlation matrix 1.0 Implementation of Nicholas J. Higham's algorithm "Computing the Nearest Correlation Matrix - A Problem from Finance", 2002.http://eprints.ma.man.ac.uk/232/01/covered...S_ep2006_70.pdf 10 KB Development Tools  -  Simple Example of Simulated Annealing Optimization 1.0 Case of study: "Capacity Energy Storage Solution".Dual problem of SMES, replacing inductors with capacities. 849.92 KB Libraries  -  Algorithm::Diff::Apply 0.2.3 Algorithm::Diff::Apply is a Perl module to apply one or more Algorithm::Diff diffs. SYNOPSIS ## Single-diff form: use Algorithm::Diff::Apply qw{apply_diff}; my @ary = ...; my @diff = ...; # some call to Algorithm::Diff::diff() my... 12.29 KB Development Tools  -  SpeedyGA: A Fast Simple Genetic Algorithm 1.0 SpeedyGA is a vectorized implementation of a genetic algorithm in the Matlab programming language. Without bells and whistles, it faithfully implements the specification for a Simple GA given on pgs 10, 11 of M. Mitchell's GA book. See comments in... 10 KB Utilities  -  XP Shutdown Alternative 1.0 I had this problem when I reinstalled Windows on a laptop where Windows XP would not show the shutdown dialog, when I googled for it I noticed more people had this problem. There are other solutions for it but this is by far the easiest and... 552.96 KB Development Tools  -  THE FASTEST WAY TO SORT N NUMBERS: sortN library 1.0 Have you ever thought about the fastest way to sort N numbers?Last week I wrote a post about the fastest way to sort 3 numbers, this week I show you a tricky way to optimize the sort of N numbers.The problem of sorting an array of numbers is... 10 KB Programming  -  SR2Sieve 1.8.11 SR2Sieve is a program developed by Geoffrey Reynolds to sieve composite numbers of the forms k*b^n+/-1 or b^n+/-k. It is used by PrimeGrid for a number of sieve sub-projects, including the Prime Sierpinski Problem, Reisel Problem and 321 Prime... 71.68 KB