Skip to main content

Global Optimization through High-Resolution Sampling

This package provides functions to run a global optimization algorithm, specifically designed to explore the properties of high-dimensional functions through High-Resolution sampling. It is based on the following paper. The package includes tools for defining functions, setting optimization parameters, generating samples, and visualizing empirical probabilities.

Installation

The package is available through pip, and may be installed via:

pip install GlobalOptimizationHRLA

Setup

In order to use this package, you need to define:

  • The target function and its gradient.
  • An initial distribution for the search space.

Main Usage

1. Defining the Target Function and Gradient

The provided example uses the Rastrigin function as the target for optimization.

import numpy as np

d = 10
U = lambda x: d + np.linalg.norm(x) ** 2 - np.sum(np.cos(2 * np.pi * x))
dU = lambda x: 2 * x + 2 * np.pi * np.sin(2 * np.pi * x)

2. Sampling from an Initial Distribution

Define an initial distribution from which samples are generated:

initial = lambda: np.random.multivariate_normal(np.zeros(d) + 3, 10 * np.eye(d))

3. Running the Algorithm

To execute the global optimization algorithm, use the DNLA.Algorithm class.

import GlobalOptimizationHRLA as HRLA

algorithm = HRLA.Algorithm(d=d, M=100, N=10, K=14000, h=0.01, title=title, U=U, dU=dU, initial=initial)
samples_filename = algorithm.generate_samples(As=[1,2,3,4], sim_annealing=False)

Parameters:

  • d (int): Dimension of the search space.
  • M (int): Number of particles in the swarm.
  • N (int): Number of generations for resampling.
  • K (int): Total number of iterations to perform.
  • h (float): Step size for gradient descent.
  • title (str): Title for the optimization, useful for organizing saved data.
  • U (function): The target function to optimize.
  • dU (function): The gradient of the target function.
  • initial (function): The initial distribution for generating particles.
  • As (list): List of tolerances or annealing factors to adjust optimization.
  • sim_annealing (bool): Determines whether to apply simulated annealing (default is False).

Returns:

  • samples_filename (str): Path to the file where generated samples are saved.

4. Post-processing and Plotting Results

After running the optimization, use the PostProcessor object to analyze and plot the empirical probabilities from the generated samples.

postprocessor = HRLA.PostProcessor(samples_filename)

Parameters:

  • samples_filename (str): The filename containing the generated samples data.

The PostProcessor object provides multiple methods. One is the plot_empirical_probabilities method, which generates a plot of the empirical probabilities for different tolerances.

postprocessor.plot_empirical_probabilities(dpi=10, layout="32", tols=[1,2,3,4,5,6], running=False)

Parameters:

  • dpi (int): Resolution of the plot, in dots per inch.
  • layout (str): Layout of the plot, specified as a string. Must be one of ["13", "23", "32", "22"] (default is "23").
  • tols (list): List of tolerances for computing empirical probabilities (default is [1,2,3,4,5,6]).
  • running (bool): Whether to display the plot with a running average or not (default is False).

Another method is compute_tables, which generates tables of empirical means and standard deviations.

postprocessor.compute_tables(measured=[K], dpi=100, mode="mean", running="True"")

Parameters:

  • measured (list): List with iteration counts to measure the empirical probabilities.
  • dpi (int): Resolution of the plot, in dots per inch.
  • mode (str): Mode for computing the tables, specified as a string. Must be one of ["mean", "std", "best"] (default is "mean").
  • running (bool): Whether to display the results are computed with a running average or not (default is True).

Examples

Examples may in found in the /examples directory of the repository.

Metadata

Release files for GlobalOptimizationHRLA 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GlobalOptimizationHRLA 1.1.0
File Size Uploaded
globaloptimizationhrla-1.1.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for GlobalOptimizationHRLA 1.1.0
File Interpreter ABI Platform
GlobalOptimizationHRLA-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / globaloptimizationhrla-1.1.0.tar.gz

Download URL globaloptimizationhrla-1.1.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cf59ddb21803167c7667193d408d1755703bf8056a27d6a25151afe43aa11ae6
BLAKE2b-256 checksum
How to use checksums
6f4a3cb9e7c4cebb6a24226739cff02e352daab5c944b2217188f284ab9e5712
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / GlobalOptimizationHRLA-1.1.0-py3-none-any.whl

Download URL GlobalOptimizationHRLA-1.1.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f970e7892d6ffb3b80f9b759316c454fa475037a266068d0bcc8a6b67d608c71
BLAKE2b-256 checksum
How to use checksums
bc874d983507094bc10df242b5b989ffb7cee50bda5af0162fcbfbb226468b53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page