Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  DOcplexException: Adding a trivially infeasible constraint

    Posted Wed July 06, 2022 09:49 PM
    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


  • 2.  RE: DOcplexException: Adding a trivially infeasible constraint

    Posted Thu July 07, 2022 05:06 AM
    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
    ------------------------------



  • 3.  RE: DOcplexException: Adding a trivially infeasible constraint

    Posted Thu July 07, 2022 10:05 PM
    Dear Hugues,
    Thank you for your reply.

    The constraint which involves the constant expression is what I got a paper which I am currently exploring. Based on your experiences, what should we do when we deal with a constant expression by using CPLEX library?
    Should we put the calculation outside the CPLEX library then load them into the CPLEX later?

    Secondly, do you any website or source which I could explore further about Mixed Integer Linear Programming modelling by using CPLEX library in python, especially for scheduling case?

    Thank you so much.

    Best regards,
    Nicholas

    ------------------------------
    Nicholas Nicholas
    ------------------------------