【问题标题】:I don't know how can I write the below conditions in CPLEX?我不知道如何在 CPLEX 中编写以下条件?
【发布时间】:2018-05-01 00:27:49
【问题描述】:

∀ 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;

【问题讨论】:

    标签: optimization conditional-statements cplex


    【解决方案1】:

    你可以使用逻辑约束:

    {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)));
    }
    

    【讨论】:

      【解决方案2】:

      以下内容对您有帮助吗?

      {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));
      

      【讨论】:

      • 谢谢,当需求 i 和 j 至少有一个公共链接时,我想设置 D[demand_i][demnand_j]=1 和 D[demand_j][demnand_i]=0 。不幸的是,我没有对约束应用正确的条件。更新一些信息,如果可以的话,谢谢你的考虑
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-26
      • 1970-01-01
      • 2016-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多