2015-05-04 115 views
-1

你好,我正在这个整数编程。如何解决这个整数编程?

我现在的工作,直到有:

Decision Variable: 
Yi = 1 if the ambulances located in region i, 
Yi = 0 otherwises 




Objective: maximize the no. of resident that can be reached within 5 
mins, Z = 

Y1(43+45)+Y2(52+58)+Y3(45+58)+.......+Y8(52+45+58+58) 

43 + 45,无。如果救护车位于Y1,则可在5分钟内到达Y1和Y5的居民。

Constraints: Y1+Y2+Y3+...+Y8 = 2 (only two locations) 

然后,我不知道应该怎样加入约束,目标似乎是错误的...

可能有人帮助我吗?谢谢!

enter image description here

+1

你的问题对我来说很不清楚。 – moffeltje

+0

你打算只使用Excel还是一般编程? –

+0

@moffeltje请问为什么有这样的说法? –

回答

1

如果你是好与一般的编程,这里是用Python实现。

Y = [{}]*100 
Y[1]={1:43, 5:45} 
Y[2]={2:52, 8:58} 
Y[3]={3:45, 6:58} 
Y[4]={4:40, 5:45} 
Y[5]={1:43, 5:45, 4:40, 8:58} 
Y[6]={3:45, 6:58, 7:44, 8:58} 
Y[7]={6:58, 7:44} 
Y[8]={2:52, 5:45, 6:58, 8:58} 

result = {'loc1':0, 'loc2': 0, 'total':0} 
for i in range(1, 9): 
    for j in range (i + 1, 9): 
     Y[i * 10 + j] = Y[i].copy() 
     Y[i * 10 + j].update(Y[j]) 
     total = 0 
     for key in Y[i * 10 + j]: 
      total += Y[i * 10 + j][key] 
     if total > result['total']: 
      result['loc1'] = i 
      result['loc2'] = j 
      result['total'] = total 
     print i, " ", j, " ", total 

print result