argmin

repository·main·Indexed 22 days ago

https://github.com/argmin-rs/argmin

A numerical optimization library written in pure Rust (v0.11.0) providing a consistent interface for a wide variety of optimization algorithms. The ecosystem includes the core argmin crate, argmin-math for backend abstractions (supporting ndarray, nalgebra, faer, and Vecs), argmin-testfunctions for algorithm verification, and finitediff for finite differentiation. It features a type-agnostic design, checkpointing for interrupted runs, and various observers for logging and real-time monitoring via the Spectator GUI tool.

Tokens
41.7K
Snippets
84
Records
243
Agent score
76%

What's inside argmin

  1. Overview of the argmin optimization library

    main

    argmin is a numerical optimization library written in Rust designed to provide a wide range of optimization algorithms through a consistent interface.

    Key features include:

    • Type-agnostic design: Works with any type or math backend (e.g., nalgebra, ndarray, or custom implementations).
    • Observers: Allows tracking iteration progress via logging to screen, disk, or custom implementations.
    • Checkpointing: An optional mechanism to mitigate data loss from crashes in unstable environments.
    • Extensibility: Uses Rust's generics and traits so users can implement their own tailored versions of framework components.
    • Algorithm Toolbox: Simplifies developing new algorithms by handling termination, parameter vectors, populations, gradients, Jacobians, and Hessians automatically.
  2. Overview of argmin-math abstractions

    main

    The argmin-math crate provides mathematical abstractions required for optimization tasks within the argmin ecosystem. It allows users to perform mathematical operations using different backends. Currently, the supported math backends are:

    • Basic Vecs
    • ndarray
    • nalgebra
    • faer

    For specific implementation details and API usage for each backend, consult the official documentation.

  3. Overview of argmin

    main

    argmin is a mathematical optimization framework implemented in pure Rust. It provides a wide range of solvers designed with a consistent interface, allowing users to easily plug optimization problems into different solvers.

    Key features include:

    • Consistent Interface: Easily switch between different solvers using a unified API.
    • Type Agnostic: You can represent variables, gradients, Jacobians, and Hessians using your own custom types.
    • Flexible Math Backends: Supports Vec, ndarray, or nalgebra for mathematical operations, and allows for custom backend implementations.
    • Observers: Monitor optimization progress via logging to the screen, files, or custom observer implementations.
    • Checkpointing: Mitigate crashes in unstable environments by saving regular progress checkpoints.
    • Extensibility: Leverages Rust's generics and traits to allow users to provide their own implementations for most features.
    • Development Framework: Provides tools and an ecosystem to help developers implement their own custom solvers.
  4. Use argmin_testfunctions for optimization testing

    main

    The argmin_testfunctions crate provides a collection of two- and multidimensional test functions, including their derivatives and Hessians, designed for testing optimization algorithms.

    Key Features:

    • Dimensionality Support: Includes 2D functions and multidimensional functions.
    • Memory Efficiency:
      • For 2D functions, derivative and Hessian calculations do not allocate.
      • For multidimensional functions, you can choose between Vec-based variants (which allocate, useful when parameter counts are known only at runtime) or _const variants (which use fixed-size arrays and do not allocate, useful when parameter counts are known at compile-time).
    • Generic Inputs: All functions are generic over their inputs and support both f32 and f64 types.
    • Function Variants: Some functions like ackley, rosenbrock, and rastrigin have variants with optional parameters to change their shape (e.g., ackley_abc, rosenbrock_ab, and rastrigin_a).
  5. Use argmin-observer-spectator to send metrics to Spectator

    main

    The argmin-observer-spectator crate provides an observer that sends optimization metrics and parameter vectors to a Spectator instance. This allows for real-time monitoring of optimization processes.

    For implementation details, refer to the official documentation or the provided examples in the main repository:

    Detailed API documentation can be found on docs.rs for the latest release.

  6. Use argmin-testfunctions-py for optimization testing

    main

    The argmin-testfunctions-py module provides Python bindings for the test functions found in the argmin_testfunctions Rust crate. It is designed for testing optimization algorithms by providing standard mathematical test functions along with their derivatives and Hessians.

    Key features:

    • Derivatives and Hessians: For every test function, you can access its derivative (gradient) and Hessian (second-order derivative) using specific function suffixes.
    • Variable Dimensionality: While most functions are two-dimensional, functions like ackley, levy, rastrigin, rosenbrock, and sphere support an arbitrary number of parameters.
    • Customizable Shapes: Some functions allow optional parameters (e.g., a, b, c) to modify the shape of the test function surface.
  7. Use argmin-observer-slog to log optimization progress

    main
    The argmin-observer-slog crate provides an observer for the argmin optimization framework that logs the progress of an optimization process. It can output logs to the terminal or to a file on disk, allowing you to monitor how an optimization is proceeding in real-time or review it later.
  8. Use finitediff for gradient, Jacobian, and Hessian calculations

    main

    The finitediff crate provides methods to calculate gradients, Jacobians, and Hessians using forward and central difference schemes. It supports input vectors using two primary types:

    • Vec<f64>
    • ndarray::Array1<f64>

    This is useful for optimization tasks where the analytical derivative of a function is unavailable or difficult to compute.

  9. Use argmin-observer-paramwriter to log parameter vectors

    main

    The argmin-observer-paramwriter crate provides an observer for the argmin optimization framework that writes serialized parameter vectors to files during the optimization process. This is useful for tracking the evolution of parameters over time or for debugging optimization trajectories.

    For detailed implementation details, refer to the official documentation or the argmin book.

  10. Integrate external solvers with argmin

    main

    External solvers that implement the Solver trait are compatible with argmin's Executor. This compatibility allows external solvers to leverage argmin's core features, such as checkpointing and observers.

    Currently compatible external solvers include:

    • egobox
    • cobyla
  11. Understand Bootstrap asset structure

    main

    The Bootstrap download includes compiled and minified versions of CSS and JS, along with source maps for debugging.

    • CSS: Located in the css/ directory. Includes bootstrap.css, bootstrap.min.css, and specialized files like bootstrap-grid.css and bootstrap-utilities.css. RTL (Right-to-Left) versions are also provided (e.g., bootstrap.rtl.css).
    • JS: Located in the js/ directory. Includes bootstrap.js, bootstrap.min.js, and ESM modules (bootstrap.esm.js).
    • Bundled JS: Files named bootstrap.bundle.js and bootstrap.bundle.min.js include Popper automatically, which is required for certain components like tooltips and popovers.
    bootstrap/
    ├── css/
    │   ├── bootstrap-grid.css
    │   ├── bootstrap-grid.min.css
    │   ├── bootstrap.css
    │   ├── bootstrap.min.css
    │   └── ...
    └── js/
        ├── bootstrap.bundle.js
        ├── bootstrap.bundle.min.js
        ├── bootstrap.esm.js
        ├── bootstrap.js
        └── bootstrap.min.js