Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CMP and CMPState #86

Merged
merged 149 commits into from May 14, 2024

Conversation

merajhashemi
Copy link
Collaborator

@merajhashemi merajhashemi commented Mar 21, 2024

CMP and CMPState

  • Converted CMPState into a dataclass for improved readability and maintainability.
  • Removed dual attributes from LagrangianStore.
  • Moved the backward method from CMPState to LagrangianStore.
  • Utilized LagrangianStore as a data structure to organize information within CMPState replacing direct attributes such as self.lagrangian and self.dual_lagrangian.
  • Added constraints attribute and related helper methods to CMP
  • Renamed populate_lagrangian to compute_lagrangian method
  • Removed purge_* methods for lagrangians
  • Added dual_parameters() method for fetching multiplier parameters for instantiating the dual optimizer

PenaltyCoefficients

  • Transformed PenaltyCoefficients to no longer be nn.module.
  • Wrapped __call__ in no_grad mode for efficiency.
  • Implemented def __call__(self, *args, **kwargs): in the base class for consistency.
  • Adjusted __call__ to return cloned values.
  • Moved penalty coefficient update parameters out of Formulation and into PenaltyCoefficientUpdater.
  • Introduced PenaltyCoefficientUpdater to handle update schemes for penalty coefficients.
  • Implemented Multipicative

Updates from #88

Constraint

  • Extracted ConstraintType enum to separate module to resolve circular dependency issues between Constraint, Formulation and Multiplier.

Formulations

  • Removed PenaltyFormulation and QuadraticPenaltyFormulation
    • PenaltyFormulation is deprecated in favor of asking users to formulate penalized tasks directly through their objective function
    • We retain some utility functions for the QuadraticPenaltyFormulation. We will add a tutorial to illustrate the use of a Quadratic Penalty formulation in Cooper.
  • Only LagrangianFormulation and AugmentedLagrangianFormulation remain. Now it is mandatory to provide a Multiplier when building a formulation.
  • Removed FormulationType.
  • Removed formulation kwargs such as penalty_growth_factor and violation_tolerance.

Multipliers

  • Now expect init tensor (if provided) to have shape (num_constraints,). Else, num_constraints:int is expected and we initialize the multipliers with zeros of shape (num_constraints,).
  • Removed support for dual_restarts.
  • Refactored enforce_positive attribute to is_inequality property.
  • Gathered equality and inequality multiplier tests into joint tests for ExplicitMultipliers

Updates from #89

  • Changed observed_constraints attribute of CMPState to be a dictionary with Constraint keys and ConstraintState values
  • Similarly, refactored constraint_measurements to be a dictionary with Constraint keys and ConstraintMeasurement values
  • Added utility function for retrieving observed_multiplier_values from LagrangianStore
  • Added utility function for retrieving observed_violations and observed_violations from CMPState

Updates from #90

  • Implement CooperOptimizer abstract base class
    • Both ConstrainedOptimizer and UnconstrainedOptimizer inherit from CooperOptimizer
  • Add RollOut for organizing returns of roll method
  • Remove ConstraintMeasurement
  • Add ContributionStore
  • Remove AugmentedLagrangian optimizers
  • Fix Penalty Coefficient and Updater to allow for scalar values
  • Remove Slacks

@merajhashemi merajhashemi changed the base branch from master to gallego-posada/1.0.0-alpha March 21, 2024 15:00
@merajhashemi merajhashemi merged commit 9f94213 into gallego-posada/1.0.0-alpha May 14, 2024
@merajhashemi merajhashemi deleted the merajhashemi/refactor-cmp branch May 14, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants