Note that there are some explanatory texts on larger screens.

plurals
  1. POoptimal solution for a modified version of the bin-packing task
    primarykey
    data
    text
    <p><strong>Problem</strong></p> <p>Suppose we have a set of <em>N</em> real numbers <em>A = {x_1, x_2, ..., x_N}</em>.</p> <p>The goal is to partition this set into <em>A_1, A_2, ..., A_L</em> subsets with the limitation of <em>sum( A_i ) &lt;= T</em> and <strong>minimizing</strong> this term:</p> <p><em>Cost := sum( abs( sum(A_i) - T ) )</em></p> <p>where <em>sum(A_i)</em> denotes the summation of numbers in <em>A_i</em> and <em>T</em> is a given threshold.</p> <p><em>I am looking for a non-evolutionary optimal algorithm.</em></p> <p><strong>Update:</strong> <em>x_i</em> are real positive numbers and not greater than <em>T</em> ( <em>0 &lt; x_i &lt;= T</em> ).</p> <p><strong>Update 2:</strong> The cost function fixed.</p> <hr> <p><strong>Nice try, Greedy algorithm!</strong></p> <p>A simple idea is to use a <a href="http://en.wikipedia.org/wiki/Greedy_algorithm" rel="nofollow">Greedy</a> approach to solve the problem. Here is a pseudocode:</p> <pre><code> 1. create subset A_1 and set i=1. 2. remove the largest number x from A. 3. If sum(A_i) + x &lt;= T * put x into A_i 4. Else * create a new subset A_i+1, * put x into A_i+1 * set i=i+1 5. If A is non-empty * goto step 2. 6. Else * return all created A_i s </code></pre> <p>The problem is this solution is not optimal. For example, there are cases that it is better not to put two largest numbers, <em>x1</em> and <em>x2</em>, in the first subset <em>A_1</em> even they don't exceed <em>T</em>, because there is no other *x_i* available to add to that set and make its sum closer to <em>T</em>. In the other hand, if we had put <em>x1</em> and <em>x2</em> in the separate sets, a better solution could be found (a solution with smaller <em>Cost</em> value).</p> <p><strong>Possible solutions</strong></p> <p>I have thought of using a <a href="http://en.wikipedia.org/wiki/Backtracking" rel="nofollow">Backtracking</a> algorithm which can find the optimal solution too, but I guess its complexity in this problem would be high.</p> <p>I have read some article on Wikipedia like <a href="http://en.wikipedia.org/wiki/Bin_packing_problem" rel="nofollow">Bin packing problem</a> (NP-hard <em>[sighs...]</em>) and <a href="http://en.wikipedia.org/wiki/Cutting_stock_problem" rel="nofollow">Cutting stock problem</a> and apparently my problem is very similar to this standard problems, but I am not sure which one matches my case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload