title: Area optimization algorithm
body: <p>I'm having the requirement, to insert a specific amount of rectangles (which have a defined width but a random height) into another rectangle (which has a defined height and the same defined width as the rectangles to insert). The goal here is, that those inserted rectangles should fill-out the target rectangle as much as possible.</p>
  
  <p>For instance:</p>
  
  <p><img src="https://i.stack.imgur.com/sXHIC.png" alt="enter image description here"></p>
  
  <p>I don't need to get as much rectangles as possible into the black, the goal is to fillout the black rect as much as possible, best case, entirely. </p>
  
  <p>In reality, there are many "black" rectangles and thousands of "reds", I'm looking for an effective algorithm to calculate. I have to implement this in ECMA-/Javascript so it's not really the fastest of all platforms.</p>
  
  <p>I looked into some algos like Richard E. Korf's "Optimal Rectangle Packing" or "Bin packings problems", but I couldn't really translate those for this specific problem.</p>
  
  <p>Can somebody recommend me a method/algorithm ?</p>