Page 1 of 1

how to model index tied to variaible

Posted: Mon Jun 29, 2020 9:31 pm
by hong123
hello, I do an optimization to divide a network into two parts. I want to make sure that in the same partition, each node at least has one connection with the node in the same partition. My code is as below, Could anyone one help? Thanks a lot.

set k/k1*k2/
n/p1*p5/;

alias /n,j/;

Set conex 'Bus connectivity matrix'/p1.p2
p2.p3
p3.p4
p3.p5
p2.p1
p3.p2
p4.p3
p5.p3
/
;
conex(n,j)$(conex(n,j)) = 1;
variable m(n,k);

eq1(n,k).. sum(j$m(j,k), m(n,k)*conex(n,j))+ sum(n$m(j,k), m(j,k)*conex(n,j)) =g= 1