Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the algorithm to optimally fill a dvd for burning

Tags:

algorithm

disk

What is the optimal algorithm for filling a set of Blu-ray disc given many hundred gigabytes of assets of varying sizes?

I am trying to consolidate a large number of old CDROMS, DVDs and small hard drives and put everything in a database indexed by MD5 signature. A daunting task for sure.

What I currently do is to sort the asset sizes (usually directory sizes) in descending order, start inserting the largest assets in the fill list skipping any that don't fit until I run out of assets. It runs almost instantaneously but I would not mind running overnight if necessary one time.

It usually gives me 95% or more utilization, but I am sure there is a way to use other combinations to give a higher efficiency. With huge items like disk images, I can get quite low utilization with this primitive method.

My thought is to take all combinations of the assets taken, 1 then 2, then 3, ... items at a time and keep a running value for the highest byte count < 25,025,314,816 bytes pointing to the array which sums to it. When I get to the point that I have so many assets taken at one time that none of the combinations will fit, stop and use the array pointed to by the running highest counter.

Is this the best possible algorithm?

There are 2 Perl modules which seem up to the task, Algorithm-Combinatorics and Math-Combinatorics. Any advice on which is faster, more stable, cooler?

My scheme is to write a script to calculate the sizes of a large number of directories and show me the optimal contents of the dozens of disks to burn.

And, I don't want to just fill on a file by file basis as I want entire directories on the same disc.

like image 986
user1556337 Avatar asked Jul 27 '12 01:07

user1556337


People also ask

What is the best software if you want to burn any type of CD or DVD?

CDBurnerXP - Best for All Kinds of Discs This program can burn CDs and DVDs, including HD DVDs and Blu-ray discs. This program also allows you to create ISOs and bootable discs with ease. CDBurnerXP is a relatively simple program that uses a standard Windows-based interface.

Can you burn 1080P to DVD?

You can easily burn 1080P to DVD with Leawo DVD Creator by referring to the following steps. Step 1: Download Leawo DVD Creator and install it on your computer. Step 2: Insert an empty DVD disc to the computer's drive with enough capacity to store the 1080P content.

How do you burn a DVD on Windows 11?

Regardless of the AutoPlay setting, to then burn a CD or DVD using File Explorer in Windows 11, select the “Burn files to disc (using File Explorer)” command in the menu of software choices that appears to open the “Burn a disc” window. Then type a name for the disc into the “Disc title:” field.


1 Answers

This is an NP-complete problem known as bin packing. There is no known polynomial-time algorithm that solves it optimally. In other words, the optimal solution cannot be found without basically trying all solutions.

On the plus side, a very simple heuristic like "put the largest remaining folder on the first disk that has room" will guarantee that you will use fewer than twice as many disks as the best case. (You can read more details on the problem's Wikipedia article).

like image 198
chepner Avatar answered Sep 30 '22 08:09

chepner