• Gurobi Staff

Hi,

Could you elaborate more on what actually you are trying to model in your problem? Are $$\texttt{tau_m}$$ constant values? Are these positive? In best case, please provide a small example showing one constraint you are trying to produce. Could you share your code where you try to implement the constraints?

Best regards,
Jaromił

I am trying to model recurring vehicle visits to the same location. For each visit at a specific location, the vehicle has an entry and an exit node and for these nodes, the corresponding times are known. My problem is that I need to find the combination of entry and exit time for each visit.

Let's say the set Tau is the entry time and set T is the exit time. There is no direct relation between the entry and the exit nodes indices, so my strategy was to, for each value of Tau, take the minimum value of the the values of variable T, which should obviously be larger than tau and 0. This would then match the correct exit time with a certain entry time.

Both Tau and T are positive, integer decision variables.

• Gurobi Staff

Hi,

You could try starting from this point

import gurobipy as gpfrom gurobipy import GRBm = gp.Model("myModel")[...]indices = [0,1,2,3]T = m.addVars(indices,vtype=GRB.INTEGER, lb=1, ub = 10, name="T")tau_m = m.addVars(indices,vtype=GRB.INTEGER, lb=0, ub = 9, name="tau_m")a = m.addVars(indices,vtype=GRB.INTEGER,lb=1,ub=10,name="a")m.addConstrs((a[i] == gp.min_(T[j] for j in indices) for i in indices ),"min_constraints")m.addConstrs((a[i] >= tau_m[i]+1 for i in indices),"tau_constraints")[...]m.write("myMIP.lp")

Note that strict inequalities are not allowed in (mixed-integer) linear programming due to compactness assumptions. Thus, when the $$\texttt{tau}$$ variables are integer, you can use a $$\geq$$ relation. If the $$\texttt{tau}$$ variables are continuous, you can add a small $$\epsilon$$ to it instead of $$1$$. Obviously, you have to adjust the lower and upper bounds of the variables to fit our actual problem, but I think the above should provide you a good starting point. You can use the $$\texttt{write}$$ function to write the problem to a readable format, $$\texttt{myMIP.lp}$$ in the above case, and analyze whether the constraints are the ones you have in mind.

Best regards,
Jaromił

Thanks for your response. This was also my initial approach. However, this method proves to be unfeasible. Most likely the min constraint is incompatible with the inequality constraint because the minimum constraint only outputs the absolute minimum value in the set.

Is there a way to circumvent this by first determining the set of decision variables that satisfy the inequality constraints and then parsing that set to the minimum constraint?

• Gurobi Staff

Hi,

Regarding the infeasibility, you could try to determine which (in)equalities make your problem infeasible. From there on, you could try adapting your model. The Knowledge Base article How do I determine why my model is infeasible? should be helpful in this case.

You could also try to model the conditions with an additional binary variable and indicator constraints.

Best regards,
Jaromił