title: matrix with row and column constraints
body: <p>I need to solve for a n x n (n usually &lt;12) matrix subject to a few constraints:</p>
  
  <p>1.Predetermined row and column sums are satisfied. </p>
  
  <p>2.Each element in the matrix having a row number greater than column number must be zero (so basically the only nonzero elements must be in the top right portion).</p>
  
  <p>3.For a given row, every element more than three columns to the right first nonzero element must also be zero.</p>
  
  <p>So, a 4x4 matrix might look something like this (the row and column constraints will be much larger in practice, usually around 1-3 million):</p>
  
  <pre><code>|3 2 1 0| = 6
  |0 2 1 1| = 4
  |0 0 2 1| = 3
  |0 0 0 4| = 4
   3 4 4 6
  </code></pre>
  
  <p>I have been trying to use some solver approaches to do this in excel and also have tried some R based optimization packages but have been so unsuccessful so far. </p>
  
  <p>Any suggestions on how else I might approach this would be much appreciated.</p>
  
  <p>Thanks!</p>