title: Combinatorial optimization for puzzle solving
body: <p>My problem is explained in the following image
  <a href="http://i.stack.imgur.com/n6mZt.png" rel="nofollow">http://i.stack.imgur.com/n6mZt.png</a> </p>
  
  <p>I have a finite (but rather large) amount of such pieces that need to be stacked in a way so that the REMAINING area is the smallest possible. The pieces are locked in the horizontal axis (time) and have fixed height. They can only be stacked. </p>
  
  <p>The remaining area is defined by the maximum point of the stack that depends on which pieces have been selected. The best combination in the example image would be the [1 1 0]. (The trivial [0 0 0] case will not be allowed by other constraints)</p>
  
  <p>My only variables are binaries (Yes or No) for each piece. The objective is a little more complicated than what I am describing, but my greatest problem right now is how to formulate the expression</p>
  
  <pre><code>Max{Stacked_Pieces} - Stacked_Pieces_Profile
  </code></pre>
  
  <p>in the objective function. The result of this expression is a vector of course (timeseries) but it will be further reduced to a number through other manipulations.</p>
  
  <p>Essentially my problem is how to write</p>
  
  <pre><code>Max{A} - A, where A = 1xN vector
  </code></pre>
  
  <p>In a way compatible with a linear (or even quadratic) objective. Or am I dealing with a non-linear problem?</p>
  
  <p><em>EDIT: The problem is like a Knapsack problem the main difference being that there is no knapsack to fill up. i.e. the size of the knapsack varies according to the selected pieces and is always equal to the top of the stacked profile</em></p>
  
  <p>Thanks everybody!</p>