|
Stevedore Stomp This applet demonstrates a practical application of the NP-Complete partition problem. For this demonstration, you have 20 sealed crates to load into the hold of a ship. Their weights are random numbers in the range 1-50,000 kilos. You have to flip them, port and starboard, so that you have exactly the same weight (or a difference of 1 kilo if the total weight is an odd number) on either side. These are not numbers that have been specially chosen to be partitioned in this way. They are simply 20 random numbers in the size range that you choose. If you can't get them balanced exactly, you have to do the best you can. You can either flip the crates from one side to the other by clicking the crate buttons, or you can click 'balance cargo' to let the applet do it. If you click 'balance cargo' again, the applet will balance it again, using a different sequence, and maybe giving a different balancing combination. To load a new cargo, set 'Max. Crate Size' to the value you want, and then click 'Load New Cargo'. You can type over the crate sizes with your own values. If you type space or an invalid value, it will be set to zero. |