by Dana DeLou » Mon, 08 Sep 2003 22:54:48
Would using Solver be an acceptable solution? If I understand the question,
you have a number like 90.
You multiply 90 by .33 to get 29.7. You have to decide to use integer 29,
or rounded up 30. You do this for each percentage given.
These rounded numbers must total the original 90.
I hope I understand this correctly. This is hard to explain, so here goes.
Have two columns that round the percentages down, and up.( to get the 29,
and 30 from above). In the next 3 columns, put 0,1, and for the third, use
"SUM" and sum the 0 & 1 cells. Since you can not use IF functions, this is
a way to have Solver decide on the two cells. The 0/1 cells will be a
constraint that are Binary. The Sum cell is another constraint that says it
should total 1. Solver will alternate the two 0/1 cells so that one of them
will be 1, and the other will be zero. Now, use Sumproduct on the two
rounded values (29/30, and the two cells 0/1). This will be the value that
Solver picks. To determine the "Error" I used for example (29.7- Solver's
Pick)^2.
Basically, the difference squared. (Note that using ABS(difference) will
not work in Solver, so that is why ^2).
Copy these down for the other percentages.
Add a Sum formulas that sum the differences. Add another formula that does
this: =90-Sum(Solver's pick). Solver needs to make this equal zero.
For Solver, try to minimize the total of the "differences."
For constraints:
0/1 cells are binary
Each of Sum(x,y) cells that sum the 0/1 cells should total 1.
Set the cell that has "90-Sum(Solver's pick). " equal to zero.
In Excel XP, you often have to run Solver twice to get the "better"
solution.
For some numbers, Solver suggested a solution that was not similar to
rounding the 7 smallest percentages, and then adjusting the 33%.
I'm not a Stat's expert, so I'm not sure if (difference)^2 is the best
measure. It appears that if you round the 7 smallest percentages, some
numbers will make the larger .33 value have to move a larger integer amount
to get back to the original value.
For example, if using (difference)^2, Solver suggests taking you number (90
* 4% = 3.6) and rounding down to 3.
This allowed your 90*33% = 29.7 to use 30 instead of a value 28!
The penalty of (29.7 - 28)^2 was too high doing it this way.
Anyway, HTH. :>)
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =