subset_sum_swap, a Fortran90 code which uses swapping to try to improve an initial estimated solution of the subset sum problem, which seeks a subset of a set of integers which has a given sum. Even when an exact solution exists, this approach often only finds an approximate solution.

In the test code, we will be given a collection of 21 weights and a target value (24639098). We seek a combination of the weights which adds up to the target value, or comes very close to it.


The information on this web page is distributed under the MIT license.


subset_sum_swap is available in a C version and a C++ version and a Fortran77 version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:


f90_combinatorics, a Fortran90 code which considers a variety of problems in combinatorics involving counting, combinations, permutations, and so on.


Source Code:

Last revised on 13 June 2024.