symforce.opt.objective module#

class Objective[source]#

Bases: ABC

An objective, defined as a residual or group of residuals and an associated Params block

Subclasses should add individual residual functions as static methods that return residual_block.ResidualBlock, and define the Params block as a dataclass

Params: Dataclass#
static default_inputs(enabled)[source]#

Should return instantiated numerical arguments for the residual function(s) of this objective, to be used for testing and sanity checking

Parameters:

enabled (bool) – Whether to configure the objective params with the objective enabled or not (e.g. setting costs to 0)

Return type:

Values

class TimestepObjective[source]#

Bases: Objective

An objective defined as a single residual applied over multiple timesteps, and associated Params block

Subclasses should define the residual_at_timestep() function needed to compute the residual at each timestep.

abstract residual_at_timestep(*args)[source]#

Compute the residual at a single timestep

Parameters:
  • * – Any arguments needed for the particular residual; typically these are expressions evaluated at a particular time, or single element of a timestepped sequence

  • args (Any) –

Returns:

residual_block – The ResidualBlock for this objective at this timestep

Return type:

ResidualBlock

Params: Dataclass#