Objective.add_term#

Objective.add_term(fn: Callable)[source]#

Register an extra cost term added to this objective at evaluate time.

Used by mixin subclasses (e.g. ESD1Base, RTEDVIS) that extend a parent's objective without rewriting it. fn(r) receives a RoutineNS and returns a scalar CVXPY expression; that expression is summed onto the base objective before the cp.Minimize/cp.Maximize wrap.

Composes equally with e_str-form and e_fn-form parents, so a parent can migrate from one to the other without breaking any subclass that registered terms.