0

I'm working on a mathematical model and my cplex code can be seen at the bottom. When I start running this model and I have "out of memory error " after 30 minutes and model says that the problem of this error in theese two "forall" sections. Can you please help me to reduce the usage of memory by changing this foralls. Thank you.

this constraint gives error:

forall (m in MachineType, i in ProductType, p in PolishingType,t in TimePeriod, u in (2..A[i]*D[m][p]):(t+u <=maxT)) 
  (- x[m][t][i][p] + x[m][t+1][i][p] - x[m][t+u][i][p]) <=0;

forall (m in MachineType, p1 in PolishingType, p2 in PolishingType:p1!=p2, t in TimePeriod, i in ProductType, u in TimePeriod:u==S /*[m][p1][p2]*/&&(t+u <=maxT)) 
  x[m][t+u][i][p2] <= 1-x[m][t][i][p1];

/*********************************************
 * OPL 22.1.1.0 Model
 * Author: User
 * Creation Date: May 1, 2023 at 2:12:46 PM
 *********************************************/
int NMachineType=...; //M-m
int NPolishingType=...; //P-p
int NProductType=...; //İ-i 
int NTimePeriod=...; //T-t
int maxT=32400;//Toplam Çalışma Süresi
float BigM=99999999999; 
int S=97;//97 saniye 
range MachineType=1..NMachineType;
range PolishingType=1..NPolishingType;
range ProductType=1..NProductType;
range TimePeriod=1..NTimePeriod;


int  Q[ProductType]=...; //i ürününden sipariş edilen miktar
int A[ProductType]=...; //i ürününün polisajda işlem alanı
dvar boolean J[MachineType][PolishingType]; //m makinesinin p türü polisaj işini yapabiliyorsa 1, yapamıyorsa 0 değerini alan gösterge kümesi
int IP[ProductType][PolishingType]=...;// i ürünün görmesi gereken polisaj aşamaları dvar 
int D[MachineType][PolishingType]=...; //m makinesinin p türü polisaj işini yapma süresi
//int S[MachineType][PolishingType][PolishingType]; //m makinesinde p_1 türü polisaj işinden p_2 türü polisaja geçişte makine ayar süresi 
dvar boolean x[MachineType][TimePeriod][ProductType][PolishingType]; //1,m" makinesine " t" zamanında " i" ürününün " p" tür polisajına atanır" otherwise=0

minimize sum(m in MachineType, t in TimePeriod, i in ProductType, p in PolishingType) (t* x[m][t][i][p]);

subject to 
{
  forall (m in MachineType, t in TimePeriod) sum(i in ProductType,p in PolishingType) x[m][t][i][p] <=1;
  
  forall (m in MachineType, i in ProductType, p in PolishingType, t in (2..A[i]*D[m][p])) (x[m][1][i][p]-x[m][t][i][p]) <=0;
  
  forall (m in MachineType, i in ProductType, p in PolishingType,t in TimePeriod, u in (2..A[i]*D[m][p]):(t+u <=maxT)) 
  (- x[m][t][i][p] + x[m][t+1][i][p] - x[m][t+u][i][p]) <=0;
  
  forall (m in MachineType, i in ProductType, p in PolishingType, t in 2..(A[i]*D[m][p])) (x[m][maxT][i][p]-x[m][maxT-t][i][p]) <=0;
  
  forall (m in MachineType, p in PolishingType) sum(i in ProductType, t in TimePeriod) x[m][t][i][p] <= BigM * J[m][p];
  
  forall (i in ProductType, p in PolishingType:p==IP[i][p]) sum(m in MachineType, t in TimePeriod) x[m][t][i][p] >=1;//== D[m][p];
  
  forall (m in MachineType, p1 in PolishingType, p2 in PolishingType:p1!=p2, t in TimePeriod, i in ProductType, u in TimePeriod:u==S /*[m][p1][p2]*/&&(t+u <=maxT)) 
  x[m][t+u][i][p2] <= 1-x[m][t][i][p1];
  
  }

I tried to the deactivate theese two parts but program didn't continued.

Berk Uzun
  • 1
  • 1
  • We don't know how big are the ranges of machine types, products, polishing types etc but I suspect that you are creating a huge number of variables and constraints. Does it work OK for smaller instances? How does memory use grow as you increase the instance size? I suspect that you will need to change your model to use sparse data structures, e.g. index your variables etc by sets of tuples. See the examples provided with CPLEX. Or, if this is really a scheduling problem, swap to using the CP solver and model stuff using interval variables etc. Again look at the provided examples – TimChippingtonDerrick May 08 '23 at 17:30

0 Answers0