词典模型问题-CPLEX OPL-模型永远运行,没有答案

时间:2019-10-29 09:15:46

标签: cplex opl lexicographic

我在1:31分钟停止了,这是引擎日志的输出:enter image description here我正在使用CP进行目标编程的模型-字典编目。数据来自excel文件。 问题是:该软件正在运行,正在运行...。没有答案。 我看到它正在工作,因为时间在右下角过去了。数据不是太大,我在CPLEX的其他分析中使用了相同的数据,效果很好。

Excel文件: https://drive.google.com/open?id=1rOKhqlegKo-BHJnJj9cnnpKMdwpktYlX

1)有人可以看到出什么问题了吗? 2)只需确保使用CP不可能将dvar作为float +,对吗?

谢谢

.mod

 using CP;
 // variable decision 

 {string} Forest = ...;
 {string} Products = ...;
 {string} Destination = ...;

 float Demand [Destination][Products]= ...; //volume in Kg
 float Distance [Forest][Destination]= ...; //in Km
 float Stock [Forest][Products]= ...; //volume in Kg 
 float Freshness [Forest][Products]=...; `


 //Decision Variables
 dvar int+ Delivered [Forest][Destination][Products];

 //Expressoes
 dexpr float Opt_Distance = sum (u in Forest, c in Destination, p in Products) Distance[u][c] * Delivered[u][c][p]; 
 dexpr float Opt_Freshness =  sum (u in Forest, c in Destination, p in Products) Freshness[u][p] * Delivered[u][c][p]; 

 //Objective Function
 minimize staticLex (Opt_Distance,Opt_Freshness); 


 //Constraint
 subject to {
     forall (p in Products)
         forall (u in Forest)
             sum (c in Destination)
                 Delivered[u][c][p] <= Stock [u][p];

     forall (p in Products)
         forall (c in Destination)
             sum (u in Forest) 
                 Delivered[u][c][p] >= Demand[c][p];   

}


.dat

 // variable decision 

 Forest = {"F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24","F25","F26","F27","F28","F29","F30","F31","F32","F33","F34","F35","F36","F37","F38","F39","F40","F41","F42","F43","F44","F45","F46","F47","F48","F49","F50"};
 Products = {"P1","P2","P3","P4"};
 Destination = {"D1","D2","D3","D4","D5","D6","D7","D8","D9","D10"};



 SheetConnection sheet("...Data_test.xlsx");


 Demand from SheetRead(sheet,"Demand");
 Distance from SheetRead(sheet,"Distance");
 Stock from SheetRead(sheet,"Stock");
 Freshness from SheetRead(sheet,"Freshness");

1 个答案:

答案 0 :(得分:3)

似乎您没有设置任何时间限制。在这种情况下,引擎将搜索最佳解决方案,直到可以证明当前解决方案是最佳解决方案为止。通常,不能保证搜索会在合理的时间内结束(问题可能是NP)。

如日志所示,您在88秒后手动停止了搜索(“通过中止”),同时找到了86个解决方案。每次找到解决方案时,日志中都会有一行以星号开头。当前的最佳目标值也打印在日志中(第一列)。

因此,我建议在模型中添加一些时间限制(或其他类型的限制)。可以通过以下方式完成:

var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
    var fileName= args[1];
}

是的,CP模型中不可能有浮点变量。