Javier Núñez wrote:
> I need make this flow constraint for a routing problem:
> (in latex): \sum_j x_{ ij } = \sum_j x_{ ji }
> (in ampl): sum {j in J} x[i,j] - sum {j in J} x[j,i] = 0
>
> (where x[i,j] is a binary variable, for all i in I and j in J.). I
> tried to do this constraint in gecodej (in java), but is incorrect:
>
> [...]
> x = new VarMatrix<IntVar>(this, n, n, IntVar.class, 0, 1);
> for (int i=0; i<n; i++) {
> linear(this, x.row(i) - x.col(i) , IRT_EQ, 0);
> }
> [...]
>
> Error: "operator: cannot be applied to VarArray<IntVar>,
> VarArray<IntVar>"
You cannot use expressions like x-y for posting constraints (not in
Java, anyway). You have to use an integer array with coefficients
{1,-1} and an array of IntVar containing x.row[i] and x.col[i] instead
and give those to linear. See the documentation of the linear
constraint posting function.
Guido
_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users