title: Strange but practical 2D bin packing optimization
body: <p><img src="https://i.stack.imgur.com/SnsKC.png" alt="Sample Sub-optimal output"></p>
  
  <p>I am trying to write an application that generates drawing for compartmentalized Panel.</p>
  
  <p>I have N cubicles (2D rectangles) (N &lt;= 40). For each cubicle there is a minimum height (minHeight[i]) and minimum width (minWidth[i]) associated. The panel itself also has a MAXIMUM_HEIGHT constraint.</p>
  
  <p>These N cubicles have to be arranged in a column-wise grid such that the above constraints are met for each cubicle.</p>
  
  <p>Also, the width of each column is decided by the maximum of minWidths of each cubicle in that column. </p>
  
  <p>Also, the height of each column should be the same. This decides the height of the panel</p>
  
  <p>We can add spare cubicles in the empty space left in any column or we can increase the height/width of any cubicle beyond the specified minimum. However we cannot rotate any of the cubicles.</p>
  
  <pre><code>OBJECTIVE: TO MINIMIZE TOTAL PANEL WIDTH.
  </code></pre>
  
  <p>At present I have implemented it simply by ignoring the widths of cubicles in my optimization. I just choose the cubicle with largest minHeight and try to fit it in my panel. However, it does not gurantee an optimal solution.</p>
  
  <p>Can I get any better than this?</p>
  
  <p>EDIT 1: MAXIMUM_HEIGHT of panel = 2100mm, minwidth range (350mm to 800mm), minheight range (225mm to 2100mm)</p>
  
  <p>EDIT 2: PROBLEM OBJECTIVE: TO MINIMIZE PANEL WIDTH (not panel area).</p>