我如何才能让 CPLEX 理解我指的是元组的哪个特定部分?

How can I make CPLEX understand which specific part of the tuple I am referring to?

我有这个元组:

tuple copie_macchine {

   int macchina;
   int copia1;
   int copia2;
   int copia3; 

 }

{copie_macchine} copie = ...;

例如:

 copie = {<3,3,4,0>,
 <6,7,8,9>,
 <8,11,12,0>,
 <9,13,14,0>,
 <10,15,16,0>,
 <20,26,27,28>};

我有这部分代码:

forall (j in J)
    
    forall (m in M )
                   
           forall (i1 in I)
    
              forall (c in copie : c.copia3 !=0 && m == c.copia1 || m == c.copia2 || m == c.copia3)
 
                    {
                      
                      sum (m in M) y[i1][j][m] == 1;   
                                               
                    }

我怎样才能让 CPLEX 理解,例如 c.macchina = 3 那么指的是 c.copia1 = 3,c.copia2 = 4?

您可以在元组集中使用数组:

.mod

tuple copie_macchine {

   key int macchina;
   int copia1;
   int copia2;
   int copia3; 

 }

{copie_macchine} copie = ...;

tuple copie_macchine2
{

   key int macchina;
   int copies[1..3];

 }
 
 range r=1..3;
 int ar[r];
 
 copie_macchine2 copie2[i in copie]=<i.macchina,ar>;
 
 execute
 {
   copie2;
 }
 
 
 execute
 {
   for(var i in copie)
   {
     copie2[i].copies[1]=i.copia1;
     copie2[i].copies[2]=i.copia2;
     copie2[i].copies[3]=i.copia3;
   }
 }

.dat

copie = {<3,3,4,0>,
 <6,7,8,9>,
 <8,11,12,0>,
 <9,13,14,0>,
 <10,15,16,0>,
 <20,26,27,28>};