pyepo.func.rank

Learning to rank Losses

Classes

listwiseLTR

Listwise Learning-to-Rank loss over a cached solution pool.

pairwiseLTR

Pairwise Learning-to-Rank loss over a cached solution pool.

pointwiseLTR

Pointwise Learning-to-Rank loss over a cached solution pool.

Module Contents

class pyepo.func.rank.listwiseLTR(optmodel: pyepo.model.opt.optModel, processes: int = 1, solve_ratio: float = 1.0, reduction: pyepo.func.abcmodule.Reduction = 'mean', dataset: pyepo.data.dataset.optDataset | None = None)

Bases: pyepo.func.abcmodule.optModule

Listwise Learning-to-Rank loss over a cached solution pool.

Models the ranking distribution over the cached pool \(\Gamma\) as SoftMax of predicted-cost scores and minimizes its cross-entropy against the true ranking distribution. The full-list formulation captures interactions between every pair of solutions in \(\Gamma\). Pool semantics (solve_ratio, dataset) are shared with the other LTR variants and with the contrastive methods.

Reference: Mandi et al. (2022) https://proceedings.mlr.press/v162/mandi22a.html

forward(pred_cost: torch.Tensor, true_cost: torch.Tensor) torch.Tensor

Forward pass

class pyepo.func.rank.pairwiseLTR(optmodel: pyepo.model.opt.optModel, processes: int = 1, solve_ratio: float = 1.0, reduction: pyepo.func.abcmodule.Reduction = 'mean', dataset: pyepo.data.dataset.optDataset | None = None)

Bases: pyepo.func.abcmodule.optModule

Pairwise Learning-to-Rank loss over a cached solution pool.

Enforces a margin between the true optimum (the best member of \(\Gamma\)) and each suboptimal solution via a ReLU hinge on the predicted-cost difference. Lighter than the listwise variant (no SoftMax over the full pool) and often a good first choice when the pool is large. Pool semantics (solve_ratio, dataset) are shared with the other LTR variants and with the contrastive methods.

Reference: Mandi et al. (2022) https://proceedings.mlr.press/v162/mandi22a.html

relu
forward(pred_cost: torch.Tensor, true_cost: torch.Tensor) torch.Tensor

Forward pass

class pyepo.func.rank.pointwiseLTR(optmodel: pyepo.model.opt.optModel, processes: int = 1, solve_ratio: float = 1.0, reduction: pyepo.func.abcmodule.Reduction = 'mean', dataset: pyepo.data.dataset.optDataset | None = None)

Bases: pyepo.func.abcmodule.optModule

Pointwise Learning-to-Rank loss over a cached solution pool.

Treats each cached solution \(\mathbf{w} \in \Gamma\) as an independent regression target: the predicted score \(\hat{\mathbf{c}}^\top \mathbf{w}\) is fit toward the true score \(\mathbf{c}^\top \mathbf{w}\) via squared error, averaged over the pool. Cheapest of the three LTR variants – no cross-pool interactions. Pool semantics (solve_ratio, dataset) are shared with the other LTR variants and with the contrastive methods.

Reference: Mandi et al. (2022) https://proceedings.mlr.press/v162/mandi22a.html

forward(pred_cost: torch.Tensor, true_cost: torch.Tensor) torch.Tensor

Forward pass