[gecode-users] flow constraint

Christian Schulte cschulte at kth.se
Wed May 14 08:40:53 CEST 2008


Moreover, if the variables are 0/1 it is better to use BoolVar instead of
IntVar.

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Guido Tack
Sent: Wednesday, May 14, 2008 8:39 AM
To: Javier Núñez
Cc: users at gecode.org
Subject: Re: [gecode-users] flow constraint

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
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list