Documentation

LeanCert.Engine.Search.Heuristic

Heuristic Search for Global Optimization #

This file provides heuristic search methods using fast floating-point arithmetic to find good candidate points for global optimization. These candidates are used to initialize rigorous branch-and-bound algorithms with tight upper bounds, enabling early pruning of the search space.

Main definitions #

Design notes #

The heuristic results are NOT verified. They are used only to guide the search:

  1. Find a candidate point with low objective value
  2. Certify this point using rigorous interval arithmetic
  3. Use the certified upper bound to prune the branch-and-bound tree

This "oracle-guided" approach can prune 90%+ of the search space on typical problems.

Rational to Float conversion #

Convert a rational to a Float (approximate)

Equations
Instances For

    Float representation of boxes #

    Float representation of a box for fast sampling

    • centers : Array Float

      Center of each dimension

    • radii : Array Float

      Half-width (radius) of each dimension

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

        Convert a rational Box to float representation

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

          Dimension of a float box

          Equations
          Instances For

            Pseudo-Random Number Generator #

            Simple Linear Congruential Generator (LCG) for reproducible randomness. Parameters from Numerical Recipes: a = 1664525, c = 1013904223, m = 2³²

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

                Create a PRNG with given seed

                Equations
                Instances For

                  Generate next random number in [0, 1) and updated PRNG

                  Equations
                  Instances For

                    Generate next random number in [-1, 1] and updated PRNG

                    Equations
                    Instances For

                      Generate n random numbers in [-1, 1]

                      Equations
                      Instances For

                        Sampling methods #

                        Generate a random point inside a float box

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

                          Generate n random points inside a float box

                          Equations
                          Instances For

                            Get the center point of a float box

                            Equations
                            Instances For

                              Monte Carlo Minimization #

                              def LeanCert.Engine.Search.findBestCandidate (e : Core.Expr) (B : Optimization.Box) (samples : := 100) (seed : := 12345) :

                              Heuristic Minimizer using Monte Carlo sampling. Samples n points using Float arithmetic and returns the best candidate found.

                              This is surprisingly effective for finding the "basin of attraction" of the global minimum, especially in high dimensions where grid search is infeasible.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def LeanCert.Engine.Search.findBestCandidate.loop (e : Core.Expr) (fb : FloatBox) (i : ) (rng : PRNG) (bestVal : Float) (bestPt : Float) :
                                Equations
                                Instances For
                                  def LeanCert.Engine.Search.findTopCandidates (e : Core.Expr) (B : Optimization.Box) (samples : := 100) (k : := 5) (seed : := 12345) :

                                  Find multiple good candidates (for multi-start local search). Returns the k best distinct points found during sampling.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    Equations
                                    Instances For
                                      def LeanCert.Engine.Search.gridSearch (e : Core.Expr) (B : Optimization.Box) (pointsPerDim : := 10) :

                                      Uniform grid search over a box. Samples a regular grid with pointsPerDim points along each dimension. Total samples = pointsPerDim^dim, so use sparingly for high dimensions.

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

                                        Combined Strategy #

                                        def LeanCert.Engine.Search.hybridSearch (e : Core.Expr) (B : Optimization.Box) (gridPoints : := 5) (mcSamples : := 50) (seed : := 12345) :

                                        Hybrid search combining grid and Monte Carlo. First does a coarse grid search, then refines around the best point with Monte Carlo.

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