Having problems modelling non-linear constraints in Gurobi
OngoingHi,
I have a model that i need to optimize using Gurobi. The problem is it has non-linear constraints. I tried modelling it but i got a result from the optimizer that the model is infeasible.
0
-
Official comment
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. -
Jaromił Najman please help !
0 -
Hi Muhammad,
Have you tried running the computeIIS or the feasRelax method on the infeasible model? Please see the following articles:
- How do I determine why my model is infeasible?
- How do I use 'compute IIS' to find a subset of constraints that are causing model infeasibility?
- How do I change variable and/or constraint bounds to make an infeasible model feasible using feasRelax?
Best regards,
Simran0 -
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.MINIMIZEHere in the objective function i have key error 0.
0
Post is closed for comments.
Comments
4 comments