pyepo.metric.unambregret¶
Unambiguous regret loss
Attributes¶
Functions¶
|
Normalized unambiguous regret (worst-case-tie SPO loss). |
|
A function to calculate normalized unambiguous regret for a batch |
Module Contents¶
- pyepo.metric.unambregret.logger¶
- pyepo.metric.unambregret.unambRegret(predmodel: torch.nn.Module, optmodel: pyepo.model.opt.optModel, dataloader: torch.utils.data.DataLoader, tolerance: float = 1e-05) float¶
Normalized unambiguous regret (worst-case-tie SPO loss).
When the predicted cost vector \(\hat{\mathbf{c}}\) yields multiple optimal solutions,
regretreports the realized one whileunambRegretreports the worst case over all optima: \(l_{\mathrm{URegret}}(\hat{\mathbf{c}}, \mathbf{c}) = \max_{\mathbf{w} \in W^*(\hat{\mathbf{c}})} \mathbf{c}^\top \mathbf{w} - z^*(\mathbf{c})\). More theoretically rigorous thanregret, but in practice the two are nearly identical andunambRegretis rarely required.- Parameters:
predmodel – a regression neural network for cost prediction
optmodel – a PyEPO optimization model
dataloader – PyTorch DataLoader over an
optDatasettolerance – precision used when rounding predicted costs to find ties
- Returns:
normalized unambiguous regret
- Return type:
- pyepo.metric.unambregret.calUnambRegret(optmodel: pyepo.model.opt.optModel, pred_cost: numpy.ndarray, true_cost: numpy.ndarray, true_obj: float, tolerance: float = 1e-05, max_iter: int = 10) float¶
A function to calculate normalized unambiguous regret for a batch
- Parameters:
optmodel – optimization model
pred_cost – predicted costs
true_cost – true costs
true_obj – true optimal objective value
tolerance – tolerance for precision
max_iter – maximum number of recursive retries
- Returns:
unambiguous regret loss
- Return type: