import JuMP
import Gurobi
function objf(x, y) return (y - 2)^2/4 - x * y end
B = JuMP.Model(() -> Gurobi.Optimizer()); # A bilinear program
JuMP.@variable(B, 0 <= x <= 1);
JuMP.@variable(B, y); # this variable is free
JuMP.@objective(B, Min, objf(x, y));
JuMP.optimize!(B);
JuMP.termination_status(B) # DUAL_INFEASIBLE
# julia> println(B)
# Min 0.25 y² - x*y - y + 1
# Subject to
# x >= 0
# x <= 1
# Comment: Theoretically speaking, The program is bounded below because 0.25 is positive
# And this can be reflected by visualizing
using CairoMakie
f = Figure();
Axis(f[1, 1]);
xs = LinRange(0, 1, 100);
ys = LinRange(-3, 8, 100);
zs = [objf(x, y) for x in xs, y in ys];
contour!(xs, ys, zs; labels=true, levels = -4:0.5:4);
f
Run the above code in julia REPL:
julia> import JuMP
julia> import Gurobi
julia> function objf(x, y) return (y - 2)^2/4 - x * y end
objf (generic function with 1 method)
julia> B = JuMP.Model(() -> Gurobi.Optimizer());
Set parameter Username
Set parameter LicenseID to value 2602363
Academic license - for non-commercial use only - expires 2025-12-20
julia> JuMP.@variable(B, 0 <= x <= 1);
julia> JuMP.@variable(B, y);
julia> JuMP.@objective(B, Min, objf(x, y));
julia> JuMP.optimize!(B);
Gurobi Optimizer version 12.0.1 build v12.0.1rc0 (win64 - Windows 11.0 (26100.2))
CPU model: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz, instruction set [SSE2|AVX|AVX2|AVX512]
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: 0x64a2e73d
Model has 2 quadratic objective terms
Coefficient statistics:
Matrix range [0e+00, 0e+00]
Objective range [1e+00, 1e+00]
QObjective range [5e-01, 2e+00]
Bounds range [1e+00, 1e+00]
RHS range [0e+00, 0e+00]
Continuous model is non-convex -- solving as a MIP
Found heuristic solution: objective 1.0000000
Found heuristic solution: objective 0.8925000
Presolve time: 0.00s
Presolved: 3 rows, 7 columns, 8 nonzeros
Presolved model has 2 SOS constraint(s)
Presolved model has 1 quadratic constraint(s)
Found heuristic solution: objective 0.8025000
Variable types: 5 continuous, 2 integer (2 binary)
Root relaxation: unbounded, 1 iterations, 0.00 seconds (0.00 work units)
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 postponed 0 0.80250 - - - 0s
0 0 postponed 0 0.80250 - - - 0s
0 0 postponed 0 0.80250 - - - 0s
0 2 postponed 0 0.80250 - - - 0s
Explored 3 nodes (7 simplex iterations) in 0.02 seconds (0.00 work units)
Thread count was 8 (of 8 available processors)
Solution count 3: 0.8025 0.8925 1
Model is unbounded
Best objective 8.025000000000e-01, best bound 8.025000000000e-01, gap 0.0000%
User-callback calls 123, time in user-callback 0.00 sec