I am trying to convert a variable name function I wrote for a smaller set of data to a larger one and have run across a problem of creating duplicate variable names because of the size of the set. I need unique variable names created in this step because they are used as part of a constraint later.
The problem code is:
n_counties = 102
n_districts = 17
model = LpProblem("Supply-Demand-Problem", LpMinimize) # create model
variable_names = [str(i)+str(j) for j in range(1, n_districts+1) for i in range(1, n_counties+1)]
This code currently creates 70 duplicate variable names.
I am trying to create a set that does the same thing (create a new variable name for each combination of county and district) but doesn't create any duplicate variables. Is is possible to do this by incrementing by letters instead or random integers? Any help or suggestions you have are welcome! Thanks! :)