> > subject to riga {k in ELEMENTI,i in ELEMENTI,j in ELEMENTI: j != i} :
> > x[k,i] != x[k,j] ;
This is not correct
>
> The != is a logical relational operator, not a constraint relation.
> Put another way, constraints in a math program are limited to =, <=
> and >= (unless the model is going to a constraint solver, but I don't
> think AMPL supports constraint solvers yet). So AMPL saw this as a
> logical constraint, tried to convert it to an indicator constraint (if
> logical condition then algebraic relation), failed and burped up the
> error message.
>
> Since x is integer in {0, ..., n}, you can enforce x[k, i] != x[k, j]
> by introducing a binary variable z[k, i, j] and adding constraints
>
> x[k, i] <= x[k, j] - 1 + (n + 1)*z[k, i, j]
> x[k, j] <= x[k, i] - 1 + (n + 1)*(1 - z[k, i, j])
>
No comments:
Post a Comment