Can you provide a reproducible example? Which solver?
For example, this works:
julia> using JuMP, HiGHS
julia> function milprog(c, A, sense, b, l, u, vartype, solver)
m, n = size(A)
@assert length(sense) == length(b) == m
@assert length(c) == length(l) == length(u) == length(vartype) == n
model = Model(solver)
@variable(model, l[i] <= x[i in 1:n] <= u[i], binary = (vartype[i] == :Bin))
@objective(model, Min, c' * x)
for i in 1:m
if sense[i] == '='
@constraint(model, A[i, :]' * x == b[i])
elseif sense[i] == '>'
@constraint(model, A[i, :]' * x >= b[i])
else
@assert sense[i] == '<'
@constraint(model, A[i, :]' * x <= b[i])
end
end
optimize!(model)
if !is_solved_and_feasible(model)
return (; status = termination_status(model),)
end
return (;
status = termination_status(model),
objval = objective_value(model),
sol = value.(x),
)
end
milprog (generic function with 1 method)
julia> milprog(
[12, 20],
[6 8; 7 12],
['>', '>'],
[100, 120],
[0, 0],
[Inf, 3],
[:Cont, :Bin],
HiGHS.Optimizer
)
Running HiGHS 1.8.1 (git hash: 4a7f24ac6): Copyright (c) 2024 HiGHS under MIT licence terms
Coefficient ranges:
Matrix [6e+00, 1e+01]
Cost [1e+01, 2e+01]
Bound [1e+00, 1e+00]
RHS [1e+02, 1e+02]
Presolving model
2 rows, 2 cols, 4 nonzeros 0s
2 rows, 2 cols, 4 nonzeros 0s
Solving MIP model with:
2 rows
2 cols (1 binary, 0 integer, 0 implied int., 1 continuous)
4 nonzeros
MIP-Timing: 0.0024 - starting analytic centre calculation
Src: B => Branching; C => Central rounding; F => Feasibility pump; H => Heuristic; L => Sub-MIP;
P => Empty MIP; R => Randomized rounding; S => Solve LP; T => Evaluate node; U => Unbounded;
z => Trivial zero; l => Trivial lower; u => Trivial upper; p => Trivial point
Nodes | B&B Tree | Objective Bounds | Dynamic Constraints | Work
Src Proc. InQueue | Leaves Expl. | BestBound BestSol Gap | Cuts InLp Confl. | LpIters Time
0 0 0 0.00% 185.1428571 inf inf 0 0 0 0 0.0s
T 0 0 0 0.00% 185.1428571 205.1428571 9.75% 0 0 0 1 0.0s
1 0 1 100.00% 205.1428571 205.1428571 0.00% 0 0 0 1 0.0s
Solving report
Status Optimal
Primal bound 205.142857143
Dual bound 205.142857143
Gap 0% (tolerance: 0.01%)
P-D integral 6.90514725065e-07
Solution status feasible
205.142857143 (objective)
0 (bound viol.)
0 (int. viol.)
0 (row viol.)
Timing 0.00 (total)
0.00 (presolve)
0.00 (solve)
0.00 (postsolve)
Max sub-MIP depth 0
Nodes 1
Repair LPs 0 (0 feasible; 0 iterations)
LP iterations 1 (total)
0 (strong br.)
0 (separation)
0 (heuristics)
(status = MathOptInterface.OPTIMAL, objval = 205.14285714285714, sol = [15.428571428571429, 1.0])