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

Implement MOEA/D - DE #269

Merged
merged 128 commits into from
Jun 15, 2021
Merged

Implement MOEA/D - DE #269

merged 128 commits into from
Jun 15, 2021

Conversation

jonpsy
Copy link
Member

@jonpsy jonpsy commented Mar 9, 2021

This PR is a continuation of #210. Till now I've made these changes

Address issue #176

  • Naming changes
  • Fixing algorithms
  • Wrapping codes into functions
  • Argument passing fixed

**Important: For more details regarding its testing and comparison against other algorithms. Refer this discussion.

The following remains to be done

TODO

  • Adding more sanity checks
  • Let user explicitly choose whether they want to preserve diversity or not
  • Use a Policy-based approach to delegate Weight initialization and Decomposition.
  • Discard arma::mat for InputType and OutputType.
  • Add test cases for various MatType: Stress testing and accuracy measurement. Schaffer and Fonseca pass currently for
    double.
  • Use the CheckArbitraryFunctionType API once that PR is merged.
  • Assert RequireDenseFloatingType InputType.
  • After ZDT is merged, test against it: report results. (or maybe do it in separate PR?)

FIXME

  • Handle zero weight condition in Tchebycheff decomposition
  • Updating Solutions

DOCUMENTATION

  • Write about MOEA/D-DE in optimizer.md
  • Update History.MD
  • Finalize docs.

Memory

  • Find and remove redundant & expensive matrix copy.
  • Find and remove leaks

Testing

  • Add callback test

REVIEWS
Requesting @zoq @say4n @rcurtin for reviews.

@jonpsy jonpsy changed the title Implement MOEA/D - DE [WIP] Implement MOEA/D - DE Mar 9, 2021
@jonpsy
Copy link
Member Author

jonpsy commented Mar 9, 2021

There are a few compile-time errors, I'll be fixing that over-the-course. I'd like reviews on algorithmic correctness and semantics.

@jonpsy
Copy link
Member Author

jonpsy commented Mar 10, 2021

Just have to fix the tests, a little bit of tinkering aaaand we should be done! I'd like to add other decomposition methods (Bi, Weighted) as part of separated PR so as to avoid bloating :)

@jonpsy
Copy link
Member Author

jonpsy commented Mar 11, 2021

Good news:
=> Everything compiles
Bad news:
=> All the test fail
=> preserveDiversity when set to false leads to SIG memory violation.

@zoq, the actual paper preserves diversity by default, but pagmo2 allows user to turn off that feature. By "preserving diversity", I mean to say the optimizer produces a diverse set of population.

It does by the following way (as per the paper):
a) Algorithm chooses to sample from either the neighbor or whole population, but favors the "whole population" thus increasing diversity.
b) The child solutions (however good they might be) cannot replace a threshold number of parents. For ex: if maxReplace = 10, no more than 10 children would replace original solution.

The above-mentioned feature can be switched off by disabling preserveDiversity, but I was wondering, is it overkill? Because paper didn't allow any choice and simply favored preserving diversity.

@jonpsy
Copy link
Member Author

jonpsy commented Mar 12, 2021

All tests pass! @zoq could you review this please? I was wondering we could try and compare NSGA2 & MOEA/D-DE in terms of speed, correctness.

@jonpsy jonpsy changed the title [WIP] Implement MOEA/D - DE Implement MOEA/D - DE Mar 12, 2021
@jonpsy
Copy link
Member Author

jonpsy commented Mar 13, 2021

Pushing some more. I'll be explaining my choice of default args over the next few comments.

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.

Thanks, I'll take a closer look into the code over the next days, do you mind to go over the code and adjust the indentation according to the style guidelines.

doc/optimizers.md Outdated Show resolved Hide resolved
doc/optimizers.md Outdated Show resolved Hide resolved
doc/optimizers.md Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead.hpp Outdated Show resolved Hide resolved
@jonpsy
Copy link
Member Author

jonpsy commented Mar 14, 2021

Default args:

  • populationSize: 150. For 2 objectives he's chosen N=300, so I took N=150, assuming single objective.

N default

  • neighborSize : 20
  • neighborProb: 0.9
  • maxReplace: 2

Parameter-Set1

Some notes: The paper recommends maxReplace << neighborSize
nr-delta

Finally

crossOverProb: 1.0
differentialWeight: 0.5
distributionIndex: 20
mutationRate: 1/numVariables

