我不知道如何在 CPLEX 中编写 (i ∈ V^a∪ V^s) 以下条件?
Posted
技术标签:
【中文标题】我不知道如何在 CPLEX 中编写 (i ∈ V^a∪ V^s) 以下条件?【英文标题】:I don't know how can I write (i ∈ V^a∪ V^s) the below conditions in CPLEX? 【发布时间】:2021-10-03 16:36:50 【问题描述】:∑((i,j ∈A_2) )(x_ij)+∑_((i,j,k)∈A_3)(y_ijk) = 1, i ∈ V^a∪ V^s
V^a和V^s的交集不知道怎么写,对吗?
int Arr_node;
int Loco_start;
int Exp1= Arr_node inter Loco_start;
Forall(i in Exp1)(sum(<i,j> in A2)x[<i,j>]) + (sum(<i,j,k> in A3)y[<i,j,k>]) == 1;
【问题讨论】:
【参考方案1】:你可以使用 inter 或 &&
见
string cities="A","B","C";
string departures="A","B";
string arrivals="B","C";
dvar boolean x[cities];
string bothdepandarr=departures inter arrivals;
minimize sum(c in cities) x[c];
subject to
forall(c in bothdepandarr) x[c]==1;
或
string cities="A","B","C";
string departures="A","B";
string arrivals="B","C";
dvar boolean x[cities];
minimize sum(c in cities) x[c];
subject to
forall(c in departures inter arrivals) x[c]==1;
或
string cities="A","B","C";
string departures="A","B";
string arrivals="B","C";
dvar boolean x[cities];
minimize sum(c in cities) x[c];
subject to
forall(c in cities : c in departures && c in arrivals) x[c]==1;
【讨论】:
以上是关于我不知道如何在 CPLEX 中编写 (i ∈ V^a∪ V^s) 以下条件?的主要内容,如果未能解决你的问题,请参考以下文章
在 Linux 上的 Eclipse C++ 中设置 CPLEX
如何在 Cplex (java) 中添加关于 argmax o min 的约束?
CPLEX OPL ERROR RUNTIME:不要键入 lloType ,