# Two sized vitamin pills - how many of each at a specific dosage?

1. ## Two sized vitamin pills - how many of each at a specific dosage?

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?

Regards

Richard

2. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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)

3. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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.

4. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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

5. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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.

6. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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

7. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

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

8. ## Re: Two sized vitamin pills - how many of each at a specific dosage?

Transposed for convenience:

 A B C D E 1 Dose 250 100 2 250 1 0 B2 and down: =(\$A2 - C2*C\$1) / B\$1 3 300 0 3 C2 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.

There are currently 1 users browsing this thread. (0 members and 1 guests)