-
Notifications
You must be signed in to change notification settings - Fork 9
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
Multiple Primal Optimizers #45
Multiple Primal Optimizers #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of multiple primal optimizers looks good!
Left several repeated change requests for not wrapping a single optimizer object into a list (since the ConstrainedOptimizer
class would already do that internally anyway).
IMO this would keep the usage less cluttered since users will most often use single primal optimizers anyway.
A natural follow-up feature for this would be multiple (partially instantiated) dual optimizers. However, this does not seem to be a pressing feature to implement at the moment. |
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Co-authored-by: Jose Gallego-Posada <jgalle29@gmail.com>
Closes #39
Changes
Parameter
primal_optimizer
ofConstrainedOptimizer
renamed toprimal_optimizers
. It accepts either a (i)torch.optim.Optimizer
or a (ii) list of Optimizers. Behavior in case (i) is unchanged.Lines previously performing
constrained_optimizer.primal_optimizer.method()
have been replaced byfor primal_optimizer in constrained_optimizer.primal_optimizers; primal_optimizer.method()
.For instance,
cooper/cooper/constrained_optimizer.py
Lines 329 to 330 in 4421115
Saving and loading of checkpoints was modified to allow for lists of primal optimizers.
⚠ Warning ⚠
This breaks backward compatibility when instantiating a
ConstrainedOptimizer
with keyword argumentprimal_optimizer
.Testing
Toy2D testing of constrained and unconstrained execution included in
test_optimizer.py
.Checkpointing test included in
test_checkpoint.py
This functionality is not tested together with other optimization methods or formulations (Extragradient, Augmented Lagrangian, Proxy constraints).
Docs
Note added in
constrained_optimizer.rst
indicating that functionality exists.Small section added in
optim.rst
describing how to setup multiple primal optimizers and how Cooper handles them.Docstrings and overall documentation updated to be general enough for multiple optimizers.