Constraint - forall - CPLEX

3.3k Views Asked by At

How do I write such constraint in CPLEX, (is it right to put l+1)?

s_ijml + x_ijml*p_ij <= s_i'j'm(l+1)

where s and x are decision variables, i,j,m,l are indices

Thanks,

2

There are 2 best solutions below

2
On BEST ANSWER

Try this:

{int} i_indexes = ...;
{int} j_indexes = ...;
{int} m_indexes = ...;
{int} l_indexes = ...;

dvar float+ s[i_indexes][j_indexes][m_indexes][l_indexes];

forall(i in i_indexes, j in j_indexes, m in m_indexes, l in l_indexes) {
    l != last(l_indexes) => s[i][j][m][l] <= s[i][j][m][nextc(l_indexes, l)]; 
}
0
On

In the answer above the 'index's can not be {int}, for the indexes you nedd to use 'range'. Just change the code to this:

int N_i=...;
int N_j=...;
Range I_indexes=1..N_i;
Range I_indexes=1..N_j;