Home:ALL Converter>Python PULP Unsupported Operand Type(s) TypeError

Python PULP Unsupported Operand Type(s) TypeError

Ask Time:2019-06-12T22:45:28         Author:bathtub2007

Json Formatter

I am trying to set up some specific constraint in PULP and feel like I am missing something simple. All of the issues are all the same TypeError, showing UNSUPPORTED OPERAND between 'generator' and int or continuous.

I have tried various solutions, the code that I have is provided, although does not work.

YPER = 365
HE = 24

yearlyhours = [(i,j) for i in range(YPER) for j in range(HE)]

YAHL = pulp.LpVariable.dicts('YAHL', yearlyhours, lowBound=0, cat='Continuous')
YALL = pulp.LpVariable.dicts('YALL', yearlyhours, lowBound=0, cat='Continuous')
YAHLINT = pulp.LpVariable.dicts('YAHLINT', yearlyhours, lowBound=0, cat='Integer')
YAHLBIN = pulp.LpVariable.dicts('YAHLBIN', yearlyhours, lowBound=0, cat='Binary')

model += pulp.lpSum([YAHLINT[(i,j)] for i in range(YPER) for j in range(HE) if j >= 7 and j <= 22]) == (YAHL[i][j] for i in range(YPER) for j in range(HE) if j >= 7 and j <= 22) / 25

model += pulp.lpSum([YAHL[(i,j)] for i in range(YPER) for j in range(HE) if j >= 7 and j <= 22]) >= 0 * (YAHLBIN[i][j] for i in range(YPER) for j in range(HE) if j >= 7 and j <= 22)

TypeError: unsupported operand type(s) for /: 'generator' and 'int'

and

TypeError: unsupported operand type(s) for *: 'int' and 'generator'

Author:bathtub2007,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56564918/python-pulp-unsupported-operand-types-typeerror
yy