cooper
cooper copied to clipboard
Refactor CMP and CMPState
CMP and CMPState
- Converted CMPState into a dataclass for improved readability and maintainability.
- Removed dual attributes from
LagrangianStore
. - Moved the
backward
method from CMPState toLagrangianStore
. - Utilized LagrangianStore as a data structure to organize information within
CMPState
replacing direct attributes such asself.lagrangian
andself.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__
inno_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 betweenConstraint
,Formulation
andMultiplier
.
Formulations
- Removed
PenaltyFormulation
andQuadraticPenaltyFormulation
-
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
andAugmentedLagrangianFormulation
remain. Now it is mandatory to provide aMultiplier
when building a formulation. - Removed
FormulationType
. - Removed formulation kwargs such as
penalty_growth_factor
andviolation_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 tois_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
andUnconstrainedOptimizer
inherit fromCooperOptimizer
- Both
- Add
RollOut
for organizing returns ofroll
method - Remove
ConstraintMeasurement
- Add
ContributionStore
- Remove AugmentedLagrangian optimizers
- Fix Penalty Coefficient and Updater to allow for scalar values
- Remove Slacks