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 aRoutineNSand returns a scalar CVXPY expression; that expression is summed onto the base objective before thecp.Minimize/cp.Maximizewrap.Composes equally with
e_str-form ande_fn-form parents, so a parent can migrate from one to the other without breaking any subclass that registered terms.