-3

I am not a mathematician and I hope I am in the right place with my problem. Basically, my question is a subproblem of the stock cutting problem. I am developing a simple algorithm that generates a set of elements with a fixed overall weighting from a list of elements, each with a possibly different weighting.

For example:

Overall weighting (OW): 100
List of weightings of the elements (L): 20, 20, 20, 20, 20

Is there an established mathematical optimization function or formula that I am unfamiliar with that can be used to determine whether exactly the overall weighting can be achieved from any combination of the weightings of the elements? Not all elements need to be used. The overall weighting must neither be undercut nor exceeded, otherwise the generation of the set must be aborted.

My intention is to develop a function from it that passes the following tests with the following results (OW is 100 for all tests):

L = {20, 20, 20, 20, 20} -> True
L = {20, 20, 20, 22, 19} -> False
L = {20, 20, 20, 20, 10, 3, 3, 3, 1} -> True
L = {20, 20, 20, 20, 10, 3, 3, 3, 2} -> False

My guess is that I can only arrive at a solution by trial and error, which therefore corresponds to n! trials, whereby n = number of elements in L.

1 Answers1

2

This is called the subset sum problem. See https://en.wikipedia.org/wiki/Subset_sum_problem

RobPratt
  • 45,619