I wanna use variables in cplex forall syntax like as below..
forall(j in {1,2,3,4,5,6,7})
{
x[1][j] + x[1][(j+3)%7] + x[1][(j+4)%7] + x[1][(j+5)%7] +
x[1][(j+6)%7] + x[2][j] + x[2][(j+3)%7] + x[2][(j+4)%7] +
x[2][(j+5)%7] + x[2][(j+6)%7] >= 5;
}
But after I ran this script, there was a syntax eror because of (j+3)... How should I make a script to use this algorithm?
There are different ways to solve this, basically you need a function which takes the j index and the offset as parameter and return the corresponding result.
This could be done with a constant matrix that you set at the beginning for each of the 7 j and offsets. Then inside the loop you refer to
x[1][ f[j][3] ]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.