Hello Nicholas,
I'm a bit puzzled...
You model does not have any decision variables! Therefore, you are attempting to create constraints on constant expressions.
In that case, there are interpreted as "always true" or "always false", depending on the expression, and no optimization is needed at all...
I think you should start you modelling effort by clearly stating what are the decision variables in your problem, and then start implementing constraints based on these decision variables.
It might be a good idea to look at a few sample models to get some insights.
I hope this helps,
Kind regards,
Hugues
------------------------------
Hugues Juille
------------------------------
Original Message:
Sent: Wed July 06, 2022 09:48 PM
From: Nicholas Nicholas
Subject: DOcplexException: Adding a trivially infeasible constraint
Dear All,
Good day to you.
When I run this code, I got error message: DOcplexException: Adding a trivially infeasible constraint .
Can anyone help me, please? thank you in advance.
Here is the 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]])
AT = AT.tolist()
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]])
Z = Z.tolist()
Total_P = 8
Total_T = 6
ATZ = np.empty((Total_P), dtype = object)
ATZ = ATZ.tolist()
for l in range(Total_P):
for i in range(Total_T):
ATZ[l] = np.matmul(AT,Z[i])
M = np.empty((Total_P),dtype = object)
M = M.tolist()
for k in range(Total_K):
M_prev = M[:].copy()
for k in range(Total_K):
for l in range(Total_P):
if M != None and M_prev != None:
mdl.add_constraint(M == M_prev + ATZ)
Error: Adding trivially infeasible constraint: '', pos: 5761
/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: Adding a trivially infeasible constraint
------------------------------
Nicholas Nicholas
------------------------------
#DecisionOptimization