如何使用元组作为字符串和int输入来解决CPLEX?

时间:2018-04-05 06:29:16

标签: arrays string tuples

    int nbProducts = ...;

    int nbCustomers= ...;

    int nbPeriod = ...;

//从excel输入数据为int以满足

 tuple PCP1{

   string ProdID;

   string CustID;

   string PeriodId;

   }

tuple PCP2 {

    string ProdID;   

}

tuple PCP3{   

    string CustID;   

}

tuple PCP4{   

    string PeriodID;   

}

tuple PCP5{

    string ProdID;

    string SupID;

    string PeriodId;

}

tuple PCP6 {

    string ProdID; 

}

tuple PCP7{   

   string SupID;   

}

tuple PCP8{   

   string PeriodID;   

}

 setof(PCP1) PCP_list1 = ...;  

 setof(PCP5) PCP_list5 = ...;  

 setof(PCP2) PCP_list2 = {<f> | <f,j,v> in PCP_list1};

 setof(PCP3) PCP_list3 = {<j> | <f,j,v> in PCP_list1}; 

 setof(PCP4) PCP_list4 = {<v> | <f,j,v> in PCP_list1}; 

setof(PCP6) PCP_list6 = {<f> | <f,j,v> in PCP_list5}; 

setof(PCP7) PCP_list7 = {<j> | <f,j,v> in PCP_list5};

setof(PCP8) PCP_list8 = {<v> | <f,j,v> in PCP_list5}; 

float Demands [1..nbProducts nbCustomers nbPeriod] = ...;

浮动需求[p in 1..nbProducts,s in 1..nbCustomers,c in 1..nbPeriod] =需求[c + nbPeriod *(s-1)+ nbCustomers nbPeriod ( p-1]);

dvar boolean x[PCP_list2][PCP_list3];

dvar boolean x_sup[PCP_list6][PCP_list7][PCP_list8];

dvar boolean x_cus[PCP_list2][PCP_list3][PCP_list4];

 minimize sum(i in PCP_list2, j in PCP_list3 ) x[i][j];

subject to


   { forall( i in PCP_list6, j in PCP_list7, k in PCP_list8)
       x_sup[i][j][k] <= 1000; 

   forall(i in PCP_list2, j in PCP_list3, k in PCP_list4)
       x_cus[i][j][k] == Demand[i][j][k];

  forall( i in PCP_list2, k in PCP_list4)
       sum( c in PCP_list3 ) x_cus[i][c][k] <=  100; 
} 

//我在第二个约束中遇到约束问题 第二个约束无法直接读取我一直试图解决但却无法想到要解决的功能。

0 个答案:

没有答案