khalil-research / PyEPO

A PyTorch-based End-to-End Predict-then-Optimize Library for Linear and Integer Programming
MIT License
429 stars 56 forks source link

Implemented noise contrastive estimation and learning to rank losses #10

Closed LucasBoTang closed 1 year ago

LucasBoTang commented 1 year ago

It is the same pull request as pull #9, but it pull to a new branch for further review.

This contribution adds the noise contrastive estimation and the learning to rank losses for decision-focused learning to PyEPO. Both of these approaches make use of the solution caching scheme that is already implemented in PyEPO.

Concretely, the following changes are included:

a new file named learning_to_rank.py, which includes an abstract LearningToRank class, as well as three concrete subclasses for the different learning-to-rank methods: ListwiseLTR, PairwiseLTR, and PointwiseLTR. a new file named nce.py, which includes the NCE class, which implements the noise contrastive estimation loss. the use of the listwise learning to rank method has been added to the 03 Training and Testing.ipynb notebook. the README.md file has been updated to include the new methods.