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

Modularize code structure #52

Merged
merged 17 commits into from
Oct 24, 2022

Conversation

gallego-posada
Copy link
Collaborator

@gallego-posada gallego-posada commented Oct 24, 2022

Closes #48

Changes

⚠️ This is a backwards-compatibility breaking change!

ConstrainedMinimizationProblem (CMP)

  • Remove is_constrained argument/attribute from CMP.
  • All logic branching that depended on is_constrained has been refactored inside each CooperOptimizer subclass (see below).

Constrained Optimizer

  • Create CooperOptimizer class.
  • Create separate classes for different kinds of optimizers. For example SimultaneousConstrainedOptimizer, AlternatingConstrainedOptimizer, ExtrapolationConstrainedOptimizer.
  • Create explicit UnconstrainedOptimizer for wrapping (primal) optimizers when dealing with unconstrained problems.
  • The user has to select explicitly which kind of update to perform and choose the corresponding ConstrainedOptimizer subclass.
  • This change removes much "if/else" branching that existed in the previous ConstrainedOptimizer class, and makes maintaining the code for the individual optimizers simpler.
  • Add utility function cooper.optim.constrained_optimizers.utils.create_optimizer_from_kwargs so users can conveniently create the "right" optimizer class based on their choice of alternating/extrapolation/etc.
  • Add cooper.optim.constrained_optimizers.cooper_optimizer.CooperOptimizerState dataclass for storing the state of primal and dual optimizers, and other configurations of a CooperOptimizer object.

Formulation

  • Create separate module formulation

Multipliers

  • Create separate module multipliers

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.

Modularize ConstrainedOptimizer
2 participants