Parameter-Set3

@jonpsy
Copy link
Member Author

jonpsy commented Mar 16, 2021

@zoq Gentle nudge :)

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.

I have to take another look at the paper, but this looks really good.

include/ensmallen_bits/moead/moead.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
tests/moead_test.cpp Outdated Show resolved Hide resolved
tests/moead_test.cpp Show resolved Hide resolved
@jonpsy
Copy link
Member Author

jonpsy commented Mar 18, 2021

I was wondering why the indentation messes up when I push it here. Looks like tabs vs space issue, thanks for pointing them out @zoq.

@jonpsy
Copy link
Member Author

jonpsy commented Apr 10, 2021

Stalling this for a while, till NSGA2, Recursive MOO and Indicators gets merged. They will serve as a baseline for this pull request. Have updated TODO list for others to track the progress of this PR.

@jonpsy
Copy link
Member Author

jonpsy commented Apr 18, 2021

Keep open!

fix callback test
@jonpsy
Copy link
Member Author

jonpsy commented Jun 12, 2021

@zoq I think I've addressed all of your comments. If you find some indent mistakes, it would be helpful if you could do a "commit suggestion", it gets tiring to change minor things every commits. Thanks a lot.

@jonpsy
Copy link
Member Author

jonpsy commented Jun 12, 2021

Uhm... I've done a sizeable amount of work on the policy-based method already. How about we merge this as-is now, and create a follow-up PR in which I handle the templatizing and some other minor fixes.

Here's a patch for policy if you want a look.

@zoq
Copy link
Member

zoq commented Jun 12, 2021

@zoq I think I've addressed all of your comments. If you find some indent mistakes, it would be helpful if you could do a "commit suggestion", it gets tiring to change minor things every commits. Thanks a lot.

Maybe you can adjust your code editor to use the correct indentation style, I use vim and setting up the indentation is easy, That could save us both some time. https://github.com/mlpack/mlpack/wiki/DesignGuidelines has all the important style guidelines.

@zoq
Copy link
Member

zoq commented Jun 12, 2021

Uhm... I've done a sizeable amount of work on the policy-based method already. How about we merge this as-is now, and create a follow-up PR in which I handle the templatizing and some other minor fixes.

Here's a patch for policy if you want a look.

You can just open another PR with the changes from this one and the policy design changes, and rebase the PR afterwards. I don't want to rush anything. Like one thing I haven't done is run the tests in a loop and check if they are stable, maybe you did that already in which case we can check that one.

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.

Next step to test this in a loop.

include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
tests/moead_test.cpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead_impl.hpp Outdated Show resolved Hide resolved
include/ensmallen_bits/moead/moead.hpp Outdated Show resolved Hide resolved
jonpsy and others added 7 commits June 13, 2021 09:15
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
@jonpsy
Copy link
Member Author

jonpsy commented Jun 13, 2021

Thank you for taking the time to fix the style. I'll be sure to change my IDE settings.

Reg testing, one thing you'll find interesting to know is, that higher population size leads to more accurate results.

I have yet to test this claim, I'll play around some parameters run it over a 1000 times and report the results here.

@zoq
Copy link
Member

zoq commented Jun 13, 2021

Reg testing, one thing you'll find interesting to know is, that higher population size leads to more accurate results.

That is true, we basically increase the number of possible solutions. For the tests we don't need a perfect solution, just something that is close, to check that the optimizer works with different starting solutions.

@jonpsy
Copy link
Member Author

jonpsy commented Jun 14, 2021

Ran these command ctest -C Release -V --output-on-failure --repeat-until-fail 1000 --rng-seed time to test over 1000 times. It passed each and every time. link. Feel free (and I encourage you to) try this yourself. Just comment out other tests from CMakeLists.txt.

Let's do some final cleanups. Doc fixes, if any, and then this should be good to go imo. Looking forward for your review.

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.

Great work, no further comments from my side.

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. 👍

@jonpsy
Copy link
Member Author

jonpsy commented Jun 15, 2021

All right, if nobody has any objections. Let's get this merged!

@zoq zoq merged commit 3497f27 into mlpack:master Jun 15, 2021
@zoq
Copy link
Member

zoq commented Jun 15, 2021

Nice, with that one merged, let's open another PR for the policy design changes.

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.

3 participants