So I talked with some colleagues and the problem I currently have is actually quite challenging. The context behind this problem has to do with mass spectrometry and assigning structure to different peaks that the software gives.
But to break it down into a optimization problem, I have a certain target value. I also have a list of various inputs whose sum I want to be as close as possible to the target as possible.
So as an example, here is what I have.
List of inputs: [18.01, 42.01, 132.04, 162.05, 203.08, 176.03]
Target value: 1800.71
I want to find all the possible combinations of the inputs listed whose sum is within 0.5 of 1800.71. So the sum can be anywhere between 1800.21 and 1801.21.
I already know two inputs could be:
[18.01, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05, 162.05] **which gives a sum of 1800.59**
and
[18.01, 18.01, 203.08, 203.08, 203.08, 162.05, 203.08, 18.01, 18.01, 18.01, 18.01, 18.01, 18.01, 18.01, 18.01, 18.01, 18.01, 42.01, 162.05, 203.08, 203.08] **which gives a sum 1800.71**
I'm NOT looking to find the combination that gets me as close as possible to the target value; I am interested in ALL the possible combinations that are within 0.5 of the target value.
If anyone could help me with this problem I would greatly appreciate it!