ok there is a little thing to remember that pulp.LpVariable.dicts
generates dictionaries of dictionaries so the following is possible
>>> import pulp
>>> docs = ['a','b','c']
>>> days = ['mon','tue', 'wed']
>>> shifts = [0,1,2,3]
>>> x = pulp.LpVariable.dicts('x',(docs,days,shifts),0,1,pulp.LpInteger)
>>> x['a']['mon'][3]
x_a_mon_3
but the numpy array can only index by integers so the following is required.
>>> import pulp
>>> docs = [0,1,2]
>>> days = [0,1,2,3,4]
>>> shifts = [0,1,2,3]
>>> x = pulp.LpVariable.matrix('x',(docs,days,shifts),0,1,pulp.LpInteger)
>>> x[1][1][2]
x_1_1_2
>>> c = numpy.zeros((len(docs),len(days),len(shifts)))
>>> c[1][1][2]
0.0
>>> c[(1,1,2)]
0.0
>>> pulp.lpSum([c[doc][day][shift] * x[doc][day][shift]
... for doc in docs
... for day in days
... for shift in shifts])
0
Note the solution expression is zero as the c matrix is all zero
Stu
--
___________________________________
Dr Stuart Mitchell
Research Fellow
Light Metals Research Centre (LMRC)
University of Auckland
Private Bag 92019
Auckland
New Zealand
Ph (wk)
+64 9 3737599 ext 84867
(ddi)
+64 9 9234867
(fax)
+64 9 3737925
(mb)
+64 21 441331
___________________________________