title: cplex - minimization and sum of matrix values and indexes
body: <p>I'm using a Cplex Java API for the first time. </p>
  
  <p>I want to minimize the sum of values in matrix on some indexes, which is given by condition. </p>
  
  <p>For example, if I have the matrix <code>M = {{ 0, 1, 2, 1},{ 1, 2, 1, 0},{ 0, 1, 1, 0},{ 1, 1, 1, 2}}</code>.</p>
  
  <p>I want to calculate two sums, first, the sum of all elements <code>e = 1</code> and second, indexes where elements are equal to <code>1</code>. </p>
  
  <p>So, indexes where element is equal <code>1</code> are <code>{{0,1} {1,0} {1,2} {2,1} {2,2} {3,0} {3,1} {3,2}</code>. </p>
  
  <p>Result for first case is 9 (1+1+1+1+1+1+1+1+1)` and for second case is 24 (0+1+1+0+1+2+2+1+2+2+3+0+3+1+3+2).</p>
  
  <p>I'm not sure how to use <code>IloNumVar[]</code> and create an expression using <code>IloLinearNumExpr</code> which is used in sum and minimize a function, while matrix <code>M</code> is type <code>int[][]</code>.</p>