# Stop Criteria using JuMP with HiGHS when find the first feasible solution

**URL:** <https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [January 31, 2024, 2:54pm UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520 "2024-01-31T14:54:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![grem](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@grem](https://discourse.julialang.org/u/grem)\
**Post date:** [January 31, 2024, 2:54pm UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520/1 "2024-01-31T14:54:49Z")

</div>

Hello,  
I have a MILP problem, which is feasible, and I would like to stop the model run when the solver find the first feasible solution. Is it possible to use a stop criteria like that?  
I can only find one about time limit  
Thanks!

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [January 31, 2024, 3:00pm UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520/2 "2024-01-31T15:00:49Z")

</div>

You can use a Feasibility objective, as described in this section:

> **[JuMP · JuMP](https://jump.dev/JuMP.jl/stable/api/JuMP/#%40objective)**
>
> Documentation for JuMP.

something like:

```julia
@objective(model, MOI.FEASIBILITY_SENSE, 0)

```

---

<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:** [January 31, 2024, 7:45pm UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520/3 "2024-01-31T19:45:40Z")

</div>

Hi @grem, welcome to the forum.

You could try setting the `mip_max_improving_sols` option:  
[https://ergo-code.github.io/HiGHS/dev/options/definitions/#mip\_max\_improving\_sols](https://ergo-code.github.io/HiGHS/dev/options/definitions/#mip_max_improving_sols)

```Julia
using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
set_attribute(model, "mip_max_improving_sols", 1)

```

---

<div class="post-metadata">

**Author:** ![grem](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@grem](https://discourse.julialang.org/u/grem)\
**Post date:** [February 5, 2024, 9:08am UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520/4 "2024-02-05T09:08:28Z")

</div>

Thank you @odow, it works! The exact syntax is:

```julia
using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
set_optimizer_attribute(model, "mip_max_improving_sols", 1)

```

---

<div class="post-metadata">

**Author:** ![grem](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@grem](https://discourse.julialang.org/u/grem)\
**Post date:** [February 5, 2024, 9:12am UTC](https://discourse.julialang.org/t/stop-criteria-using-jump-with-highs-when-find-the-first-feasible-solution/109520/6 "2024-02-05T09:12:16Z")

</div>

Thank you for your help @Dan. I don’t understand exactly what is suppose to do this option but it looks that it is going through all solutions to identify the feasible ones. It doesn’t stop at the first feasible one.
