Skip to content

Problems

The description of an optimization problem.

Problem

Bases: NamedTuple

A nonlinear optimization problem over a pytree of variables.

Without an objective the problem asks for a feasible point.

variables instance-attribute

variables: PyTree[Variable]

A pytree with a Variable at every leaf, which fixes the structure of x.

objective class-attribute instance-attribute

objective: ParametricFunction | None = None

A function with a scalar output.

jacobian_pattern class-attribute instance-attribute

jacobian_pattern: Pattern | None = None

Where the Jacobian of the constraints is nonzero, or None to detect it.

hessian_pattern class-attribute instance-attribute

hessian_pattern: Pattern | None = None

Where the Hessian of the Lagrangian is nonzero, or None to detect it.

Variable

Bases: NamedTuple

An array of continuous decision variables with bounds.

Its shape is the broadcast of shape and the shapes of the bounds.

Constraint

Bases: NamedTuple

The constraint lower ≤ function(x, params) ≤ upper, one row per output entry.

lower and upper broadcast to the shape of the output. Equal bounds make an equality constraint.

ParametricFunction

Bases: Protocol

A JAX function f(x, params) of the variables and the parameters of a problem.

x has the structure of Problem.variables with an array in place of every Variable. params is the pytree passed to compile and solve.

Pattern module-attribute

Pattern = Any

Where a derivative can be nonzero, given in one of four forms.

  • A boolean matrix, Bool[np.ndarray, "rows columns"].
  • A pair (rows, columns) of integer vectors, one entry per nonzero.
  • An asdex.SparsityPattern, which has to carry its input_avals when it is built.
  • A jax.experimental.sparse.BCOO matrix, whose stored entries are the nonzeros.

The rows of a Jacobian pattern are the entries of the constraints in the order of Problem.constraints, and the columns are the flattened variables. A Hessian pattern is square over the flattened variables and may list one triangle or both.

Sense

Bases: IntEnum

Direction of optimization.