pyepo.utils =========== .. py:module:: pyepo.utils .. autoapi-nested-parse:: Package-wide utility functions Functions --------- .. autoapisummary:: pyepo.utils.objective_offset pyepo.utils.require_linear_objective pyepo.utils.costToNumpy Module Contents --------------- .. py:function:: objective_offset(model: pyepo.model.opt.optModel) -> float Bare objective constant of a compiled DSL problem. :param model: optimization model :returns: objective constant, 0.0 for models without one :rtype: float .. py:function:: require_linear_objective(optmodel: pyepo.model.opt.optModel) -> None Reject compiled DSL models carrying a quadratic objective term. :param optmodel: optimization model .. py:function:: costToNumpy(c: numpy.ndarray | torch.Tensor | list, dtype: Any = np.float32) -> numpy.ndarray Normalize a cost vector to a numpy array, detaching torch tensors as needed. :param c: cost vector :param dtype: target dtype when ``c`` is not already a tensor; torch tensors are converted via ``.detach().cpu().numpy()`` and keep their existing dtype. :returns: numpy cost vector :rtype: np.ndarray