AMPL实施ILP制定

时间:2018-06-25 21:50:14

标签: ampl

我尝试使用AMPL解决奖赏收集斯坦纳树优化问题。我确实为此找到了一个ILP公式,但是现在我很难将其实现到AMPL中。特别是(c)中的约束。 ILP-formulation我希望有人能帮助我。

我的尝试:

param n; #Anzahl der Knoten

set V := 1..n; #Knotenmenge
set E within {i in V, j in V: i<j}; #Kantenmenge
set T {i in V}; #Terminalmenge 

param p {i in V};
param w {(i,j) in E};
param r in V;


var x {(i,j) in E} binary;
var y {k in V: k != r} binary;

maximize profit: sum {i in V} p[i]*y[i] - sum {(i,j) in E} w[i,j]*x[i,j];

subject to Verhältnis: sum {(i,j) in E} x[i,j] = sum {i in V} y[i] - 1 ;
subject to Terminal{i in T}: y[i] = 1;

1 个答案:

答案 0 :(得分:0)

不确定以下方法是否有效,但也许会帮助您入门

set Vt within V     #Vt subset of V
set card(Vt) >= 2   #|Vt| >= 2
set v in Vt
set E_Vt --> "maybe set similar as E but with Vt"

subject to constraint_C: sum{(i,j) in E_Vt} x[i,j] <= sum{i in Vt and i<>v} y[i]

我本人不知道该怎么写 i in Vt\{v}这就是为什么我写i<>v的原因,如果您找到解决方案,我会很感兴趣。