Accessor method for constants. Returns ------- list of :class:`~cvxpy.expressions.constants.constant.Constant` A list of the constants in the problem.
(self)
| 482 | |
| 483 | @perf.compute_once |
| 484 | def constants(self) -> list[Constant]: |
| 485 | """Accessor method for constants. |
| 486 | |
| 487 | Returns |
| 488 | ------- |
| 489 | list of :class:`~cvxpy.expressions.constants.constant.Constant` |
| 490 | A list of the constants in the problem. |
| 491 | """ |
| 492 | const_dict = {} |
| 493 | constants_ = self.objective.constants() |
| 494 | for constr in self.constraints: |
| 495 | constants_ += constr.constants() |
| 496 | # Note that numpy matrices are not hashable, so we use the built-in |
| 497 | # function "id" |
| 498 | const_dict = {id(constant): constant for constant in constants_} |
| 499 | return list(const_dict.values()) |
| 500 | |
| 501 | def atoms(self) -> list[Atom]: |
| 502 | """Accessor method for atoms. |