简体   繁体   中英

Hello, we have a LP-Model Problem in OPL CPLEX Programm. Our .mod file shows errors that our index values k and t does not exist

// Indices 
int K =  ...;                // Produktgruppe
int T = ...;                 // Periode

// Parameter
 float a[1..K] = ...;        // Produktionskoeffizient für Produktgruppe k für die personelle Kapazität
 float b[1..K] = ...;        // Produktionskoeffizient für Produktgruppe k für die technische Kapazität
 float d[1..K] [1..T] = ...; // Nachfrage nach Produktgruppe p zum Zeitpunkt t
 float l[1..K] = ...;        // Lagerkostensatz für Produktgruppe k
 float u[1..T] = ...;        // Überstundenkostensatz in Periode t
 int Cmax[1..T] = ...;       // Maximale technische Kapazität in Periode t
 int Nmax[1..T] = ...;       // Maximale personelle Kapazität in Periode t
 int Umax[1..T] = ...;       // Maximale Übersunden in Periode t 
 
 // Entscheidungsvariable
 dvar float+ X[1..K] [1..T]; // Produktionsmenge von Produktgruppe k in Periode t
 dvar float+ L[1..K] [1..T]; // Lagermenge von Produktgruppe k in Periode t
 dvar float+ U[1..T];        // Genutze Überstunden in Periode t
 // Zielfunktion
   minimize sum (t in 1..T, k in 1..K) (l[k]*L[k][t]) + sum(t in 1..T) (u[t]*U[t]);
    
 // Nebenbedingungen    
 subject to {
  
 forall(t in 1..T, k in 1..K)   error: Aggregation operator FORALL not available for int.
 //ctTechnische Kapazitaetsrestriktion:
 sum(k in 1..K) (b[k]*X[k][t] <= Cmax[t]);    error: Name t does not exist
 
 forall (k in 1..K)                 
 //ctPersonelle Kapazitaetsrestriktion:
 a[k]*X[k][t] - U[t] <= Nmax[t];          error: Name t does not exist
    
 forall (t in 1..T)
 //ctmaximale Ueberstundenrestriktion:
  U[t] <= Umax[t];
  
  forall (t in 1..T) (k in 1..K);
  //ctProduktionsmengen:
  X[k][t] => 0;                      error: Name k does not exist
  
  forall (t in 1..T)(k in 1..K);
  // Lagermengen:
  L[k][t] => 0;                      error: Name k does not exist
  
  forall (t in 1..T) (k in 1..K);
  // Ueberstundenrestriktion:
  U[t] => 0;                          error: Name t does not exist
}





We labeled our Parameters at the beginning right and we know that in the Parameters it is not neccessary to define the index values of t and k. But we receive the same error in the resctriction area of the LP-Model telling us that they do not exist. If anyone finds where the problem is please give us your ideas/solutions.

Kind regards

// Indices 
int K =  2;                // Produktgruppe
int T = 3;                 // Periode

// Parameter
 float a[1..K] = [1,2];        // Produktionskoeffizient für Produktgruppe k für die personelle Kapazität
 float b[1..K] =[1,2];         // Produktionskoeffizient für Produktgruppe k für die technische Kapazität
 float d[i in 1..K] [j in 1..T] = i*j; // Nachfrage nach Produktgruppe p zum Zeitpunkt t
 float l[1..K] = [1,2]; ;        // Lagerkostensatz für Produktgruppe k
 float u[1..T] = [1,2,3]; ;        // Überstundenkostensatz in Periode t
 int Cmax[1..T] = [1,2,3];;       // Maximale technische Kapazität in Periode t
 int Nmax[1..T] = [1,2,3];       // Maximale personelle Kapazität in Periode t
 int Umax[1..T] = [1,2,3];       // Maximale Übersunden in Periode t 
 
 // Entscheidungsvariable
 dvar float+ X[1..K] [1..T]; // Produktionsmenge von Produktgruppe k in Periode t
 dvar float+ L[1..K] [1..T]; // Lagermenge von Produktgruppe k in Periode t
 dvar float+ U[1..T];        // Genutze Überstunden in Periode t
 // Zielfunktion
   minimize sum (t in 1..T, k in 1..K) (l[k]*L[k][t]) + sum(t in 1..T) (u[t]*U[t]);
    
 // Nebenbedingungen    
 subject to {
  
 forall(t in 1..T)   //error: Aggregation operator FORALL not available for int.
 //ctTechnische Kapazitaetsrestriktion:
 sum(k in 1..K) b[k]*X[k][t] <= Cmax[t];    //error: Name t does not exist
 
 forall (t in 1..T,k in 1..K)                 
 //ctPersonelle Kapazitaetsrestriktion:
 a[k]*X[k][t] - U[t] <= Nmax[t];          //error: Name t does not exist
    
 forall (t in 1..T)
 //ctmaximale Ueberstundenrestriktion:
  U[t] <= Umax[t];
  
  forall (t in 1..T,k in 1..K)
  //ctProduktionsmengen:
  X[k][t] >= 0;                      //error: Name k does not exist
  
  forall (t in 1..T,k in 1..K)
  // Lagermengen:
  L[k][t] >=0;                      //error: Name k does not exist
  
  forall (t in 1..T,k in 1..K)
  // Ueberstundenrestriktion:
  U[t] >= 0;                         // error: Name t does not exist
}

works fine

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM