InfiniteOpt.jl

repository·master·Indexed 43 days ago

https://github.com/infiniteopt/infiniteopt.jl

A JuMP extension for modeling and solving infinite-dimensional optimization problems, including stochastic, dynamic, and PDE-based optimization. It provides a unified abstraction for handling infinite parameters, decision functions, derivatives, and measures, with support for high-performance backends like InfiniteExaModels.jl.

Tokens
60.5K
Snippets
181
Records
236
Agent score
55%

What's inside InfiniteOpt

  1. What is InfiniteOpt.jl?

    master

    InfiniteOpt.jl is a JuMP extension designed for modeling and solving infinite-dimensional optimization problems, such as dynamic, stochastic, and PDE-constrained optimization.

    It decouples infinite-dimensional formulations from the solution techniques used to solve them. By default, it uses direct transcription (discretization) transformations that are compatible with all JuMP-supported solvers. For high-performance GPU computing, it is compatible with InfiniteExaModels.jl.

    Key modeling capabilities include:

    • Infinite parameters: Time, space, uncertainty, etc.
    • Infinite variables: e.g., y(t, x)
    • Derivatives: Ordinary and partial derivative operators of any order.
    • Measures: Univariate/multivariate integrals and expectations.
    • Constraints: Linear, quadratic, nonlinear, conic, semi-definite, and indicator constraints.
    • Advanced Integrations: Machine learning surrogate models (via MathOptAI) and generalized disjunctive programming (via DisjunctiveProgramming.jl).
  2. Overview of InfiniteOpt modeling capabilities

    master

    InfiniteOpt is a JuMP extension designed for modeling infinite-dimensional optimization problems, such as stochastic programming, dynamic programming, and space-time optimization. It provides a unified modeling abstraction that supports complex mathematical objects directly within the JuMP framework.

    Key modeling objects supported include:

    • Infinite parameters: e.g., time, space, uncertainty.
    • Finite parameters: Similar to ParameterJuMP functionality.
    • Infinite variables: Decision functions, such as $y(t, x)$.
    • Derivatives: e.g., $\frac{\partial y(t, x)}{\partial t}$.
    • Measures: e.g., integrals $\int y(t,x)dt$ or expectations $\mathbb{E}[y(\xi)]$.

    For high-performance requirements, InfiniteOpt can utilize the InfiniteExaModels.jl backend to significantly reduce solution times using efficient CPU and GPU methods.

  3. What is a TranscriptionBackend and how to use it

    master

    A TranscriptionBackend is a specialized JuMPBackend used to map a transcribed finite model back to its original infinite model (mapping variables, constraints, etc.).

    To use it, you can either create an empty backend or generate one from an existing InfiniteModel using build_transformation_backend! or transformation_backend.

    Important for efficiency: To support incremental updates of parameter functions (allowing for faster resolves), set update_parameter_functions = true when defining the backend. This maps parameter functions to JuMP parameters instead of just numerical values.

    # Option 1: Create an empty backend with incremental updates enabled
    backend = TranscriptionBackend(Ipopt.Optimizer, update_parameter_functions = true)
    model = InfiniteModel(backend)
    
    # Option 2: Generate a backend from an existing InfiniteModel
    build_transformation_backend!(inf_model)
    backend = transformation_backend(inf_model)
  4. What is an InfiniteModel?

    master

    An InfiniteModel is the core datatype in InfiniteOpt used to express infinite-dimensional optimization problems. It is designed to emulate the behavior of JuMP.Model objects, storing parameters, variables, measures, objectives, and constraints.

    Note: InfiniteModel is intended for infinite-dimensional problems. For finite or discrete-time problems, you should use standard JuMP.Model objects instead.

  5. Understand Infinite Domain classes

    master

    Infinite domains in InfiniteOpt describe the behavior of infinite parameters. They are categorized into two main groups based on whether they describe a single independent parameter or a multi-dimensional group of dependent parameters:

    1. InfiniteScalarDomain: Describes a single independent infinite parameter (univariate).

      • IntervalDomain: A continuous interval [lb, ub]. Supports (semi-)infinite bounds like -Inf or Inf.
      • UniDistributionDomain: Corresponds to a univariate distribution from Distributions.jl.
    2. InfiniteArrayDomain: Describes a group of dependent multi-dimensional infinite parameters (multivariate).

      • MultiDistributionDomain: Corresponds to a multivariate or matrix-variate distribution from Distributions.jl. The distribution's dimensions must match the parameter array's shape.
      • CollectionDomain: A collection of InfiniteScalarDomains treated dependently, allowing for non-combinatorial support grids.
    # Example of different domain types
    # Univariate
    domain_int = IntervalDomain(-2, 2)
    domain_dist = UniDistributionDomain(Beta(2,2))
    
    # Multivariate
    domain_multi = MultiDistributionDomain(MvNormal([0., 0.], [1. 0.; 0. 2.]))
    domain_coll = CollectionDomain([IntervalDomain(-2, 2), IntervalDomain(-1, 4)])
  6. How measure operators work in InfiniteOpt

    master

    In InfiniteOpt, a measure is an operator $M_{\ell}$ that maps an infinite expression $y$ over a domain $\mathcal{D}_{-\ell}$ to a real value (or vector of values).

    Discretization Paradigm: Most native measures in InfiniteOpt follow a discretization scheme. They approximate an integral of the form $\int_{\tau \in \mathcal{T}} f(\tau)w(\tau) d\tau$ by evaluating the expression at a set of grid points $\tau_i$ and summing them with weights $\alpha_i$:

    $$\int_{\tau \in \mathcal{T}} f(\tau)w(\tau) d\tau \approx \sum_{i=1}^N \alpha_i f(\tau_i) w(\tau_i)$$

    Measure Data Types:

    • DiscreteMeasureData: Used for measures evaluated on discrete points.
    • FunctionalDiscreteMeasureData: Used for functional representations.

    Extensibility: Users can implement custom measure paradigms by creating concrete subtypes of AbstractMeasureData.

  7. Define infinite parameters using @infinite_parameter

    master

    In InfiniteOpt, parameters that can take values from an infinite domain are defined using the @infinite_parameter macro. These parameters are categorized into two types:

    1. Independent Parameters: Parameters that are defined directly and do not depend on other parameters.
    2. Dependent Parameters: Parameters whose values or domains are determined by one or more other parameters.

    To create an independent parameter, you typically use build_parameter or add_parameter on an InfiniteModel object.

    # Example conceptual usage
    @infinite_parameter p = ... 
  8. Understand Abstract Dependencies in InfiniteOpt

    master

    InfiniteOpt relies on several abstract types to manage data and indexing within infinite dimensional models:

    • AbstractDataObject: The base type for objects stored within the model.
    • AbstractInfOptIndex: The base type for indices used to reference elements in infinite dimensional spaces.
    • ObjectIndex: A specific type of index used for object management.
  9. How to define derivatives: `@deriv` vs `@variable`

    master

    The recommended workflow is to use @deriv for defining the derivative relationship and @variable when you need to specify bounds or initial guesses.

    • @deriv (or @∂): Best for defining the derivative of any InfiniteOpt expression (including integrals and complex products). It handles recursive definitions and nesting.
    • @variable with Deriv: Best for defining a derivative as a named variable with specific properties like lower/upper bounds and an initial guess (start).

    Warning: Do not redefine the same derivative with multiple @variable calls, as the latest call will overwrite existing properties.

    # Recommended pattern:
    # 1. Define with @variable to set bounds/start
    @variable(model, dydt2 >= 1, Deriv(y, t, 2), start = 0)
    
    # 2. Use @deriv to reference or extend the definition
    @deriv(dydt2, t) 
  10. Specify variable types in InfiniteOpt

    master

    InfiniteOpt extends JuMP with specialized variable types. You specify these by passing a subtype of InfOptVariableType to the @variable macro.

    • Infinite(params...): Represents a variable over a continuous range or distribution.
    • SemiInfinite(infinite_var, fixed_val, params...): Represents a variable that is infinite over some parameters but fixed at a specific value for others.
    • Point(infinite_var, fixed_val, params...): Represents a variable fixed at specific points.
    • Finite: Standard JuMP finite variables.

    Note: SemiInfinite and Point variables inherit the integrality of their respective Infinite variables and this cannot be overwritten.

    # Explicit types
    @variable(model, y, Infinite(t, x...))
    @variable(model, ys, SemiInfinite(y, 0, x...))
    @variable(model, yp, Point(y, 0, [1, 1, 1]...))
    
    # Anonymous types
    y = @variable(model, variable_type = Infinite(t, x...))
  11. Understand Generative Supports

    master

    Generative supports are automatically generated supports (like collocation nodes or quadrature points) based on existing finite elements. These are used by measures and derivative evaluation schemes.

    • Concept: An IndependentParameter can be associated with one AbstractGenerativeInfo object (default is NoGenerativeSupports).
    • UniformGenerativeInfo: A concrete subtype that applies generative supports uniformly to each finite element. It requires a list of relative positions (e.g., [0.5] for the midpoint) and an InternalLabel.
    • API for Extension Writers:
      • generative_support_info(param_ref): Check current generative information.
      • has_generative_supports(param_ref): Check if supports have been created.
      • add_generative_supports(model): Triggers the generation of supports.

    Note: End-users should generally not modify generative supports directly.

    struct MyGenLabel <: InfiniteOpt.InternalLabel end;
    
    # Create info to add a support at the midpoint (0.5) of each element
    info = UniformGenerativeInfo([0.5], MyGenLabel)
  12. Use the TranscriptionOpt backend for InfiniteOpt

    master

    The TranscriptionOpt module is the default transformation backend for InfiniteOpt. It provides the machinery to transcribe infinite-dimensional optimization problems into finite-dimensional ones.

    Key components include:

    • TranscriptionBackend: The core object managing the transcription process.
    • TranscriptionData: Holds the data associated with the transcription.
    • Transcription: The high-level transcription object.

    You can build a backend using build_transcription_backend! or specialize an existing model using build_transformation_backend!.