Benchmarking of algorithms for set partitions
This paper reviews algorithms for enumerating set partitions, provides approximate formulas for their counts, and recommends the algorithm by Djokic et al. based on benchmarking tests.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a box of distinct Lego bricks. Your job is to figure out every single way you can group these bricks together. You could put each brick in its own little pile, you could stack them all into one giant tower, or you could mix and match them into various clusters. In the world of math, this is called a set partition.
This paper is essentially a "race report" for computer programs that try to list every single one of these possible groupings. Here is the breakdown of what the authors found, using simple analogies:
1. The Problem: A Rapidly Exploding Puzzle
The authors explain that while listing groupings sounds easy for a few items, the number of possibilities explodes incredibly fast.
- The Analogy: Think of it like a game of musical chairs, but instead of people, you have numbers. With just 3 items, there are 5 ways to group them. But by the time you have 17 items, there are about 82 billion different ways to group them.
- The Reality: If you have more than 17 or 18 items, it becomes impossible for a computer to list every single grouping in a reasonable amount of time. However, for smaller numbers, it is very useful to have a computer do this, especially for optimization tasks like packing boxes or scheduling shifts.
2. Counting the Possibilities (The "Bell Numbers")
Before they could race the algorithms, the authors needed a way to know exactly how many groupings to expect. These numbers are called Bell Numbers.
- The Challenge: Calculating the exact number is hard, so mathematicians use formulas to estimate it.
- The Discovery: The authors tested several complex math formulas. They found one specific formula (involving a special math function called the "Lambert W function") that is incredibly accurate. It's like having a weather forecast that is right down to the minute, even for small numbers of items. They also found a simpler formula that works well for smaller groups but gets a bit sloppy as the numbers get huge.
3. The Race: Four Algorithms Competing
The main part of the paper is a "benchmark," which is just a fancy word for a timed race. The authors took four different computer programs (algorithms) designed to list these groupings and ran them on various computers (laptops, desktops, cloud servers) using different software tools (compilers) and operating systems (Windows and Linux).
The four racers were:
- Hutchinson's Algorithm: The "Old Timer." This is the classic method from decades ago.
- Semba's Algorithm: A modern, fast contender.
- Er's Algorithm: Another modern, fast contender.
- Djokic et al.'s Algorithm: The newest challenger.
The Results:
- The Old Timer (Hutchinson): This program was significantly slower than the others. It's like trying to run a marathon in heavy boots. The authors explicitly say: Do not use this one.
- The Modern Racers (Semba, Er, Djokic): These were much faster.
- The Winner: Djokic's algorithm took the gold medal. It was the fastest across the board.
4. The "Engine" Matters Too
The authors also discovered that the "engine" running the code matters just as much as the car itself.
- Operating Systems: Code running on Linux was generally faster than on Windows.
- Compilers: The tool used to translate the code into machine language made a huge difference. For example, on one specific algorithm, the Intel compiler was much faster than the standard GNU compiler, but for another algorithm, the GNU compiler was faster.
- The Takeaway: To get the best speed, you need the right algorithm and the right software settings.
5. The Final Recommendation
After running thousands of tests, the authors have a clear verdict for anyone who needs to do this work:
- Use the algorithm by Djokic et al. It is the fastest, it is relatively short (easy to write), and it is easy to implement.
- Tip: Make sure your computer is set to "high performance" mode (compiler optimization level 2 or higher) and, if you are on Linux, use the Intel compiler for the best results.
What They Didn't Cover
The authors were careful to stick to the basics. They did not test algorithms that try to find groupings with specific limits (like "groups can only have 3 items max"), nor did they look at a different type of ordering system called "Gray codes." Those are left for future research.
In summary: If you need a computer to list every way to group a small set of items, don't use the old methods. Use the Djokic algorithm, run it on Linux with the Intel compiler, and you'll get the job done in the blink of an eye.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.