Dear All,
Good day to you.
When I create a constraint by using Cplex library (python), I got error message:
DOcplexException: Model.sum() expects numbers/variables/expressions, got: [1 0 0 0 0 0].
Is there anyone could help me, please? Thank you in advance.
Here is the python code.
###
AT =np.array([[1,-1,0,0,0,0],
[0,1,-1,0,0,0],
[0,-1,1,0,0,0],
[0,0,1,-1,0,0],
[0,0,0,1,-1,0],
[0,0,0,-1,1,0],
[0,0,0,0,1,-1],
[-1,1,-1,1,-1,1]])
Z =np.array ([[1,0,0,0,0,0],
[0,1,0,0,0,0],
[0,0,1,0,0,0],
[0,0,0,1,0,0],
[0,0,0,0,1,0],
[0,0,0,0,0,1]])
ATZ = np.empty((Total_P), dtype = object)
for l in range(Total_P):
ATZ[t] = np.matmul(AT,Z[t])
M = np.empty((Total_P),dtype = object)
for k in range(Total_K):
M_prev = M[:].copy()
for k in range(720):
for l in range(8):
if M.any() != None and M_prev.any() != None:
mdl.add_constraint(M = M_prev + ATZ)
/usr/local/lib/python3.7/dist-packages/docplex/mp/error_handler.py
in fatal(self, msg, args)
208 resolved_message = resolve_pattern(msg, args)
209 docplex_error_stop_here()
--> 210 raise DOcplexException(resolved_message)
211
212 def fatal_limits_exceeded(self, nb_vars, nb_constraints):
DOcplexException: Model.sum() expects numbers/variables/expressions, got: [1 0 0 0 0 0]
------------------------------
Nicholas Nicholas
------------------------------
#DecisionOptimization