lingo求解
model:
sets:
var/1..6/:x;
col/1..8/;
link(var,col):c;
endsets
data:
c=1 0 0 0 1 0 1 0
1 1 0 0 1 0 0 1
1 0 1 0 1 0 0 0
0 1 0 1 0 0 0 1
0 0 1 0 0 1 0 0
0 0 0 1 0 1 0 1;
enddata
min=@sum(var:x);
@for(col(j):@sum(var(i):c(i,j)*x(i))>1);
@for(var:@bin(x));
改进后:
x(i) 取1,表示在bi建学校
a1可以被备选地址b1,b2,b3所覆盖,所以x1+x2+x3>=1
model:
sets:
var/1..6/:x;
endsets
x(1)+x(2)+x(3)>1;
x(2)+x(4)>1;
x(3)+x(5)>1;
x(4)+x(6)>1;
x(5)+x(6)>1;
x(1)>1;
x(2)+x(4)+x(6)>1;
min=@sum(var:x);
@for(var:@bin(x));