Facility Location code for COMPSCI 690AA: Approximation Algorithms
Pre-requisites: Numpy, Scipy and PuLP
To use this code:
- import facility
- Create a facility location problem instance by
F = Facility_Location(facility_costs,demand_costs)
. Here,facility_costs
are the costs for setting up facilities anddemand_costs
are the costs for a facility to service a particular client.demand_costs[j][i]
is the cost of facilityi
to service clientj
. - Call
F.solve_LP()
. This does not return anything. It just solves the LP and gets the primal and dual variables. - Call
F.Deterministic_rounding()
to use deterministic rounding andF.Random_rounding()
for random rounding. These return a dictionary which represents the assignment. - Use
F.cost(assignment)
to get the cost of an assignment. F.ILP()
solves the problem exactly, using integer linear programming. It returns the optimal assignment. It can be used to compare the rounded solutions with the optimal one.