Find closest value to a const from the sum of variables

Dongato

New member
Joined
May 5, 2020
Messages
4
Hi.

Maybe somebody can help me with the following.

Don't know maybe an algebraic formula or other kind of formula to solve this:

variables:
a = 0.00348723
b = 0.00258357
c = 0.00245589
d = 0.00350425
d = 0.00011199
e = 0.00023349
f = 0.00173063

constant:

A = 0.0096

Condition:

How to get the closest value to the constant A by making the sum of the variables above which the end result has to be equal or less than the constant A.

Thank you in advance.

Your help would be very appreciated.


Dongato
 
Frankly, the question doesn't make sense! You say the "sum of the given variables" but that is 0.00348723+ 0.00258357+ 0.00245589+ 0.00350425+ 0.00011199+
0.00023349+ 0.00173063= 0.01410705, one specific number. There is no question of being "closer" to any number, A.
 
If you can use only some of the values it makes more sense. But then it's not clear whether you can use the same value more than once. In any case, what you need is not a formula, but an algorithm. Is this a programming assignment?
 
Frankly, the question doesn't make sense! You say the "sum of the given variables" but that is 0.00348723+ 0.00258357+ 0.00245589+ 0.00350425+ 0.00011199+
0.00023349+ 0.00173063= 0.01410705, one specific number. There is no question of being "closer" to any number, A.

Thank you very much for taking the time to read my question.
Maybe I did not quite make clear it can be taking any number of variables to meet the requirement of "equal or less than the constant A"
I just read the post by Cubist about the knapsack problem and that's exactly the answer I was looking for.
 
If you can use only some of the values it makes more sense. But then it's not clear whether you can use the same value more than once. In any case, what you need is not a formula, but an algorithm. Is this a programming assignment?
Thank you very much for taking the time to read my question.
Maybe I did not quite make clear it can be taking any number of variables to meet the requirement of "equal or less than the constant A"
I just read the post by Cubist about the knapsack problem and that's exactly the answer I was looking for.
 
I agree with posts #2 and #3. If @lev888 is correct then the problem is called the knapsack problem (click)
Thank you very much for taking the time to read my question.
Your answer is what I was looking for.
The link to the knapsack problem has lots of examples related to the issue.
I am glad I found this forum, and so many people willing to help.
Thanks Cubist.
 
Top