Cplex Python API constraint definition -


i have working mip model in cplex, wanna model in cplex python api , encountering problems. more specific, defined variables , pretty sure did correct added them in steps , first model working. however, wanna add following constraint , not quite sure how this:

sum_c( l[c][t] ) = sum_b( y[b][t]*k[b] )

hereby, l[c][t] continuous variables , y[b][t] binary variables, k[b] parameters.

i added constraint in following way know (as solved problem in cplex) outcomes not correct:

for j in range(nrtime):     thevars=[]     thecoefs=[]     b in range(nrbid):         thevars.append(y[b][j])         thecoefs.append(k[b])     in range(nrev):         thevars.append(l[i][j])         thecoefs.append(-1)     c.linear_constraints.add(lin_expr=[cplex.sparsepair(thevars, thecoefs)], senses="e", rhs=[0]) 

i'm thinking mistake in use of loops not quite sure. can tell me mistake? appreciate it.


Comments