mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 00:18:51 -06:00
gmi_dual: Accelerate build_expr
This commit is contained in:
@@ -348,6 +348,14 @@ end
|
|||||||
function add_constraint_set_dual_v2(model::JuMP.Model, cs::ConstraintSet)
|
function add_constraint_set_dual_v2(model::JuMP.Model, cs::ConstraintSet)
|
||||||
vars = all_variables(model)
|
vars = all_variables(model)
|
||||||
nrows, ncols = size(cs.lhs)
|
nrows, ncols = size(cs.lhs)
|
||||||
|
|
||||||
|
@timeit "Transpose LHS" begin
|
||||||
|
lhs_t = spzeros(ncols, nrows)
|
||||||
|
ftranspose!(lhs_t, cs.lhs, x -> x)
|
||||||
|
lhs_t_rows = rowvals(lhs_t)
|
||||||
|
lhs_t_vals = nonzeros(lhs_t)
|
||||||
|
end
|
||||||
|
|
||||||
constrs = []
|
constrs = []
|
||||||
gmi_exps = []
|
gmi_exps = []
|
||||||
for i = 1:nrows
|
for i = 1:nrows
|
||||||
@@ -355,7 +363,10 @@ function add_constraint_set_dual_v2(model::JuMP.Model, cs::ConstraintSet)
|
|||||||
gmi_exp = nothing
|
gmi_exp = nothing
|
||||||
gmi_exp2 = nothing
|
gmi_exp2 = nothing
|
||||||
@timeit "Build expr" begin
|
@timeit "Build expr" begin
|
||||||
expr = @expression(model, sum(cs.lhs[i, j] * vars[j] for j = 1:ncols))
|
expr = AffExpr()
|
||||||
|
for k in nzrange(lhs_t, i)
|
||||||
|
add_to_expression!(expr, lhs_t_vals[k], vars[lhs_t_rows[k]])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@timeit "Add constraints" begin
|
@timeit "Add constraints" begin
|
||||||
if isinf(cs.ub[i])
|
if isinf(cs.ub[i])
|
||||||
|
|||||||
Reference in New Issue
Block a user