Skip to content

Add @register_multivariate for n-argument custom operators #239

@andrewrosemberg

Description

@andrewrosemberg

Current behavior

ExaModels provides @register_univariate and @register_bivariate for registering custom scalar operators with user-supplied derivatives. There is no equivalent for functions of 3 or more scalar arguments.

New feature

A @register_multivariate(f, n, grad!, hess!) macro (or equivalent) that registers an n-argument scalar function with explicitly provided gradient and Hessian:

# f(x₁, ..., xₙ) -> scalar
# grad!(g, x₁, ..., xₙ) fills the n-vector of partial derivatives
# hess!(H, x₁, ..., xₙ) fills the n×n lower-triangular Hessian

Personal Motivation

My primary use case is embedding external physics "black-box" simulators (e.g., MuJoCo MJX, Dojo) into ExaModels problems: x_{t+1} - f(x_t, u_t) = 0 with available Jacobians and Hessians.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions