mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 16:38:51 -06:00
FisSal2011: Accelerate creation of obj function
This commit is contained in:
@@ -389,20 +389,26 @@ function collect_gmi_FisSal2011(
|
||||
log_should_print = false
|
||||
|
||||
if round > 1
|
||||
@timeit "Update objective function" begin
|
||||
# Build Lagrangian term
|
||||
v = sparse(pool.lhs * multipliers_curr)
|
||||
lagr_term = AffExpr(dot(multipliers_curr, pool.lb))
|
||||
for offset in 1:nnz(v)
|
||||
var_idx = v.nzind[offset]
|
||||
add_to_expression!(
|
||||
lagr_term,
|
||||
vars_s[var_idx],
|
||||
- v.nzval[offset],
|
||||
)
|
||||
@timeit "Build Lagrangian term" begin
|
||||
@timeit "mul" begin
|
||||
active_idx = findall(multipliers_curr .> 1e-6)
|
||||
v = sparse(pool.lhs[:, active_idx] * multipliers_curr[active_idx])
|
||||
end
|
||||
|
||||
# Update objective
|
||||
@timeit "dot" begin
|
||||
lagr_term = AffExpr(dot(multipliers_curr, pool.lb))
|
||||
end
|
||||
@timeit "add_to_expression!" begin
|
||||
for offset in 1:nnz(v)
|
||||
var_idx = v.nzind[offset]
|
||||
add_to_expression!(
|
||||
lagr_term,
|
||||
vars_s[var_idx],
|
||||
- v.nzval[offset],
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@timeit "Update objective" begin
|
||||
set_objective_function(
|
||||
model_s,
|
||||
orig_obj_s + lagr_term,
|
||||
|
||||
Reference in New Issue
Block a user