∀d1,d2∈D:∃(p [i]∈P[d1])∩(p [j]∈P[d2])∩(l∈p[i]∩l∈p[j])
我想写这个条件,但我不知道怎么做!
我写的就是你能看到的,这是对的吗?
{int} path[Demands][K_sp]=...; ( we have k_sp shortest pathes for each demand, that each shortest path includes index of links)
{int} Path[Demands]=...; (i insert all of index links for k_sp shortest paths a demand in this array)
forall (i in Demands, j in Demands : i!=j && card(Path[i] inter Path[j])!=0)
D[i][j]+D[j][i]==1;
答案 0 :(得分:0)
以下可以帮到你吗?
{int} D=asSet(1..10);
{int} allP=asSet(1..20);
dvar boolean x[d in D][p in allP]; // for each D , is p in P[d] ?
subject to
{
forall(d1,d2 in D) 1<=sum(p in allP) ((x[d1][p]==1) && (x[d2][p]==1));
}
assert forall(d1,d2 in D) or(p in allP) ((x[d1][p]==1) && (x[d2][p]==1));
问候
答案 1 :(得分:0)
你可以使用逻辑约束:
{int} D=asSet(1..10);
{int} allP=asSet(1..20);
dvar boolean x[d in D][p in allP]; // for each D , is p in P[d] ?
dvar boolean DD[d1 in D][d2 in D];
subject to
{
forall(ordered d1,d2 in D) DD[d1][d2]== (1<=sum(p in allP) ((x[d1][p]==1) && (x[d2][p]==1)));
forall(ordered d2,d1 in D) DD[d1][d2]== 1-(1<=sum(p in allP) ((x[d1][p]==1) && (x[d2][p]==1)));
}
问候