2

I am trying to run a minimization problem for an MIP using Gurobi in Julia. I would like it to stop after it has found a solution that is below a certain threshold that I have set. I have found ways online to do this in other programming languages, but nothing helpful for Julia. For various reasons, I cannot just use an MIP Gap setting either.

Is there a way to do this in Julia?

I tried finding solutions to this in other programming languages that Julia offers guides for, but they did not work.

Sun Lee
  • 21
  • 1

1 Answers1

0

Normally you budget on solution time rather than the quality, so typically in your code you would have:

set_optimizer_attribute(mo, "TimeLimit", 60) # Gurobi terminates after one minute

As far as I know, Gurobi does not have a parameter for "good enough" goal function value. You could however consider changing the goal function into a constraint such as:

@variable(m, x >= 0)
@variable(m, y >= 0)
@variable(m, b >=0 )


@constraint(m, 3*x + 2*y <= 500 + b)
@objective(m, Min, b)

In this example I assume we minimize 3*x + 2*y and we consider the value of 500 to be "good enough".

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • What does the third argument in the objective do? – graphtheory123 Mar 18 '23 at 00:40
  • `m` is the JuMP `Model`, `Min` means minimization and `b` is the goal function. You minimize the value of `b`. `b` represents how far the actual function `3*x + 2*y` differs from 500. `500` is a sample "good enough" value - "a solution that is below a certain threshold that I have set" – Przemyslaw Szufel Mar 18 '23 at 12:44
  • *Normally you budget on solution time rather than the quality* No. Using a gap criterion is very common. – Erwin Kalvelagen May 01 '23 at 04:33