多目标编程-CPLEX OPL-最小化偏差



我是CPLEX的初学者,如果这个问题很愚蠢,我很抱歉。我想在CPLEX(OPL(的目标编程中尽量减少偏差。我看到了一个与我的问题非常相似的问题(Cplex中的目标编程(,但我还不清楚。

让我们假设以下情况:

首先,我们想优化商店和客户之间的距离,考虑到所需的需求和库存。我们做到了,最好的解决方案是602

其次,我们想优化另一件事,也考虑到库存和需求,解决方案是251.4

然后,我们想制定一个目标程序来实现这两个目标。

这是一个想法(不起作用(:

有什么建议吗?非常感谢

// decision variable 
{string} Store = {"A","B","C","D","E"};
{string} Products = {"P1","P2"};
{string} Client = {"D1" , "D2"};
float Demand [Client][Products]= [[3,1],[4,5]]; //volume in Kg
float Freshness [Store][Products]=[[140,0],[0,100],[0,90],[50,0],[10,0]]; //Lower numbers must have priority
float Stock [Store][Products]= [[0.94,0],[0,8.62],[0,1.21],[2.6,0],[8.77,0]]; //volume in Kg
float Distance [Store][Client]=[[21,52],[42,12],[25,15],[52,31],[9,42]]; //in Km

//Decision Variables
dvar float+ Delivered [Store][Client][Products];
//Função Objetivo
minimize (p1 + n1+ p2+ n2);
//Restricoes
subject to {
sum (u in Store, c in Client, p in Products) 
Distance[u][c] * Delivered[u][c][p] - p1 + n1 <= 657.9;
sum (u in Store, c in Client, p in Products) 
Freshness[u][p] * Delivered[u][c][p] - p2 + n2 <= 251.4;

forall (p in Products)
forall (u in Store)
sum (c in Client)
Delivered[u][c][p] <= Stock [u][p];
forall (p in Products)
forall (c in Client)
sum (u in Store) 
Delivered[u][c][p] >= Demand[c][p];

}

如果你的kpi是p1和p2,你可以使用staticEx并写

minimize staticLex(p1,p2);

最新更新