【问题标题】:Problem with lexicographic model - CPLEX OPL - Model is running forever with no answer字典模型的问题 - CPLEX OPL - 模型永远运行而没有答案
【发布时间】:2020-02-24 12:18:05
【问题描述】:

我在 1:31 分钟停止,这是引擎日志输出:我正在使用 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");

【问题讨论】:

  • 您至少应该将引擎日志输出添加到您的帖子中。否则无法判断可能发生的情况。如果您还可以添加 Excel 电子表格,我们可以尝试在此处运行您的模型。这可能会更清楚地说明正在发生的事情。
  • 你能澄清一下到底是什么问题吗?从引擎输出我们可以看到求解器找到了许多可行的解决方案,然后手动中断。所以它确实找到了一些东西。它只是无法证明最优性。这可能需要任意时间(参见 Petr 的回答)。

标签: cplex opl lexicographic


【解决方案1】:

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

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

所以我建议在您的模型中添加一些时间限制(或其他类型的限制)。可以这样做:

execute {
  cp.param.timelimit = 120; // In seconds 
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多