如何在 cplex 上以更紧凑的方式编写此代码?

how can I write this code in a more compact way on cplex?

如何在 CPLEX 上以更紧凑的方式编写此代码?

forall (j in J)
    

    forall (i in I1)
      
      {
      
      if ( macc [i][j] == 1 || 2 || 4 || 5 || 7 || 11 || 12 ||  13 || 14 || 15 || 16 || 17 || 18 || 19) {
        
        y[i][j][m] == 1;
        
              }
         else {
           
           if (macc [i][j] == 3) {
             
             y[i][j][3] == 1 || y[i][j][4] == 1;
            
           }
    }            

您可以在 if 条件中对数据使用“in”:

{int} s={1,2,4,5,7,11,12,13,14,15,16,17,18,19};
int m=2;
dvar int x;

subject to

{
  if (m in s) x==2;
  
}

工作正常