Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

How can I write this code in a more compact way on 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;
            
           }
    }            

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you can use "in" with data in an if condition:

{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;
  
}

works fine

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading