# How to get a feasible point of an arbitrary optimization model?

**URL:** <https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump, optimization\
**Created:** [April 4, 2024, 10:15am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513 "2024-04-04T10:15:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 4, 2024, 10:15am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/1 "2024-04-04T10:15:30Z")

</div>

How to get a feasible point if the optimization model is not infeasible?

If the model has no objective, I can do this by:

```julia
using JuMP, HiGHS
m = Model(HiGHS.Optimizer)
@variable(m, x <= 1)
optimize!(m)
value(x)

```

But if it do have an objective, this method will no longer work:

```julia
using JuMP, HiGHS
m = Model(HiGHS.Optimizer)
@variable(m, x <= 1)
@objective(m, Min, x)
optimize!(m)
value(x)

```

In other words, I am asking how to delete the objective from a model, or directly, is there any more concise syntax in `JuMP` to check the feasibility of an objective optimization model and get one of its feasible points when it exists?

Thanks!

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 4, 2024, 11:15am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/2 "2024-04-04T11:15:38Z")

</div>

Maybe just modify the objective to zero, check for feasibility, and reset the objective back?

> **[Objectives · JuMP](https://jump.dev/JuMP.jl/stable/manual/objective/#Modify-an-objective)**
>
> Documentation for JuMP.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 4, 2024, 11:20am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/3 "2024-04-04T11:20:59Z")

</div>

OK, thanks! 🤝 I thought there was more general approaches…

Thank you again!

---

<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:** [April 4, 2024, 10:43pm UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/4 "2024-04-04T22:43:17Z")

</div>

Just to clarify, the suggested approaches would be:

```julia
@objective(m, Min, 0.0)
optimize!(m)

```

or

```julia
set_objective_sense(m, MOI.FEASIBILITY_SENSE)
optimize!(m)

```

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 5, 2024, 2:44am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/5 "2024-04-05T02:44:55Z")

</div>

Oh, thanks! I’ve got it. 🤝 🤝

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 8, 2024, 10:50am UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/6 "2024-04-08T10:50:50Z")

</div>

Hi, excuse me. May I ask how to obtain a different solution of a feasibility problem with `JuMP` after a feasible solution has been achived?

---

<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:** [April 8, 2024, 9:09pm UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/7 "2024-04-08T21:09:01Z")

</div>

JuMP and solvers like HiGHS return _a_ solution to the optimization problem that you formulate. If there are multiple solutions, there is no guarantee about which solution will be returned.

If you want to return a different solution, you must change the problem in some way. Either by adding a different objective, or by adding a new constraint that makes the previous solution infeasible.

---

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [April 18, 2024, 2:55pm UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/8 "2024-04-18T14:55:43Z")

</div>

Could you further clarify “by adding a different objective”? If we target a problem with a meaning objective (rather than a feasiblity problem), is “by adding a new constraint that makes the previous solution infeasible” the only choice?

---

<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:** [April 18, 2024, 7:44pm UTC](https://discourse.julialang.org/t/how-to-get-a-feasible-point-of-an-arbitrary-optimization-model/112513/9 "2024-04-18T19:44:10Z")

</div>

If you just care about feasible solutions then the objective doesn’t matter.

If you want multiple optimal solutions to a MIP, see

> **[Finding multiple feasible solutions](https://jump.dev/tutorials/2021/11/02/tutorial-multi-jdf/)**
>
> This tutorial demonstrates how to formulate and solve a combinatorial problem with multiple feasible solutions. In fact, we will see how to find all feasible solutions to our problem. We will also see how to enforce an “all-different” constraint on a...
