Struggling to formulate the objective function to the following MIP scenario in PuLP.
Each city is populated by N number of people.
Each factory location can facilitate a set of cities.
Minimize the number factories to open, such that the number of people facilitated is >= 4000
My main issue comes from the fact that different factories can service the same cities. So it isn't fair to sum the servicable population population of each factory and consider them seperately.
cities = ['London', 'Paris', 'Berlin', 'Amsterdam', 'Vienna', 'Prague']
factories = ['A', 'B', 'C', 'D']
city_populations = {'London': 898, 'Paris': 222, 'Berlin': 767, 'Amsterdam': 111, 'Vienna': 854, 'Prague': 908}
factories_service = {'A': ['London', 'Prague'], 'B': ['London', 'Paris', 'Vienna'], 'C': ['Amsterdam', 'Vienna', 'Prague'], 'D': ['London', 'Vienna', 'Prague']}
This is what I have at the moment but it is incorrect as it just picks the largest cities with no regard for population overlap.
prob = pl.LpProblem("Factory Coverage",pl.LpMinimize)
?
decision_vars = pl.LpVariable.dicts("Factories", factories, cat='Binary')
?
prob += pl.lpSum(decision_vars)
prob += pl.lpSum([sum([city_populations[x] for x in factories_service[i]])*decision_vars[i] for i in factories]) >= 4000
?
?
prob.solve()
Output:
Factories_A, 0.0
Factories_B, 1.0
Factories_C, 0.0
Factories_D, 1.0