ams.opt.objective.Objective#
- class ams.opt.objective.Objective(name: str | None = None, e_str: str | None = None, e_fn: Callable | None = None, info: str | None = None, unit: str | None = None, sense: str | None = 'min')[source]#
Base class for objective functions.
Exactly one of
e_strore_fnshould be provided.e_fn(r)is the Phase 4.1+ form: a callable that takes aRoutineNSand returns the inner CVXPY expression to be minimized/maximized (thecp.Minimize/cp.Maximizewrapping is handled byObjective.evaluate).- Parameters:
- namestr, optional
A user-defined name for the objective function.
- e_strstr, optional
A mathematical expression (legacy form).
- e_fncallable, optional
Callable
e_fn(r) -> cp.Expressiontaking aRoutineNS.- infostr, optional
Additional informational text about the objective function.
- sensestr, optional
The sense of the objective function, default to 'min'. min for minimization and max for maximization.
- Attributes:
vNoneTypeReturn the CVXPY objective value.
- rtnams.routines.Routine
The owner routine instance.
- codestr
The code string for the objective function.
- __init__(name: str | None = None, e_str: str | None = None, e_fn: Callable | None = None, info: str | None = None, unit: str | None = None, sense: str | None = 'min')[source]#
Methods
add_term(fn)Register an extra cost term added to this objective at evaluate time.
evaluate(*args, **kwargs)Return all the indexes of this item.
get_idx()parse(*args, **kwargs)Attributes
Return the class name
Return the calculated numerical value of the underlying expression.
Mutex descriptor for
e_str/e_fnon opt elements.Mutex descriptor for
e_str/e_fnon opt elements.Where the live CVXPY object for this item came from.
Return the number of elements.
Return the shape.
Return the size.
Return the CVXPY objective value.