# User cut with JuMP and Gurobi

**URL:** <https://discourse.julialang.org/t/user-cut-with-jump-and-gurobi/86518>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, gurobi\
**Created:** [August 29, 2022, 9:39pm UTC](https://discourse.julialang.org/t/user-cut-with-jump-and-gurobi/86518 "2022-08-29T21:39:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luiz\_Monteiro](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Luiz\_Monteiro](https://discourse.julialang.org/u/Luiz_Monteiro)\
**Post date:** [August 29, 2022, 9:39pm UTC](https://discourse.julialang.org/t/user-cut-with-jump-and-gurobi/86518/1 "2022-08-29T21:39:17Z")

</div>

Hi, I am trying to insert user cuts in a mixed-integer linear programming model (Location-routing problem).  
I’m using the sintax presented in JuMP documentation ([Callbacks · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/linear/callbacks/#User-cuts)), and model in direct mode (model1 = direct\_model(Gurobi.Optimizer()).  
The model is running and it seems that callback is working, but when analyzing the output I noticed that the added constraints are not being applied effectively.  
Example: I add a constraint to avoid subtour. The output shows a solution with a subtour that should be cutted off in the first iteration remaining the same in many iterations.  
How to make cut effective in the model?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [August 29, 2022, 11:18pm UTC](https://discourse.julialang.org/t/user-cut-with-jump-and-gurobi/86518/2 "2022-08-29T23:18:57Z")

</div>

You need to use a lazy constraint, not a user cut.

See here for a TSP tutorial with subtour elimination: [Traveling Salesperson Problem · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/tsp_lazy_constraints/)

(In more detail, a user cut can only refine a fractional solution, it cannot remove integer feasible points. See the explanation and warning here: [Solver-independent Callbacks · JuMP](https://jump.dev/JuMP.jl/stable/manual/callbacks/#User-cuts))
