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

Make Callback flexible for MultiObjective Optimizers. #289

Merged
merged 15 commits into from
Jun 4, 2021

Conversation

jonpsy
Copy link
Member

@jonpsy jonpsy commented May 28, 2021

Related to #282

  • Create MOOTypedForms struct specifically for MOO related type forms.
  • Create GenerationalStepTaken, replacement for StepTaken in MOO.
  • Register the above using ENS MACRO.
  • Write in built callback for Querying Front.
  • Adapt the tests for this.

@zoq Let me know if you agree with this methodology. You can check the commit message to see what I've done.

=> add MOOTypedForms in traits.hpp.
=> added a specialization for StepTaken for MOO in callbacks.hpp.
@jonpsy
Copy link
Member Author

jonpsy commented May 28, 2021

@zoq Similar to EndEpoch wouldn't it be great to have EndGeneration as well? Then we can make PrintLoss() adapt to that. In fact, if we're smart about this we can make almost all of our callbacks work for MOO cases.

@jonpsy
Copy link
Member Author

jonpsy commented May 29, 2021

The current implementation doesn't throw compile errors, but it doesn't work either. Looks like a template matching issue.

@jonpsy
Copy link
Member Author

jonpsy commented May 29, 2021

To test its working, I created this test code. This is working completely fine given I have defined
StepTaken for MOO Specialization before the usual StepTaken. That means, in callbacks.hpp

This should be defined first

template<typename OptimizerType,
         typename FunctionType,
         typename ObjectivesVecType,
         typename IndicesType,
         typename MatType,
         typename ...CallbackTypes>
  static bool StepTaken(OptimizerType& optimizer,
                        FunctionType& functions,
                        MatType& coordinates,
                        ObjectivesVecType& objectives,
                        IndicesType& frontIndices,
                        CallbackTypes&... callbacks)

and after that

  template<typename OptimizerType,
           typename FunctionType,
           typename MatType,
           typename... CallbackTypes>
static bool StepTaken(..)

So that the compiler avoids going into the usual StepTaken function. Let me know if this is fine or should I rename the first one as MOOStepTaken although I think the current implementation is good.

@zoq
Copy link
Member

zoq commented May 30, 2021

This looks fine to me.

Copy link
Member

@zoq zoq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update https://github.com/mlpack/ensmallen/blob/master/tests/callbacks_test.cpp as well, the test you posted is a good basis.

@jonpsy
Copy link
Member Author

jonpsy commented May 31, 2021

Gotta update the docs as well.

=> Move Callback::StepTaken() at the end of for loop nsga2
=> Register GenerationStepTaken in macro
@jonpsy
Copy link
Member Author

jonpsy commented Jun 1, 2021

GTM? @zoq

HISTORY.md Outdated Show resolved Hide resolved
include/ensmallen_bits/callbacks/query_front.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/callbacks/query_front.hpp Outdated Show resolved Hide resolved
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
@jonpsy jonpsy changed the title Make Callback traits adaptable for MOO Make Callback flexible for MultiObjective Optimizers. Jun 1, 2021
@jonpsy
Copy link
Member Author

jonpsy commented Jun 2, 2021

Looks like this is ready

Copy link
Member

@zoq zoq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thanks for doing that.

Copy link

@mlpack-bot mlpack-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second approval provided automatically after 24 hours. 👍

@zoq zoq merged commit abd5b03 into mlpack:master Jun 4, 2021
@zoq
Copy link
Member

zoq commented Jun 4, 2021

Thanks for another great addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants