design of facility location problem model
Good day
i'm struggling in this model . i'm trying to define a k-center model of location of facility in wich i have a min max function object. z is the variable to minimize
the error message is :" IndexError: list index out of range"
here is the code
from gurobipy import *
import numpy as np
ex=Model()
p=1
client=['A','B','C','D','E','F']
site= ['A1','B1','C1','D1','E1','F1']
arcs,dist=multidict({('A','A1'):0,('A','B1'):13,('A','C1'):15,('A','D1'):18,('A','E1'):0,('A','F1'):0,
('B','A1'):13,('B','B1'):0,('B','C1'):0,('B','D1'):16,('B','E1'):15,('B','F1'):0,
('C','A1'):15,('C','B1'):0,('C','C1'):0,('C','D1'):22,('C','E1'):0,('C','F1'):16,
('D','A1'):18,('D','B1'):16, ('D','C1'):22,('D','D1'):0,('D','E1'):16,('D','F1'):12,
('E','A1'):0,('E','B1'):15,('E','C1'):0,('E','D1'):16,('E','E1'):0,('E','F1'):0,
('F','A1'):0,('F','B1'):0,('F','C1'):16,('F','D1'):12,('F','E1'):0,('F','F1'):0})
z=ex.addVars(vtype=GRB.CONTINUOUS)
x=ex.addVars(site,vtype=GRB.BINARY)
y=ex.addVars(client,site,vtype=GRB.BINARY)
ex.setObjective(z,GRB.MINIMIZE)
ex.addConstr(quicksum (x[s] for s in site) ==3 )
ex.addConstrs(quicksum(y[i,j] for j in site )==1 for i in client )
ex.addConstrs(y[i,j]<=x[j] for i in client for j in site )
ex.addConstrs(quicksum (dist[i,j]*y[i,j])<=z for i,j in arcs if dist[i,j]!=0 )
ex.addConstr(quicksum (x[i] for i in site) ==3 )
ex.optimize()
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
Post is closed for comments.
Comments
1 comment