Using the default parameters:
julia> using JuMP, Gurobi
julia> model = Model(Gurobi.Optimizer)
Set parameter LicenseID to value 890341
A JuMP Model
├ solver: Gurobi
├ objective_sense: FEASIBILITY_SENSE
├ num_variables: 0
├ num_constraints: 0
└ Names registered in the model: none
julia> @variable(model, x == 1)
x
julia> @variable(model, y)
y
julia> @constraint(model, c, x * y <= 1)
c : x*y ≤ 1
julia> @objective(model, Max, y)
y
julia> optimize!(model)
Gurobi Optimizer version 12.0.1 build v12.0.1rc0 (mac64[x86] - Darwin 24.1.0 24B83)
CPU model: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 0 rows, 2 columns and 0 nonzeros
Model fingerprint: 0x1be0693c
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [0e+00, 0e+00]
QMatrix range [1e+00, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [1e+00, 1e+00]
RHS range [0e+00, 0e+00]
QRHS range [1e+00, 1e+00]
Presolve removed 0 rows and 1 columns
Presolve time: 0.00s
Presolved: 1 rows, 1 columns, 1 nonzeros
Ordering time: 0.00s
Barrier statistics:
AA' NZ : 0.000e+00
Factor NZ : 1.000e+00
Factor Ops : 1.000e+00 (less than 1 second per iteration)
Threads : 1
Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 1.00500000e+00 1.51017673e+00 5.00e-03 5.00e-01 2.12e-01 0s
1 9.76922662e-01 1.00464675e+00 0.00e+00 0.00e+00 2.77e-02 0s
2 9.99966338e-01 1.00251942e+00 0.00e+00 0.00e+00 2.55e-03 0s
3 9.99996273e-01 1.00000251e+00 0.00e+00 0.00e+00 6.24e-06 0s
4 9.99999996e-01 1.00000000e+00 0.00e+00 0.00e+00 6.24e-09 0s
Barrier solved model in 4 iterations and 0.00 seconds (0.00 work units)
Optimal objective 9.99999996e-01
User-callback calls 45, time in user-callback 0.00 sec
shows
Presolve removed 0 rows and 1 columns
Presolve time: 0.00s
Presolved: 1 rows, 1 columns, 1 nonzeros
so Gurobi did remove the x
variable.
You can also see this with
julia> begin
model = direct_model(Gurobi.Optimizer())
set_silent(model)
@variable(model, x == 1)
@variable(model, y)
@constraint(model, c, x * y <= 1)
@objective(model, Max, y)
optimize!(model)
grb = backend(model)
presolvedP = Ref{Ptr{Cvoid}}(C_NULL)
GRBpresolvemodel(grb, presolvedP)
GRBwrite(presolvedP[], "presolved.lp")
print(read("presolved.lp", String))
end
Set parameter LicenseID to value 890341
\ Model _pre
\ LP format - for model browsing. Use MPS format to capture full model detail.
\ Signature: 0x5af67735cda1dc02
Maximize
y
Subject To
R0: y <= 1
Bounds
y free
End
And we find that it still uses the barrier algorithm (which is not supposed to be invoked on small-scale LPs
You cannot assume this. In the default parameter setting, Gurobi may choose any method to solve the problem.