Skip to content

Commit

Permalink
Renaming to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
juan43ramirez committed Mar 13, 2024
1 parent ed851f2 commit 0d171fe
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions cooper/cmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ def populate_primal_lagrangian(self) -> LagrangianStore:

current_primal_constraint_measurements = []
for constraint_group, constraint_state in contributing_constraints:
(
primal_lagrangian_contribution,
primal_constraint_measurement,
) = constraint_group.compute_constraint_primal_contribution(constraint_state)
current_primal_constraint_measurements.append(primal_constraint_measurement)
if primal_lagrangian_contribution is not None:
current_primal_lagrangian = current_primal_lagrangian + primal_lagrangian_contribution
primal_constraint_contrib, primal_measurement = constraint_group.compute_constraint_primal_contribution(
constraint_state
)
current_primal_constraint_measurements.append(primal_measurement)
if primal_constraint_contrib is not None:
current_primal_lagrangian = current_primal_lagrangian + primal_constraint_contrib

# Modify "private" attributes to accumulate Lagrangian values over successive
# calls to `populate_primal_lagrangian`
Expand Down Expand Up @@ -138,19 +137,18 @@ def populate_dual_lagrangian(self) -> LagrangianStore:

current_dual_constraint_measurements = []
for constraint_group, constraint_state in contributing_constraints:
(
dual_lagrangian_contribution,
dual_constraint_measurement,
) = constraint_group.compute_constraint_dual_contribution(constraint_state)
current_dual_constraint_measurements.append(dual_constraint_measurement)
if dual_lagrangian_contribution is not None:
current_dual_lagrangian = current_dual_lagrangian + dual_lagrangian_contribution
dual_lagrangian_contrib, dual_measurement = constraint_group.compute_constraint_dual_contribution(
constraint_state
)
current_dual_constraint_measurements.append(dual_measurement)
if dual_lagrangian_contrib is not None:
current_dual_lagrangian = current_dual_lagrangian + dual_lagrangian_contrib

# Extracting the violation from the dual_constraint_measurement ensures that it is
# the "strict" violation, if available.
_, strict_constraint_features = constraint_state.extract_constraint_features()
constraint_group.update_strictly_feasible_indices_(
strict_violation=dual_constraint_measurement.violation,
strict_violation=dual_lagrangian_contrib.violation,
strict_constraint_features=strict_constraint_features,
)

Expand Down

0 comments on commit 0d171fe

Please sign in to comment.