Skip to main content

Having problems modelling non-linear constraints in Gurobi

Ongoing

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Muhammad Ahsan Farooq Rajput
    • Gurobi-versary
    • First Comment
    • First Question

    Jaromił Najman please help !

    0
  • Simranjit Kaur
    • Gurobi Staff

    Hi Muhammad,

    Have you tried running the computeIIS or the feasRelax method on the infeasible model? Please see the following articles:

    Best regards,
    Simran

    0
  • Hi Simranjit, 
    I modified my code but now i am getting a key error:0 in objective function. Could you please help me ?

    import gurobipy as gp
    from gurobipy import GRB

    # Create a new Gurobi model
    model = gp.Model("production_planning")
    # Define the sizes of the sets
    i = 6
    j = 4
    m = 2

    # Create sets I, J, and M
    I = range(i)  # Parts set from 1 to i_n
    J = range(j)  # Jobs set from 1 to j_n
    M = range(m)  # Machines set from 1 to m_n
    # Define the parameters for each part
    h = {1: 25.10, 2: 37.25, 3: 39.24, 4: 4.27, 5: 13.56, 6: 2.18}  # Height of each part
    a = {1: 569.53, 2: 464.89, 3: 779.96, 4: 122.62, 5: 390.39, 6: 178.34}  # Production area of each part
    V = {1: 2867.59, 2: 2378.05, 3: 16420.91, 4: 102.83, 5: 3640.48, 6: 214.79}  # Material volume of each part

    # Define the parameters for each machine
    MC = 2  # Cost per unit volume of material
    TC = {1: 60, 2: 80}  # Operation cost per unit time for each machine
    VT = {1:0.030864, 2:0.030864} # Time for forming per unit volume of material for each machine
    HT = {1: 1.4, 2: 0.7}  # Accumulated interval time per unit height for each machine
    HC = 20  # Cost of human work per unit time
    ST = {1: 2, 2: 1}  # Setup time needed for each machine
    H = {1: 32.5, '2': 40}  # Maximum height of part that each machine can process
    A = {1: 625, 2: 1600} # Maximum production area of part that each machine can process
    #Decision variables
    X = model.addVars(j, i, vtype=GRB.BINARY, name="X")
    Y = model.addVars(m, j, vtype=GRB.BINARY, name="Y")
    Z = model.addVars(j, vtype=GRB.BINARY, name="Z")      #indicator variable
    JPC = model.addVars(m, j, lb=0.0, ub=1.0, vtype=GRB.CONTINUOUS, name="JPC")
    model.update()
    #Objective function
    model.setObjective((sum(JPC[m,j] for m in M for j in J) / sum(V[i] for i in I)), GRB.MINIMIZE

    Here in the objective function i have key error 0. 

    0

Post is closed for comments.