[英]Multiple Model Building (Iteratively) in C++ (Benders Decomposition with Multiple Scenarios)
I'm trying to write a Benders Decomposition code in C++ to solve a facility location problem. 我正在尝试用C ++编写Benders分解代码来解决设施位置问题。 It is a two stage stochastic programming example and the demand parameters depend on the scenarios.
它是一个两阶段随机编程示例,需求参数取决于场景。 I wrote a similar code in AMPL before and it's run file was starting as follows:
之前我在AMPL中编写了类似的代码,它的运行文件开始如下:
option solver cplexamp;
option omit_zero_rows 1;
option display_eps .000001;
option solver_msg 0;
option show_boundto1 0;
problem Master: r, y, theta,
Master_Cost, Cut_Defn, Open_Facilities_Facility_Capacity, Number_of_Facilities_Per_Node;
problem Sub{s in 1..NSec}:
{k in 1..K, (i,j) in LINKS} x[k,s,i,j],
{k in 1..K, i in 1..nnodes} z[k,s,i],
{k in 1..K, i in 1..nnodes} w[k,s,i],
BSP_Cost[s],
{i in 1..nnodes, k in 1..K} Flow_Conservation[i,k,s],
{(i,j) in LINKS} Arc_Capacity[i,j,s];
let nCUT := 0;
let {s in 1..NSec} theta[s] := 0;
let {k in 1..K, i in 1..nnodes} R[k,i] := 0;
param GAP default Infinity;
param newGAP;
However, in C++ I don't know how to construct subproblems (build models) with respect to scenarios. 但是,在C ++中,我不知道如何构建关于场景的子问题(构建模型)。 (I should construct a model for every scenario indexed by
s
) (我应该为
s
索引的每个场景构建一个模型)
Below is the subproblem generation part of my code (s number of models); 下面是我的代码的子问题生成部分(模型数量); however, I realized this is wrong because it is only adding constraints to a one large problem instead of s subproblems.
但是,我意识到这是错误的,因为它只是对一个大问题而不是子问题添加约束。
IloModel model_sub(env);
IloObjective Objective_sub(env);
model_sub.add(Objective_sub);
for (int s=0; s<S; s++){
for (int i=0; i<I; i++){
for (int j=0; j<J; j++){
model_sub.add(MU[i][s] + Beta[j][s] <= c[j][i]);
}
}
}
IloCplex cplex_sub(model_sub);
Any help is appreciated, thanks a lot. 感谢任何帮助,非常感谢。
Note: This link has a code that is working with only a single subproblem (a single scenario). 注意: 此链接的代码仅与单个子问题(单个方案)一起使用。 This is basically what I'm trying to replicate (or base my code on), if anyone is interested.
这基本上是我试图复制(或基于我的代码),如果有人感兴趣。 If you also have a link or a file of a multi-scenario Benders code, that'd also be amazingly generous.
如果你还有一个多场景Benders代码的链接或文件,那也是非常慷慨的。
Thanks again. 再次感谢。
您可以有一个IloModel
每个方案或有一个IloModel
为您的子问题,但修改每一个需要解决的一个问题特定场景时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.