Re: selecting dictionaries to maximize counts

2005-02-18 Thread Brian Beck
Steven Bethard wrote: > Anyway, do you know what name this problem is usually discussed under? If I knew what to google for, I could probably find at least a few simple heuristics to try... I think the closest thing would be the 'knapsack problem' or the 'subset sum problem.' http://en.wikipedi

Re: selecting dictionaries to maximize counts

2005-02-18 Thread Steven Bethard
Brian Beck wrote: Steven Bethard wrote: I have a list of dictionaries. Each dictionary holds counts of various 'words', e.g.: py> countdicts = [ ... dict(a=9, b=9, c=9), ... dict(a=8, b=7), ... dict(a=4, b=5, c=12)] I need to select dicts with the constraint that the number of each

Re: selecting dictionaries to maximize counts

2005-02-18 Thread Brian Beck
Steven Bethard wrote: I have a list of dictionaries. Each dictionary holds counts of various 'words', e.g.: py> countdicts = [ ... dict(a=9, b=9, c=9), ... dict(a=8, b=7), ... dict(a=4, b=5, c=12)] I need to select dicts with the constraint that the number of each 'word' totalled ov

Re: selecting dictionaries to maximize counts

2005-02-18 Thread Steven Bethard
John Machin wrote: Steven Bethard wrote: I have a list of dictionaries. Each dictionary holds counts of various 'words'... ... Basically, I use a greedy approach -- adding a dict each time if I can. ... This leads to some suboptimal solutions given that, while the total counts must not exceed MAX

Re: selecting dictionaries to maximize counts

2005-02-18 Thread John Machin
Steven Bethard wrote: > I have a list of dictionaries. Each dictionary holds counts of various > 'words', e.g.: > Basically, I use a greedy approach -- adding a dict each time if I can. > This leads to some suboptimal solutions given that, while the total > counts must not exceed MAX_VALUE, I

selecting dictionaries to maximize counts

2005-02-18 Thread Steven Bethard
I have a list of dictionaries. Each dictionary holds counts of various 'words', e.g.: py> countdicts = [ ... dict(a=9, b=9, c=9), ... dict(a=8, b=7), ... dict(a=4, b=5, c=12)] I need to select dicts with the constraint that the number of each 'word' totalled over all selected dicts