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

CMA stop conditions #401

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

beny-bee
Copy link
Contributor

Hi,

I am currently enhancing the implementation of the CMA-ES algorithm by introducing additional stopping conditions. These modifications are intended to improve numerical stability and are advocated in A Restart CMA Evolution Strategy With Increasing Population Size and The CMA Evolution Strategy: A Tutorial. The changes are also in line with implementations found in Python libraries maintained by the same author.

These are basically:

  • [Implemented] Maximum Generations (maxiter): Stop if the number of iterations reaches a predefined limit.
  • [Implemented] Target Objective Value (ftarget): Stop if the best objective value is less than or equal to a target value.
  • [Implemented] Maximum Function Evaluations (maxfevals): Stop if the number of function evaluations reaches a predefined limit.
  • [Implemented] Tolerance on Function Value (tolfun): Stop if the range of function values of the best solutions falls below a threshold over a certain number of iterations.
  • [Implemented] Tolerance on Fitness Stagnation (tolflatfitness): Stop if the best objective value does not change significantly over a number of generations.
  • [Implemented] Condition Number of Covariance Matrix (tolconditioncov): Stop if the condition number of the covariance matrix exceeds a certain threshold.
  • No Effect Axis (noeffectaxis): Stop if adding 0.1 times the standard deviation in the search space in a principal axis direction does not change the solution.
  • No Effect Coordinate (noeffectcoord): Stop if adding 0.2 times the standard deviation in the search space along one coordinate does not change the solution.
  • Tolerance on Variables (tolx): Stop if the change in the variables between generations falls below a threshold.
  • Tolerance on Upscaled Sigma (tolfacupx): Stop if any scaled step sizes exceed the product of the initial step sizes and a specified tolerance factor.
  • Historical Fitness Tolerance (tolfunhist): Stop if the range of fitness values in the historical best fitness list remains below a specified threshold.
  • Sigma Ratio Increase (tolupsigma): Stop if the ratio of the current step size to the maximum eigenvalue of the covariance matrix exceeds a specified multiple of the initial step size.
  • Stagnation (tolstagnation): Stop if there is no significant improvement over a large number of generations.
  • Relative Function Value (tolfunrel): Stop based on a relative condition involving the historical and current best function values.

These conditions are the ones currently present in the Python repository I mentioned and align with the papers while adding a few other stopping criteria. These are what I plan to implement, but I'm open suggestions.

Additionally, I have made modifications in lines 94 and 112 to align with the initialization presented in The CMA Evolution Strategy: A Comparing Review (page 26, equations 35 and 37). These initialization parameters are also supported by other papers I have reviewed.

Copy link

mlpack-bot bot commented Jun 14, 2024

Thanks for opening your first pull request in this repository! Someone will review it when they have a chance. In the mean time, please be sure that you've handled the following things, to make the review process quicker and easier:

  • All code should follow the style guide
  • Documentation added for any new functionality
  • Tests added for any new functionality
  • Tests that are added follow the testing guide
  • Headers and license information added to the top of any new code files
  • HISTORY.md updated if the changes are big or user-facing
  • All CI checks should be passing

Thank you again for your contributions! 👍

@@ -274,6 +291,17 @@ typename MatType::elem_type CMAES<SelectionPolicyType,
return overallObjective;
}

// Terminate if sigma/sigma0 is above 10^4 * max(D)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Terminate if sigma/sigma0 is above 10^4 * max(D)
// Terminate if sigma/sigma0 is above 10^4 * max(D).

To be consistent with the style.

@github-actions github-actions bot removed the s: stale label Jul 29, 2024
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.

is this ready to be merged?

@beny-bee
Copy link
Contributor Author

is this ready to be merged?

I think perhaps some review would be fine, but I believe its okay. It should be ready to be merged

@beny-bee beny-bee marked this pull request as ready for review August 13, 2024 05:30
@github-actions github-actions bot closed this Sep 27, 2024
@rcurtin
Copy link
Member

rcurtin commented Sep 27, 2024

Since this is so close, we should keep it open to get it merged. I marked it keep-open

@rcurtin rcurtin reopened this Sep 27, 2024
@NilotpalMaitra
Copy link

Hello, is this issue still open?

@coatless
Copy link
Contributor

@NilotpalMaitra still open; needs someone to take it across the finish line.

@NilotpalMaitra
Copy link

@NilotpalMaitra still open; needs someone to take it across the finish line.

Sure! I would try my best to resolve this issue!

@NilotpalMaitra
Copy link

Can anyone just tell whats the final issue, its hard to decipher from the above chats

@beny-bee
Copy link
Contributor Author

Hi @NilotpalMaitra, the goal of this was to expand some of the stopping conditions the CMA-ES currently had. If you check the original post I left some references to the papers as well as a Python library maintained by the author of those papers. If you go through them, you will see there are some of these stopping criteria missing in the current implementation.

The modifications aren't as straightforward as I originally thought, with some modifications needing to change quite a bit of code to add arrays/history of previous iterations and substantially modifying some of the API. This would then need to be replicated for all CMA-ES variants in the library to maintain coherence.

Overall, there is a lot of code that would need to be overhauled and tested, and I believe it would be beneficial to have some discussion with the maintainers before committing to these changes. Feel free to take it up and finish it.

@NilotpalMaitra
Copy link

Thank you so much for summarizing the issue! as you have mentioned that the issue is not as simple as it was, So I would definitely go through the paper first to give myself a gist of what all is happening .

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.

5 participants