Skip to content

Commit 527bd54

Browse files
committed
renaming and spaces
1 parent c52d974 commit 527bd54

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

src/mbm.jl

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ function _reformulate_disjunct(
4646
!haskey(_indicator_to_constraints(model), lvref) && return
4747
# Filter out deactivated disjuncts from binary variable mapping in
4848
# the event we've identified some infeasible disjuncts already
49-
active_subproblem_indicators = filter(d -> !(d in method.deactivated), method.subproblem_indicators)
49+
active_subproblem_indicators = filter(
50+
d -> !(d in method.deactivated),
51+
method.subproblem_indicators
52+
)
5053
bconref = Dict(d => binary_variable(d) for d in active_subproblem_indicators)
5154

5255
constraints = _indicator_to_constraints(model)[lvref]
@@ -83,7 +86,8 @@ function _reformulate_disjunct(
8386
# Check if all M values are zero for that constraint. If so, it
8487
# should be enforced globally (no reformulation with binaries).
8588
if !isempty(method.M) && all(
86-
_is_all_zeros(method.M[d]) for d in keys(method.M))
89+
_is_all_zeros(method.M[d]) for d in keys(method.M)
90+
)
8791
push!(ref_cons, con)
8892
else
8993
append!(ref_cons,
@@ -290,11 +294,6 @@ function _raw_M(
290294
M_vals = typeof(method.default_M)[]
291295
for obj_expr in objectives
292296
JuMP.@objective(sub.model, Max, obj_expr)
293-
# Clear start values before each solve to prevent NaN
294-
# residue from a previous non-feasible solve
295-
for v in JuMP.all_variables(sub.model)
296-
JuMP.set_start_value(v, nothing)
297-
end
298297
JuMP.optimize!(sub.model)
299298
if JuMP.termination_status(sub.model) == _MOI.INFEASIBLE
300299
return nothing
@@ -367,11 +366,13 @@ function _maximize_M(
367366
set_value = objective.set.value
368367
ge_obj = JuMP.ScalarConstraint(objective.func, MOI.GreaterThan(set_value))
369368
le_obj = JuMP.ScalarConstraint(objective.func, MOI.LessThan(set_value))
370-
raw_lower = _raw_M(sub,prepare_objectives(model, ge_obj, sub),method)
371-
raw_upper = _raw_M(sub,prepare_objectives(model, le_obj, sub),method)
369+
raw_lower = _raw_M(sub, prepare_objectives(model, ge_obj, sub), method)
370+
raw_upper = _raw_M(sub, prepare_objectives(model, le_obj, sub), method)
372371
(raw_lower === nothing || raw_upper === nothing) &&
373372
return nothing
374-
return [aggregate_M_values(model, raw_lower),aggregate_M_values(model, raw_upper)]
373+
return [aggregate_M_values(model, raw_lower),
374+
aggregate_M_values(model, raw_upper)
375+
]
375376
end
376377

377378
# Interval: solve both lower and upper bound directions, finalize each.
@@ -387,11 +388,14 @@ function _maximize_M(
387388
MOI.GreaterThan(set_values[1]))
388389
le_obj = JuMP.ScalarConstraint(objective.func,
389390
MOI.LessThan(set_values[2]))
390-
raw_lower = _raw_M(sub,prepare_objectives(model, ge_obj, sub),method)
391-
raw_upper = _raw_M(sub,prepare_objectives(model, le_obj, sub),method)
391+
raw_lower = _raw_M(sub, prepare_objectives(model, ge_obj, sub), method)
392+
raw_upper = _raw_M(sub, prepare_objectives(model, le_obj, sub), method)
392393
(raw_lower === nothing || raw_upper === nothing) &&
393394
return nothing
394-
return [aggregate_M_values(model, raw_lower),aggregate_M_values(model, raw_upper)]
395+
return [
396+
aggregate_M_values(model, raw_lower),
397+
aggregate_M_values(model, raw_upper)
398+
]
395399
end
396400

397401
# Nonpositives: per-row LessThan solves for each dimension of the vector.
@@ -407,7 +411,7 @@ function _maximize_M(
407411
for i in 1:objective.set.dimension
408412
le_obj = JuMP.ScalarConstraint(
409413
objective.func[i], MOI.LessThan(zero(val_type)))
410-
raw = _raw_M(sub,prepare_objectives(model, le_obj, sub),method)
414+
raw = _raw_M(sub, prepare_objectives(model, le_obj, sub), method)
411415
raw === nothing && return nothing
412416
push!(results, aggregate_M_values(model, raw))
413417
end
@@ -427,7 +431,7 @@ function _maximize_M(
427431
for i in 1:objective.set.dimension
428432
ge_obj = JuMP.ScalarConstraint(
429433
objective.func[i], MOI.GreaterThan(zero(val_type)))
430-
raw = _raw_M(sub,prepare_objectives(model, ge_obj, sub),method)
434+
raw = _raw_M(sub, prepare_objectives(model, ge_obj, sub), method)
431435
raw === nothing && return nothing
432436
push!(results, aggregate_M_values(model, raw))
433437
end
@@ -449,8 +453,8 @@ function _maximize_M(
449453
objective.func[i], MOI.GreaterThan(zero(val_type)))
450454
le_obj = JuMP.ScalarConstraint(
451455
objective.func[i], MOI.LessThan(zero(val_type)))
452-
raw_ge = _raw_M(sub,prepare_objectives(model, ge_obj, sub),method)
453-
raw_le = _raw_M(sub,prepare_objectives(model, le_obj, sub),method)
456+
raw_ge = _raw_M(sub, prepare_objectives(model, ge_obj, sub), method)
457+
raw_le = _raw_M(sub, prepare_objectives(model, le_obj, sub), method)
454458
(raw_ge === nothing || raw_le === nothing) &&
455459
return nothing
456460
push!(results, aggregate_M_values(model, max.(raw_ge, raw_le)))

0 commit comments

Comments
 (0)