Documentation

LeanCert.Engine.Optimization.Guided

Float-Guided Global Optimization #

This file provides "oracle-guided" global optimization that uses fast floating-point heuristics to initialize the rigorous branch-and-bound algorithm with tight bounds.

Algorithm Overview #

The key insight: finding a good upper bound early allows aggressive pruning.

  1. Heuristic Phase: Use Monte Carlo sampling with hardware floats to find a candidate point x_guess that likely minimizes f.

  2. Certification Phase: Convert x_guess to a tiny rational interval and rigorously evaluate f(x_guess) using interval arithmetic to get a certified upper bound U.

  3. Pruning Phase: Initialize branch-and-bound with upper bound U. Any box B with lower bound L > U is immediately pruned.

Performance Impact #

For typical optimization problems, this approach can prune 90%+ of the search space on the first iteration, dramatically reducing total computation.

Main definitions #

Design notes #

The float results are NEVER trusted directly. They only guide where to look. All bounds returned are rigorously computed using interval arithmetic.

Configuration for guided optimization #

Extended configuration for guided optimization

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Float to Rational conversion #

      Convert a Float to a rational approximation. Returns a rational that is close to the float value. Note: This is approximate; the certified interval evaluation handles precision.

      Equations
      Instances For

        Convert a float environment to a rational point interval environment. Each float coordinate becomes a small interval around the rational approximation. Uses a fixed width of 1/1000000 for simplicity.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def LeanCert.Engine.Optimization.floatEnvToRatEnvClamped (pt : Float) (B : Box) (width : := 1 / 1000000) :

          Convert a float environment to interval environment within box bounds. Clamps coordinates to stay within the box.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Candidate certification #

            Certify a float candidate by evaluating it rigorously. Returns an interval containing the true function value at (or near) the candidate.

            Equations
            Instances For

              Certify with division support.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Guided optimization #

                Global minimization with Float guidance.

                Algorithm:

                1. Evaluate the whole box to get initial bounds
                2. Use Monte Carlo (and optionally grid search) to find a good candidate
                3. Certify the candidate to get a rigorous upper bound
                4. Initialize branch-and-bound with this upper bound for early pruning
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Global minimization with Float guidance and division support.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Global maximization with Float guidance.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Global maximization with Float guidance and division support.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Convenience API #

                        def LeanCert.Engine.Optimization.minimize (e : Core.Expr) (B : Box) (maxIters : := 1000) (tolerance : := 1 / 1000) :

                        Quick guided minimization with sensible defaults

                        Equations
                        Instances For
                          def LeanCert.Engine.Optimization.maximize (e : Core.Expr) (B : Box) (maxIters : := 1000) (tolerance : := 1 / 1000) :

                          Quick guided maximization with sensible defaults

                          Equations
                          Instances For

                            Result inspection #

                            Get the certified minimum interval from a result. Note: Returns none if lo > hi (should not happen for valid results).

                            Equations
                            Instances For

                              Check if the optimization has converged (gap is small)

                              Equations
                              Instances For

                                Get the optimality gap

                                Equations
                                Instances For