mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 00:18: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
|
log_should_print = false
|
||||||
|
|
||||||
if round > 1
|
if round > 1
|
||||||
@timeit "Update objective function" begin
|
@timeit "Build Lagrangian term" begin
|
||||||
# Build Lagrangian term
|
@timeit "mul" begin
|
||||||
v = sparse(pool.lhs * multipliers_curr)
|
active_idx = findall(multipliers_curr .> 1e-6)
|
||||||
lagr_term = AffExpr(dot(multipliers_curr, pool.lb))
|
v = sparse(pool.lhs[:, active_idx] * multipliers_curr[active_idx])
|
||||||
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
|
||||||
|
@timeit "dot" begin
|
||||||
# Update objective
|
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(
|
set_objective_function(
|
||||||
model_s,
|
model_s,
|
||||||
orig_obj_s + lagr_term,
|
orig_obj_s + lagr_term,
|
||||||
|
|||||||
Reference in New Issue
Block a user