cooper icon indicating copy to clipboard operation
cooper copied to clipboard

Refactor CMP and CMPState

Open merajhashemi opened this issue 11 months ago • 0 comments

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 avatar Mar 21 '24 14:03 merajhashemi