pyepo.utils

Package-wide utility functions

Functions

getArgs(→ dict)

A global function to get args of model

costToNumpy(→ numpy.ndarray)

Normalize a cost vector to a numpy array, detaching torch tensors as needed.

Module Contents

pyepo.utils.getArgs(model: pyepo.model.opt.optModel) dict

A global function to get args of model

Parameters:

model – optimization model

Returns:

model args

Return type:

dict

pyepo.utils.costToNumpy(c: numpy.ndarray | torch.Tensor | list, dtype=np.float32) numpy.ndarray

Normalize a cost vector to a numpy array, detaching torch tensors as needed.

Parameters:
  • c – cost vector

  • 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

Return type:

np.ndarray