简体   繁体   English

您好,我们在 OPL CPLEX 程序中有一个 LP 模型问题。 our.mod 文件显示我们的索引值 k 和 t 不存在的错误

[英]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.我们在一开始就给我们的Parameters做了标注,我们知道在Parameters中不需要定义t和k的索引值。 But we receive the same error in the resctriction area of the LP-Model telling us that they do not exist.但是我们在 LP 模型的限制区域中收到相同的错误,告诉我们它们不存在。 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工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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