I have a stock of Vitamin B1 capsules in two sizes - 100 mg and 250 mg
How can I calculate the number of each capsules required to meet a certain dosage, say 650mg or 350mg?
Can anyone help please?
Regards
Richard
I have a stock of Vitamin B1 capsules in two sizes - 100 mg and 250 mg
How can I calculate the number of each capsules required to meet a certain dosage, say 650mg or 350mg?
Can anyone help please?
Regards
Richard
I would probably do a "trial and error" kind of approach. Starting with an algebraic statement of the problem:
n*100+m*250=target
n and m have to be integers.
Solve for one of the variables (I would probably solve for n)
Try different values for m (0,1,2,3) -- calculate n
Solution's are found for any case where n is an integer. (m=1 and n=4 would be one solution for 650)
Originally Posted by shg
I tried to do a setup with Solver but I don't know how to tune it. Alf or shg or bsalv or any other Solver-guy, are you out there?
I even considered a macro that would run solver for each column at a time (kind of lame, yes I know ) but even there it would run thousands of sub- whatever.
Restrictions were int, >=0 and <10 and I tried both minimising ABS and just go for zero.
<----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left
If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.
If I used Solver, I would set it up as a root finding type problem:
n*100+m*250-target=f(m,n)=0
Enter values for n, m, and target
Enter f in a cell
Call Solver and tell it to set f equal to a value of 0 by changing m and n subject to constraints that m and n >=0 and integer
Yup, that is pretty much what I did. And solver did a fair but not perfect jobb and it took forever. Evolutionary algorithm, it doesn't seem to accept any other for this setup. I assume the settings for this and that under options have to be tweaked as well somehow but I have no clue what they even mean.
I did it long hand with a vlookup table with dosages spaced at 50mg up to 1500 - seems to work in the range I need
I've set up a macro running solver in a loop. There are probably better ways of setting up solver but as Sweden celebrate "Midsummer" yesterday my brain is not yet up to producing a more advanced solution.
To test run macro "SolvLoop"
Alf
Transposed for convenience:
A B C D E 1 Dose 250 100 2 250 1 0B2 and down: =($A2 - C2*C$1) / B$1 3 300 0 3C2 and down: =MATCH(TRUE, MOD($A2 - {0,1,2,3,4} * C$1, B$1) = 0, 0) - 1 4 350 1 1 5 400 0 4 6 450 1 2 7 500 2 0 8 550 1 3 9 600 2 1 10 650 1 4
I believe that works for any dose 250+ divisible by 50.
Last edited by shg; 06-21-2014 at 05:52 PM.
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks