Grouping items with most optimized value I am looking to group items with different value and get the most optimized combination closest to a certain value. For example I have items such as the ones shown below, and I am looking to group them so that the total value is as close to "50" as possible (50 or above). What would a recommended algorithm i could use to find the optimized grouping?
 Item  Value
 -----------
 ItemA  10
 ItemA  10
 ItemA  10
 ItemB  12
 ItemB  12
 ItemC  5
 ItemC  5
 ItemD  8
 ItemE  25
 ItemE  25
 ItemE  25

For example if i was to do this by hand some combinations would be 
Group into 50s
Group 1) 25 + 25 = 50
Group 2) 25 + 12 + 12 + 5 = 54
Group 3) 10 + 10 + 10 + 8 + 5 = 43 (all is remaining)

So i will have 3 groups with one of them less than 50 (43 in this case)
or
Group 1) 25 + 10 + 10 + 5 = 50
Group 2) 25 + 10 + 12 + 5 = 52
Group 3) 25 + 12 + 8 = 45 (all is remaining)

In this case which is better than the first since i have two groups closer to 50. 50 and 52
But are these the the most optimized groupings? I am not sure, I was looking to see if there is some algorithm i can use to maybe calculate the most optimized groups
 A: Thanks for the clarification of the problem. By my understanding, your objectives are:


*

*Maximise the number of groups that have sum >= 50.

*Minimise the sum of the "excess" for these groups.


This isn't exactly the knapsack problem but it's a similar problem. I suspect it's NP-hard, which means that barring a major breakthrough the time to find the best solution will increase very rapidly as the problem size increases. For small problems you can use an exhaustive search as shown in Carl's answer above; for larger problems the run-time will quickly become prohibitive. (I'm not certain I've understood the exact requirements for your problem, but most of my comments here should hold anyway.)
However, this sort of problem is very important in operations research, so there are a lot of highly-engineered algorithms that will find optimal solutions to small problems and pretty-good solutions to larger problems. If you want to roll your own, google "MIP optimisation algorithms" and start reading from there. Otherwise, I'd recommend downloading a demo of an optimisation platform like AMPL and doing a tutorial so you can take advantage of algorithms that have already been coded by others.
I coded up my understanding of your problem in AMPL:
set Items;
param NumAvailable{Items};
param Size{Items};
param MaxGroups := sum{i in Items} NumAvailable[i];
# maximum possible number of groups we could make
set Groups := 1..MaxGroups ordered;
param TargetSize;
# preferred size for each group
param BigNumber := sum{i in Items} NumAvailable[i]*Size[i];
# Primary decision variables: no. of each item type per group
var Allocations{Groups,Items} integer >= 0;
# require that all items are allocated
subject to AllocateAll{i in Items}:
NumAvailable[i] = sum{g in Groups} (Allocations[g,i]);
var SumByGroup{Groups};
subject to DefineSums{g in Groups}: SumByGroup[g] = 
sum{i in Items} Allocations[g,i]*Size[i];
# symmetry-breaking constraint: require that 
# groups are ordered largest to smallest
subject to OrderSizes{g in Groups: ord(g) > 1}: 
SumByGroup[g]<=SumByGroup[g-1];
var IsGroupAtTarget{Groups} binary;
# Enforce definition of that variable:
subject to DefineTargetFlag{g in Groups}:
IsGroupAtTarget[g]<=SumByGroup[g]/TargetSize;
# If a group is smaller than the target, all subsequent
# are empty (i.e. only allow one group < target)
subject to OnlyOneSmallGroup{g in Groups: ord(g) > 1}:
SumByGroup[g]<=BigNumber*IsGroupAtTarget[g-1];
var Excess{Groups} >= 0;
subject to DefineExcess{g in Groups}:
Excess[g]
>=
SumByGroup[g]-TargetSize+BigNumber*(IsGroupAtTarget[g]-1);
maximize ObjectiveFunction: sum{g in Groups} 
(BigNumber*IsGroupAtTarget[g]-Excess[g]);

param: Items: NumAvailable Size :=
ItemA 3 10
ItemB 2 12
ItemC 2 5
ItemD 1 8
ItemE 3 25
;
param TargetSize := 50;

With the Gurobi solver, this runs pretty much instantly. The optimal solution is:
Allocations [*,*]
:  ItemA ItemB ItemC ItemD ItemE    :=
1     2     1     2     1     0
2     0     0     0     0     2
3     1     1     0     0     1
4     0     0     0     0     0
5     0     0     0     0     0
6     0     0     0     0     0
7     0     0     0     0     0
8     0     0     0     0     0
9     0     0     0     0     0
10    0     0     0     0     0
11    0     0     0     0     0
;

i.e. group 1 has two each of ItemA and ItemC, one each of ItemB and ItemD (sum exactly 50); group 2 has two of Item E (sum exactly 50); group 3 has one each of A, B, and E (sum 47). Obviously you can't do better than this, with this particular case.
If I try a bigger problem, with 5x as many items of each kind, it still takes < 1 second to find an optimal solution: one group of 51, thirteen of 50, and one of 34. I suspect exhaustively searching all possible combinations would take rather longer!
As I commented above, this is much more of a maths or programming question than stats per se.
