Resetting TimeLimit of Gurobi Optimizer

I am currently using JuMP with the Gurobi Solver to optimise a tournament schedule. I use a local search heuristic to try and solve each round in a given time limit after having found a first feasible solution. The problem I now face is, that it takes quite a while to find a first initial solution. Therefore my time limit is quite high. I would like to lower it before reoptimizing each round, but I could not find any examples on how to modify this parameter from the Gurobi Solver in Julia. (E.g in Java I could do the following: m.set(“TimeLimit”, “100.0”); )

Below is a very simple example, where I would like to change the time limit before the second call to optimize!().

using JuMP
using Gurobi

m = Model(with_optimizer(Gurobi.Optimizer, TimeLimit=720))
@variable(m, x[1:2] >= 0, Int)

@constraint(m, 4*x[1] <= 400)
@constraint(m, x[2] <= 120)
@constraint(m, 8*x[1] + 4*x[2] <= 1000)

@objective(m, Max, sum(24*x[1] + 20*x[2]))
optimize!(m)

@constraint(m, x[2] <= 100)
@objective(m, Max, sum(24*x[1] + 20*x[2]))
#set new TimeLimit?
optimize!(m)

It should be

MOI.set(m, MOI.RawParameter("TimeLimit"), 100.0);

but for this to work at the moment, you should checkout https://github.com/JuliaOpt/JuMP.jl/pull/2003, MOI master and https://github.com/JuliaOpt/Gurobi.jl/pull/216/. It should work with JuMP v0.20.

In JuMP v0.19, you can hack your way around with

Gurobi.setparam!(backend(m).optimizer.model.inner, "TimeLimit", 100.0)
1 Like