CPLEX Ilog Studio放松了重要的约束-无法正确解决

时间:2018-10-29 01:37:46

标签: cplex ilog

我是第一次使用CPLEX Studio。我使用的是学生版,因此无法通过IBM支持部门记录问题。

我正在使用下面粘贴的复杂问题。问题是minedOnlyOnce约束。这应该只开采一次块,但是开采一次以上。

{int} TimePeriods =...;

{int} Blocks =...;



float value[Blocks] = ...;
float oreTons[Blocks] = ...;
float wasteTons[Blocks] = ...;
float resourceMaxCap =...;
float processMinCap =...;


 tuple blockType {
    int id;
    int x;
    int y;
    int z;
 };

{blockType} BlocksType = ...;

{blockType} Ontop[j in BlocksType] =
     {i | i in BlocksType: j.z == i.z +1 &&
                        ((j.x  == i.x-1 ) ||
                         (j.x  == i.x+1 ) ||
                         (j.x  == i.x )  ) &&
                        ((j.y  == i.y-1 ) ||
                         (j.y  == i.y+1 ) ||
                         (j.y  == i.y )  ) };




dvar boolean schedule[Blocks][TimePeriods];


maximize

sum( b in Blocks, t in TimePeriods) ( value[b] * schedule[b][t] * 1/(1+0.1)^t );


subject to{


forall(b in Blocks) {
         minedOnlyOnce :
         sum( t in TimePeriods) (schedule[b][t]) <= 1;
         }


forall( i in BlocksType,t in TimePeriods) {
        BlocksOnTop :
        sum(j in Ontop[i])(t) * schedule[i.id][t]-sum(j in Ontop[i])sum(r in TimePeriods : r <= t)(schedule[j.id][r]) <=0 ;
        }




forall(t in TimePeriods) {
         resourceAvailable :
         sum(b in Blocks)  (schedule[b][t]*oreTons[b]+schedule[b][t]*wasteTons[b]) <= resourceMaxCap;
         }



forall(t in TimePeriods) {
         minProcessFeed :
         sum(b in Blocks)(schedule[b][t]*oreTons[b]) >= processMinCap;
         }


}
SheetConnection sheet("3D_27block_data.xlsx");

BlocksType from SheetRead(sheet,"Data!A2:D28");
Blocks from SheetRead(sheet,"Data!A2:A28");
TimePeriods from SheetRead(sheet,"Data!O2:O4");

value from SheetRead(sheet,"Data!H2:H28");
oreTons from SheetRead(sheet,"Data!F2:F28");
wasteTons from SheetRead(sheet,"Data!G2:G28");

resourceMaxCap from SheetRead(sheet,"Data!P2:P4");
processMinCap from SheetRead(sheet,"Data!Q2:Q4");

schedule to SheetWrite(sheet,"Data!I2:K28");

1 个答案:

答案 0 :(得分:-1)

如果该模型不可行,CPLEX可以放宽标记的约束并提供宽松的解决方案。

如果你转身

forall(b in Blocks) {
         minedOnlyOnce :
         sum( t in TimePeriods) (schedule[b][t]) <= 1;
         }

进入

forall(b in Blocks) {
         //minedOnlyOnce :
         sum( t in TimePeriods) (schedule[b][t]) <= 1;
         }

然后,该约束将变成硬约束(无法放松的约束)