I believe you know how to post a sum constraint so the non trivial part lies in the c[i,next[i]] which retrieves the integer in matrix c at row i and column next[i]. The problem is that next[i] is a variable so you cannot use it directly to access a (Java) array.
You need to use the element constraint (that is also in minizinc):
/**
* Creates an element constraint: value = table[index]
*
* @param value an integer variable taking its value in table
* @param table an array of integer values
* @param index an integer variable representing the value of value in table
*/
default Constraint element(IntVar value, int[] table, IntVar index)
As you work with a matrix, you need to do that for each row and then post a sum on them.
Note also that in Java, array cells are accessed from 0 to n-1 (in minizinc it is from 1 to n), so you may need to update the model accordingly or use an offset.
Hope this helps
https://www.cosling.com/