I don't know how can I write (i ∈ V^a∪ V^s) the below conditions in CPLEX?

44 views Asked by At

∑((i,j ∈A_2) )(x_ij)+∑_((i,j,k)∈ A_3)(y_ijk) = 1, i ∈ V^a∪ V^s

I don't know how to write the intersection of V^a and V^s on for all, is that correct?

{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

There are 1 answers

0
Alex Fleischer On

You may use inter or &&

See

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

or

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

or

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