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

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

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

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:

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!

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

2 Likes

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

Thank you again!

1 Like

Just to clarify, the suggested approaches would be:

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

or

set_objective_sense(m, MOI.FEASIBILITY_SENSE)
optimize!(m)
2 Likes

Oh, thanks! I’ve got it. :handshake: :handshake:

1 Like

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?

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.

5 Likes

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?

1 Like

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

If you want multiple optimal solutions to a MIP, see

3 Likes