facebookresearch / nevergrad

A Python toolbox for performing gradient-free optimization
https://facebookresearch.github.io/nevergrad/
MIT License
3.89k stars 349 forks source link

Update _layering.py #1577

Open zcoder opened 7 months ago

zcoder commented 7 months ago

add: class SignificantFigure(Int): Rounds data to a specified number of significant figures.

Types of changes

Motivation and Context / Related issue

Why is this change required?

This change introduces the SignificantFigure layer into the Nevergrad optimization library, addressing a specific need for precise control over the numerical precision of parameters during the optimization process. The current version of Nevergrad does not offer an in-built method to enforce a specific number of significant figures in its parametrization process. This limitation can lead to challenges in scenarios where the precision of parameters, defined by the number of significant digits, is crucial, such as in scientific computations, financial models, or engineering simulations.

What problem does it solve?

The SignificantFigure layer solves the problem of rounding parameter values to a defined number of significant figures. This is particularly useful when working with parameters that can vary over wide ranges, where the precision in terms of decimal places may not be consistent across different magnitudes. The introduction of this layer ensures that the parameters are handled consistently, irrespective of their scale, enhancing the robustness and accuracy of the optimization results.

Furthermore, this change enables Nevergrad users to more closely align the optimization process with domain-specific requirements regarding numerical precision, thereby expanding the library's applicability and utility in various technical and scientific fields.

How Has This Been Tested (if it applies)

tested localy

Checklist

if this functionality is needed in nevergrad, I will complete all the necessary items required for merge (nevergrad/contributing.html)

teytaud commented 4 weeks ago

Hello! Can you run black and then everything should be ok ?