When creating a collection of LpVariables using the class method dicts, using an index that is a list of tuples in order to emulate a matrix it only work when the name does not contain a '%'
What did you do?
i1 = list(range(10))
i2 = list('abcdefghij')
i3 = 'jan feb mar apr may jun jul aug sep oct'.split()
indices = [(a, b, c) for a in i1 for b in i2 for c in i3]
P = pl.LpVariable.dicts('P', indices=indices)
P[0, 'a', 'jan']
Details for the issue
When creating a collection of LpVariables using the class method dicts, using an index that is a list of tuples in order to emulate a matrix it only work when the name does not contain a '%'
What did you do?
i1 = list(range(10)) i2 = list('abcdefghij') i3 = 'jan feb mar apr may jun jul aug sep oct'.split() indices = [(a, b, c) for a in i1 for b in i2 for c in i3]
P = pl.LpVariable.dicts('P', indices=indices) P[0, 'a', 'jan']
What did you expect to see?
I was expecting to see: P_(0, 'a', 'jan')
What did you see instead?
P(0,'a',_'jan')
Which is a weird looking name