Phillip Feldman phillip.m.feld...@gmail.com added the comment:
Raymond-
I think that you may have overestimated the complexity of the problem. In
about 5 hours, I coded, debugged, and documented a set of generator functions
to solve the general formulation (including box limits) for three
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
Sorry Phillip, I'm closing this feature request because the benefits would
likely be outweighed by the costs (maintenance, learning curve, module
complexity, etc). It was not the goal of the module to become a complete
Phillip Feldman phillip.m.feld...@gmail.com added the comment:
Mark: I disagree with your claim that in its basic form, this is covered by
itertools.combinations. If you open the attached text on elementary
combinatorics and go to page 11, you will see a table that lays out six of the
eight
Mark Dickinson dicki...@gmail.com added the comment:
Mark: I disagree ...
Okay, I misunderstood. I thought you were still talking about the unlabelled
balls in labelled boxes problem, which is an isomorphic problem to that solved
by combinations_with_replacement.
It looks as though you're
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
Any additions would need to be motivated by real world problems. The issue is
that adding more generators makes the module harder to learn and remember, so
tools are not usually added for the sake of completeness.
--
Phillip Feldman phillip.m.feld...@gmail.com added the comment:
Ideally, I'd like to see support for all combinations of the following
occupancy problem features:
- Labeled and unlabeled boxes
- Labeled and unlabeled balls
- Empty boxes allowed and empty boxes forbidden
- Boxes with no capacity
Phillip Feldman phillip.m.feld...@gmail.com added the comment:
With the exception of the empty boxes forbidden category, I've come across
all of these at one time or another, many in the context of error control
coding (data communications). Much of the early work on occupancy problems was
Mark Dickinson dicki...@gmail.com added the comment:
Balls-in-boxes _is_ one of the most basic of the canonical combinatorial
problems.
Agreed. But in its basic form, this is covered by itertools.combinations,
isn't it? It may be worth a doc recipe showing how to use
Mark Dickinson dicki...@gmail.com added the comment:
And using combinations_with_replacement, it's even a one-liner:
balls_in_boxes = lambda n, k: (tuple(map(c.count, range(k))) for c in
combinations_with_replacement(range(k), n))
for item in balls_in_boxes(5,3): print(item)
...
(5, 0, 0)
Changes by Georg Brandl ge...@python.org:
--
title: unlabelled balls in boxes - itertools: unlabelled balls in boxes
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12961
___
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
priority: normal - low
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12961
___
___
Phillip Feldman phillip.m.feld...@gmail.com added the comment:
The itertools module should only have a few of the most generally useful,
especially in combination with other tools.
Balls-in-boxes _is_ one of the most basic of the canonical combinatorial
problems. You can verify this by
12 matches
Mail list logo